Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.82 KB | None | 0 0
  1. <?php
  2. if(isset($_GET['uploadpdffile']))
  3. {
  4.     $pdffile = $_GET['uploadpdffile'];
  5.     include('lib/PdfToText.phpclass');
  6.     $time_pattern1      = '/(\d{2}:\d{2}:\d{2} [A-Za-z]{2})/';
  7.     $time_pattern2      = '/(\d{2}:\d{2} [A-Za-z]{2})/';
  8.     $space_utf_pattern  = '/(\t|\n|\v|\f|\r| |\xC2\x85|\xc2\xa0|\xe1\xa0\x8e|\xe2\x80[\x80-\x8D]|\xe2\x80\xa8|\xe2\x80\xa9|\xe2\x80\xaF|\xe2\x81\x9f|\xe2\x81\xa0|\xe3\x80\x80|\xef\xbb\xbf)+/';
  9.     //$pdf                = new PdfToText('schedule 11 efcc sample.pdf');
  10.     $pdf                = $pdffile;
  11.     $displaymode = 'false';
  12.  
  13.     if(isset($_GET['verbose'])){
  14.         $displaymode = $_GET['verbose'];
  15.     }
  16.     $physicians = array();
  17.     $text = preg_replace($space_utf_pattern, ' ', $pdf->Text);
  18.  
  19.     $header = explode(' ', substr($text, 0, 200));
  20.  
  21.     if($displaymode == 'true'){
  22.  
  23.     }
  24.     if($displaymode == 'true'){
  25.  
  26.     }
  27.  
  28.     foreach ($header as $key => $value)
  29.     {
  30.         //print_r($value.'<br/>');
  31.             if($value=='Schedule for'){
  32.                 $physicians[] = str_replace('TimeNameVisits:', 'Visits:', $header[$key-1]);
  33.                // print_r('TRUE');
  34.             }
  35.     }
  36.  
  37.     $text           = str_replace('Schedule for ', '', $text);
  38.     $tmpdoc         = substr($text, 0, strpos($text,','));
  39.     $tmptext        = substr($text, strpos($text,','), strlen($text));
  40.     $text           = $tmptext;
  41.     $physicians[]   = $tmpdoc;
  42.  
  43.     if(preg_match($time_pattern1, $text))
  44.     {
  45.  
  46.     }
  47.     if(preg_match($time_pattern2, $text))
  48.     {
  49.         $data_raw = preg_split($time_pattern2, $text, NULL, PREG_SPLIT_DELIM_CAPTURE);
  50.     }
  51.     for($i=1; $i<count($data_raw); $i++) {
  52.         if($i%2==0)
  53.         {
  54.             //$data_raw[$i] = preg_replace('/\s*\([^)]*\)|F\/U|Fully Booked\.|Checked In|OVERBOOKED|Booked|\d{2} MINUTES\.|Missed|FM|See ACPM|Comment|^(([\+]([\d]{2,}))([0-9\.\-\/\s]{5,})|([0-9\.\-\/\s]{5,}))*$/', '', $data_raw[$i]);
  55.             $data_raw[$i] = preg_replace('/\s*\([^)]*\)|f\/u|fully booked\.|checked in|overbooked|booked|\d{2} minutes\.|missed|FM|see acpm|comment/', '', strtolower($data_raw[$i]));
  56.             $data_raw[$i] = preg_replace('/\s+/', ' ', trim($data_raw[$i]));
  57.             $data[$data_raw[$i-1]] = $data_raw[$i];
  58.         }
  59.     }
  60.         $tmparraykeys = array();
  61.     foreach($data as $key => $value)
  62.     {
  63.  
  64.         $tmpstr = preg_split('/(([\+]([\d]{2,}))([0-9\.\-\/\s]{5,})|([0-9\.\-\/\s]{5,}))/', $value,NULL, PREG_SPLIT_DELIM_CAPTURE);
  65.         $tmparr_nameandphone = preg_split('/\s+/', $tmpstr[1]);
  66.         $tmparrayvalues = array($tmpstr[0],$tmparr_nameandphone[1],$tmparr_nameandphone[0],);
  67.         $tmparrayvalues[0] = preg_split('/(\d{2})/', $tmparrayvalues[0]);
  68.         $tmparraykeys['physician'] = $physicians[0];
  69.         $tmparraykeys['name']   = $tmparrayvalues[0][0];
  70.         $tmparraykeys['phone']  = $tmparrayvalues[1];
  71.         //$tmparraykeys['min']    = $tmparrayvalues[2];
  72.         $data2[$key]            = $tmparraykeys;
  73.         //$data2[$key][phonenumber] = $tmparr[0];
  74.     }
  75.  
  76.  
  77.     foreach($data2 as $key1 => $tmparr)
  78.     {
  79.         foreach($tmparr as $key2 => $value)
  80.         {
  81.             if(strtolower($value) =='- not available')
  82.             {
  83.                 unset($data2[$key1]);
  84.             }
  85.         }
  86.  
  87.     }
  88.  
  89.     $schedule = json_encode($value);
  90.     print_r($schedule);
  91.    // exit;
  92.     /*************************************************************\
  93.     foreach($data2 as $key => $arrtmp) {
  94.        // print_r($arrtmp);
  95.         foreach($data2 as $arrtmp=>$value)
  96.         {
  97.             //$pieces = explode(' ', $value);
  98.             $pieces = $value;
  99.             $data[$arrtmp] = @array($physicians[0]=>$pieces[0].' '.$pieces[1],
  100.                                                      $physicians[1]=>$pieces[2].' '.$pieces[3]);
  101.         }
  102.     }
  103.      *
  104.      */
  105. }
  106. //print_r($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement