Guest User

zxcbdf

a guest
Jul 3rd, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. # Required files
  4. require ("{$_SERVER['DOCUMENT_ROOT']}/config/pipeline-x.php");
  5. include ("linkedin-functions.php");
  6. include ("simple-html-dom.php");
  7.  
  8. # Define variables
  9. $fn = urlencode($_REQUEST['fn']);
  10. $ln = urlencode($_REQUEST['ln']);
  11.  
  12. # Connect to database
  13. $db = new px_dbasei();
  14. $db->connect("192.168.50.70", "jerry", "0ldn3w5", "pipeline_test");
  15.  
  16. # Query records that are less than 30 days old
  17. $sql = "SELECT * FROM linkedin_parse "
  18.       ."WHERE "
  19.       ."`first_name` = '{$fn}' AND "
  20.       ."`last_name` = '{$ln}' AND "
  21.       ."`date_inserted` < DATE_SUB(NOW(), INTERVAL 30 DAY) ";
  22. $results = $db->query($sql);
  23.  
  24. # If no rows return
  25. if($results->num_rows == 0):
  26.     # Query records if there are match
  27.     $sql = "SELECT * FROM linkedin_parse "
  28.           ."WHERE "
  29.           ."`first_name` = '{$fn}' AND "
  30.           ."`last_name` = '{$ln}' ";
  31.     $results = $db->query($sql);
  32.     # If there are no results then perform INSERT
  33.     if($results->num_rows == 0):
  34.         echo 'Perform INSERT';
  35.     else:
  36.         echo 'Perform UPDATE';
  37.         # Search linkedin and download page
  38.         $ch = curl_init();
  39.         curl_setopt($ch, CURLOPT_URL, "http://www.linkedin.com/pub/dir/?first={$fn}&last={$ln}&search=Search");
  40.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");
  41.         curl_setopt($ch, CURLOPT_HEADER, 0);
  42.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  43.         curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
  44.         curl_setopt($ch, CURLOPT_TIMEOUT, 8);
  45.         $res = curl_exec($ch);
  46.         curl_close($ch);
  47.         $html = str_get_html($res);
  48.  
  49.         parse_records($html);
  50.         print_r($table);
  51.     endif;
  52. endif;
Advertisement
Add Comment
Please, Sign In to add comment