Advertisement
Ashesh

Error Help

Oct 30th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php  
  4.  
  5.  
  6.  
  7.    $dbhost = 'x.x.x';
  8.    $dbuser = 'x';
  9.    $dbpass = 'x*';
  10.    
  11.    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  12.    if(! $conn )
  13.    {
  14.      die('Could not connect: ' . mysql_error());
  15.    }
  16.    
  17.    mysql_select_db('1737892_root') or trigger_error("Unable to switch to the database: " . mysql_error());
  18.  
  19.    
  20. function arr($num,$part){
  21.  
  22. $ch = curl_init();
  23. $r= rand (1,90);
  24.  
  25. $partt=intval($part);
  26.  
  27. if($partt==1){
  28. $url="https://www.googleapis.com/customsearch/v1?q=G&num=10&start=".$r."&safe=off&cx=x:2hdsc4__avm&filter=0&c2coff=disable&alt=json&key=x";
  29.  
  30. }elseif($partt==2){
  31.  
  32.  
  33. $url="https://www.googleapis.com/customsearch/v1?q=G&num=10&start=".$r."&safe=off&cx=xx:gxhaza__iwg&filter=0&c2coff=disable&alt=json&key=xx";
  34. }elseif($partt==3){
  35.  
  36. $url="https://www.googleapis.com/customsearch/v1?q=G&num=10&start=".$r."&safe=off&cx=xxx:yzy968__ofi&filter=0&c2coff=disable&alt=json&key=xxx-K-uxTnbXtEI";
  37. }elseif($partt==4){
  38.  
  39. $url="https://www.googleapis.com/customsearch/v1?q=G&num=10&start=".$r."&safe=off&cx=xxxx%3Anbwg77___eg&filter=0&c2coff=disable&alt=json&key=xxxx";
  40.  
  41.  
  42. }else{
  43.  
  44. return '00';
  45. exit;
  46.  
  47.  
  48. }
  49.  
  50.  
  51. curl_setopt($ch, CURLOPT_URL, $url);
  52.  
  53. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  54.  
  55. $output = curl_exec($ch);
  56.  
  57.  
  58. curl_close($ch);
  59.  
  60.  
  61.  
  62.         $a=intval($num);
  63.         $data = json_decode($output, true);
  64.         $se= $data['items'][$a]['pagemap']['cse_image'][0]['src'];
  65.        // till here $se = "blah"
  66.         if($se='' || $se=""||$se=NULL || !(isset($se))){
  67.        
  68.           $p=$part+1;          
  69.          
  70.           arr($rr,$p);
  71.        
  72.         }
  73.        
  74.          $query = mysql_query("SELECT `url` FROM `url` WHERE `url`='".$se."'");
  75.          
  76.         if (mysql_num_rows($query) === 0)
  77.   {
  78.    
  79.      $rr= rand (1,10);
  80.         // return back
  81.       mysql_query("INSERT INTO `url`(`url`) VALUES ('".$se."')");
  82.       return $se;
  83.      
  84.   }else{
  85. // Url already exists fetch another
  86.        
  87.      arr($rr,$part);
  88.      
  89.      
  90.       }
  91.      
  92.  
  93. $rr= rand (1,10);
  94. $randed= arr($rr,'1');
  95. echo $randed;
  96. exit;
  97.  
  98. ?>
  99. </body>
  100. </html>
  101.  
  102.  
  103. This page takes forever to load!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement