Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

shantanu oak http://oksoft.blogspot.com

« Newer Snippets
Older Snippets »
Showing 11-14 of 14 total

Yubnub "checkshortcut" command to check alias

   1  
   2  <?php
   3  
   4  if (!$link = mysql_connect('', '', '')) {
   5     echo 'Could not connect to mysql';
   6     exit;
   7  }
   8  
   9  if (!mysql_select_db('yub', $link)) {
  10     echo 'Could not select database';
  11     exit;
  12  }
  13  $sendto1 = mysql_query("select email from yubmail where mail_alias = '$path'");
  14  $sendto2 = mysql_result($sendto1, 0);
  15  
  16  if (!$sendto2) {
  17     echo "The alias does not exist! You can try to create one or send the message to mailinator ailas.";
  18  exit;
  19  }
  20  
  21  echo "The alias $path does exist!";
  22  ?>

Yubnub "dbsearch" command to search MySQL data

   1  
   2  <META HTTP-EQUIV="Refresh" CONTENT="0;URL=
   3  <?php
   4  $compare1 = substr($path, 0, 7);
   5  if ($compare1 == "http://"){
   6  echo $path.'db_search.php?search_option=1&submit_search=Go&db='.$db.'&search_str='.$search;
   7  }
   8  
   9  if (!$link = mysql_connect('', '', '')) {
  10     echo 'Could not connect to mysql';
  11     exit;
  12  }
  13  
  14  if (!mysql_select_db('yub', $link)) {
  15     echo 'Could not select database';
  16     exit;
  17  }
  18  $sendto1 = mysql_query("select email from yubmail where mail_alias = '$path'");
  19  $sendto2 = mysql_result($sendto1, 0);
  20  echo $sendto2.'db_search.php?search_option=1&submit_search=Go&db='.$db.'&search_str='.$search;
  21  ?>
  22  ">

Yubnub "data" command to display MySQL data

   1  
   2  <?php
   3  // Yubnub.org command "data" access this show.php file on the server
   4        
   5  //    $dbname = "";
   6  //    $loginname = "";
   7  //    $loginpass = "";
   8  //    $dbhost = "";
   9      
  10      echo('<html><body bgcolor="#FFFFFF">');
  11      echo('<font face="arial" size="+4"><center>');
  12      echo(" $dbname");
  13      
  14      $id_link = @mysql_connect($dbhost, $login, $password);
  15      
  16      $tables = mysql_list_tables($dbname, $id_link);
  17      
  18      $num_tables = mysql_num_rows($tables);
  19  
  20      // store table names in an array
  21      $arr_tablenames[] = '';
  22      
  23      // store number of fields per table(index 0,1,2..) in an array
  24      $arr_num_fields[] = '';
  25      for ($i=0; $i < $num_tables; $i++) {
  26          $arr_tablenames[$i] = mysql_tablename($tables, $i);
  27          $arr_num_fields[$i] = mysql_num_fields(mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link));
  28      }
  29      
  30      // store field names in a multidimensional array:
  31      // [i] == table number, [ii] == field number for that table
  32      for ($i=0; $i < $num_tables; $i++) {
  33          for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
  34              $result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
  35              $hash_field_names[$i][$ii] = mysql_field_name($result, $ii);
  36          }    
  37      }
  38      
  39      for ($i=0; $i < $num_tables; $i++) {
  40          echo("<center><h2> $arr_tablenames[$i] </h2></center>");
  41          echo('<table align="center" border="1"><tr>');
  42          $result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
  43          for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
  44              echo("<th>");
  45              echo $hash_field_names[$i][$ii];
  46              echo("</th>");
  47          }
  48          echo("</tr><tr>");
  49          $number_of_rows = @mysql_num_rows($result);
  50          for ($iii = 0; $iii < $number_of_rows; $iii++) {
  51              $record = @mysql_fetch_row($result);
  52              for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
  53                  echo("<td>");
  54                  // echo $record[$ii];
  55                  $mytext = nl2br($record[$ii]);
  56                  echo $mytext;
  57                  echo("</td>");
  58              }
  59          echo("</tr>");
  60          }
  61          echo("</table>");
  62      }
  63      
  64  
  65  
  66      echo('</body></html>');
  67  
  68  ?>
  69  

Yubnub "shortcut" command source

   1  
   2  <?php
   3  
   4  // CREATE TABLE `yubmail` (
   5  // `id` int(11) NOT NULL auto_increment,
   6  // `mail_alias` varchar(250) NOT NULL default '',
   7  // `email` varchar(250) NOT NULL default '',
   8  // `modifed1` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   9  // `paid` enum('Y','N') default 'N',
  10  // PRIMARY KEY (`id`),
  11  // UNIQUE KEY `mail_alias` (`mail_alias`)
  12  // ) ENGINE=MyISAM
  13  
  14  
  15   $this = ' ';
  16     function after ($this, $alias)
  17     {
  18         if (!is_bool(strpos($alias, $this)))
  19         return substr($alias, strpos($alias,$this)+strlen($this));
  20     };
  21  
  22     function before ($this, $alias)
  23     {
  24         return substr($alias, 0, strpos($alias, $this));
  25     };
  26  $mail_alias = before ($this, $alias);
  27  $email = after ($this, $alias); 
  28  
  29  if (!$link = mysql_connect('mysql', 'username', 'password')) {
  30     echo 'Could not connect to mysql';
  31     exit;
  32  }
  33  
  34  if (!mysql_select_db('yub', $link)) {
  35     echo 'Could not select database';
  36     exit;
  37  }
  38  
  39  $sql_query = mysql_query("INSERT INTO yubmail(mail_alias, email) VALUES ('$mail_alias', '$email')") ;
  40  
  41  if (!$sql_query) {
  42     die('Try again with different shortcut');
  43  }
  44  echo "alias created called <b><i>$mail_alias</i></b> directing to <b>$email</b>";
  45  ?> 
  46  
« Newer Snippets
Older Snippets »
Showing 11-14 of 14 total