Ejemplo n.º 1
0
 public function passwdgen()
 {
     //read an html file with English words to use for passwords into variable $html
     $html = new \Htmldom('http://www.paulnoll.com/Books/Clear-English/words-03-04-hundred.html');
     //print_r($_REQUEST) ;
     // Retrieve all li elements from $html and store words in array
     foreach ($html->find('li') as $e) {
         $words[] = $e->innertext;
     }
     $numwords = 2;
     $separator = "+";
     //randomly select array keys based on number of words
     $wordcount = array_rand($words, $numwords);
     $newpassword = "";
     foreach ($wordcount as $value) {
         $newpassword .= $words[$value];
     }
     //$Password_String =  $newpassword;
     $Password_String = trim($newpassword);
     $Password_String = preg_replace('/\\s{2,}/', $separator, $Password_String);
     //append the number at the end
     $AppendNum = rand(0, 10);
     $Password_String = $Password_String . $AppendNum;
     return $Password_String;
 }
Ejemplo n.º 2
0
 public function getStory($storyId)
 {
     $story = Stories::find($storyId);
     $excerptExtract = $story->feed->excerpt;
     $dom = new \Htmldom(htmlspecialchars_decode(urldecode($story->url)));
     $body = $dom->find($excerptExtract, 0);
     return response()->json(array('body' => $body->innertext));
 }
Ejemplo n.º 3
0
 public function getHtmlDom($link)
 {
     try {
         $html = new \Htmldom();
         $html->file_get_html($link);
     } catch (\Exception $e) {
         return false;
     }
     return $html;
 }
 public function getUrls($keyword)
 {
     $html = new \Htmldom($this->url . urlencode($keyword));
     $links = array();
     $rank = 1;
     foreach ($html->find('h3.r a') as $element) {
         $url = html_entity_decode(str_replace("/url?q=", "", $element->href));
         $urlArray = explode("&sa", $url);
         $links[] = array('rank' => $rank, 'value' => $urlArray[0]);
         $rank++;
     }
     return $links;
 }
Ejemplo n.º 5
0
 public function getMovie()
 {
     $html = new \Htmldom('http://www.google.com.au/movies?near=bangalore');
     print '<pre>';
     foreach ($html->find('#movie_results .theater') as $div) {
         print "Theate:  " . $div->find('h2 a', 0)->innertext . "\n";
         print "Address: " . $div->find('.info', 0)->innertext . "\n";
         foreach ($div->find('.movie') as $movie) {
             print "\tMovie:    " . $movie->find('.name a', 0)->innertext . '<br />';
             print "\tTime:    " . $movie->find('.times', 0)->innertext . '<br />';
         }
         print "\n\n";
     }
     $html->clear();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $html = new \Htmldom('http://www.google.com.au/movies?near=bangalore');
     print '<pre>';
     foreach ($html->find('#movie_results .theater') as $div) {
         print "Theate:  " . $div->find('h2 a', 0)->innertext . "\n";
         print "Address: " . $div->find('.info', 0)->innertext . "\n";
         foreach ($div->find('.movie') as $movie) {
             print "\tMovie:    " . $movie->find('.name a', 0)->innertext . '<br />';
             print "\tTime:    " . $movie->find('.times', 0)->innertext . '<br />';
         }
         print "\n\n";
     }
     $html->clear();
     $list = array(["title" => 'Reggae', "id" => 1], ["title" => 'Chill', "id" => 2], ["title" => 'Dubstep', "id" => 3], ["title" => 'Indie', "id" => 4], ["title" => 'Rap', "id" => 5], ["title" => 'Cowbell', "id" => 6]);
     echo json_encode($list);
 }
Ejemplo n.º 7
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $client = new \GuzzleHttp\Client(['cookies' => true, 'timeout' => 20.0, 'connect_timeout' => 20.0, 'verify' => false, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2398.0 Safari/537.36', 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding' => 'gzip, deflate, sdch', 'Accept-Language' => 'en-US,en;q=0.8', 'Dnt' => '1', 'Pragma' => 'no-cache', 'Cache-Control' => 'no-cache', 'Host' => 'ais-cs.ucsc.edu', 'Origin' => 'https://ais-cs.ucsc.edu', 'Connection' => 'keep-alive', 'DNT' => 1]]);
     $counter = 0;
     do {
         $decrypted = Crypt::decrypt($this->user->gold_password);
         $login = $client->request('POST', 'https://ais-cs.ucsc.edu/psc/csprd/EMPLOYEE/PSFT_CSPRD/c/SA_LEARNER_SERVICES.SSR_SSENRL_CART.GBL?cmd=login&languageCd=ENG', ['form_params' => ['timezoneOffset' => 480, 'Submit' => 'Sign In', 'userid' => $this->user->cruz_id, 'pwd' => $decrypted]]);
         $html = new \Htmldom();
         $html->load($login->getBody());
         $classes = [];
         $rows = $html->find('table.PSLEVEL2GRIDWBO a.PSHYPERLINK');
         foreach ($rows as $row) {
             $classes[] = $row->plaintext;
         }
         $counter += 1;
     } while (count($classes) == 0 && $counter != 10);
     $class_name = [];
     $class_number = [];
     foreach ($classes as $indice => $value) {
         //DAN DID THIS
         $findPosition = strpos($classes[$indice], '(');
         $subString = rtrim(substr($classes[$indice], 0, $findPosition - 1));
         $class_name[$indice] = $subString;
         $findPosition = strpos($classes[$indice], '(');
         $subString = substr($classes[$indice], $findPosition + 1, 5);
         $class_number[$indice] = $subString;
     }
     //echo 'classes:' . count($class_name);
     $pusher_data = [];
     foreach ($class_name as $indice => $value) {
         $class = SchoolClass::where('class_id', $class_number[$indice])->first();
         if (!$class) {
             $class = SchoolClass::create(['class_name' => $class_name[$indice], 'class_id' => $class_number[$indice]]);
         }
         UserClass::create(['user_id' => $this->user->id, 'class_id' => $class->id, 'priority' => 1]);
         $pusher_data[] = ['class_name' => $class->class_name, 'class_id' => $class->id, 'user_id' => $this->user->id, 'priority' => 1];
     }
     LaravelPusher::trigger('user' . $this->user->id, 'register', ['message' => $pusher_data]);
 }
Ejemplo n.º 8
0
Route::get('katalog/{path}', 'CategoriesController@index')->where('path', '(.*)?');
Route::get('product/{path}', 'WaresController@index')->where('path', '(.*)?');
Route::any('ajax-cart', 'HomeController@ajaxCart');
Route::any('ajax-cart-remove', 'HomeController@ajaxCartRemove');
Route::get('cart-test', function () {
    $cartContentObj = Cart::content();
    $cartContentArr = [];
    foreach ($cartContentObj as $item) {
        $item->thumbnail = $item->ware->thumbnail;
        $item->options['slug'] = 'sdfsd';
        $cartContentArr[] = $item;
    }
    return $cartContentArr;
});
Route::get('get-data', function () {
    $html = new Htmldom('http://dmtoys.com.ua/catalog/igrushki/interaktivnye-igrushki/angry-birds');
    foreach ($html->find('#primary-menu-inner a') as $item) {
        echo $item->href . '<br>';
    }
});
Route::get('cart-destroy', function () {
    Cart::destroy();
});
Route::get('cart', 'HomeController@cart');
Route::get('adm', 'AdminController@index');
Route::post('adm/categories', 'CategoriesController@store');
Route::get('adm/categories', 'CategoriesController@adminIndex');
Route::get('adm/categories/create', 'CategoriesController@create');
Route::get('adm/categories/{id}', 'CategoriesController@edit');
Route::put('adm/categories/{id}', 'CategoriesController@update');
Route::get('adm/categories/{id}/destroy', 'CategoriesController@destroy');
Ejemplo n.º 9
0
 protected function claim_reason_code($code)
 {
     $url = 'http://www.wpc-edi.com/reference/codelists/healthcare/claim-adjustment-reason-codes/';
     $html = new Htmldom($url);
     $table = $html->find('table[id=codelist]', 0);
     $description = '';
     foreach ($table->find('tr[class=current]') as $row) {
         $code_row = $row->find('td[class=code]', 0);
         $description_row = $row->find('td[class=description]', 0);
         $date_row = $row->find('span[class=dates]', 0);
         if ($code == $code_row->innertext) {
             $description = $description_row->plaintext;
             $date = $date_row->plaintext;
             $description = trim(str_replace($date, '', $description));
             break;
         }
     }
     if ($description == '') {
         return $code . ', Code unknown';
     } else {
         return $description;
     }
 }
Ejemplo n.º 10
0
 public function uma_auth()
 {
     $open_id_url = str_replace('/nosh', '/uma-server-webapp/', URL::to('/'));
     $practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first();
     $client_id = $practice->uma_client_id;
     $client_secret = $practice->uma_client_secret;
     $url = route('uma_auth');
     $oidc = new OpenIDConnectClient($open_id_url, $client_id, $client_secret);
     $oidc->setRedirectURL($url);
     if ($practice->uma_refresh_token == '') {
         $oidc->addScope('openid');
         $oidc->addScope('email');
         $oidc->addScope('profile');
         $oidc->addScope('offline_access');
         $oidc->addScope('uma_protection');
     } else {
         $oidc->addScope('openid');
         $oidc->addScope('email');
         $oidc->addScope('profile');
     }
     $oidc->authenticate(true);
     $firstname = $oidc->requestUserInfo('given_name');
     $lastname = $oidc->requestUserInfo('family_name');
     $email = $oidc->requestUserInfo('email');
     $npi = $oidc->requestUserInfo('npi');
     $access_token = $oidc->getAccessToken();
     if ($npi != '') {
         $provider = DB::table('providers')->where('npi', '=', $npi)->first();
         if ($provider) {
             $user = User::where('id', '=', $provider->id)->first();
         } else {
             $user = false;
         }
     } else {
         $user = User::where('uid', '=', $oidc->requestUserInfo('sub'))->first();
         //$user = User::where('firstname', '=', $firstname)->where('email', '=', $email)->where('lastname', '=', $lastname)->where('active', '=', '1')->first();
     }
     if ($user) {
         // Add refresh token, if there is one
         if ($oidc->getRefreshToken() != '') {
             $refresh_data['uma_refresh_token'] = $oidc->getRefreshToken();
             DB::table('practiceinfo')->where('practice_id', '=', '1')->update($refresh_data);
             // Register scopes, if none are set yet
             $uma = DB::table('uma')->first();
             if (!$uma) {
                 $resource_set_array[] = array('name' => 'Patient', 'icon' => 'https://noshchartingsystem.com/i-patient.png', 'scopes' => array(URL::to('/') . '/fhir/Patient/1', URL::to('/') . '/fhir/Patient?identifier=1', URL::to('/') . '/fhir/Patient?_id=1', URL::to('/') . '/fhir/Medication', URL::to('/') . '/fhir/Practitioner'));
                 $resource_set_array[] = array('name' => 'Condition', 'icon' => 'https://noshchartingsystem.com/i-condition.png', 'scopes' => array(URL::to('/') . '/fhir/Condition/?subject:Patient=1'));
                 $resource_set_array[] = array('name' => 'Medication List', 'icon' => 'https://noshchartingsystem.com/i-pharmacy.png', 'scopes' => array(URL::to('/') . '/fhir/MedicationStatement/?subject:Patient=1'));
                 $resource_set_array[] = array('name' => 'Allergy', 'icon' => 'https://noshchartingsystem.com/i-allergy.png', 'scopes' => array(URL::to('/') . '/fhir/AllergyIntolerance/?subject:Patient=1'));
                 $resource_set_array[] = array('name' => 'Immunization', 'icon' => 'https://noshchartingsystem.com/i-immunization.png', 'scopes' => array(URL::to('/') . '/fhir/Immunization/?subject:Patient=1'));
                 $resource_set_array[] = array('name' => 'Encounter', 'icon' => 'https://noshchartingsystem.com/i-medical-records.png', 'scopes' => array(URL::to('/') . '/fhir/Encounter/?subject:Patient=1'));
                 $resource_set_array[] = array('name' => 'Family History', 'icon' => 'https://noshchartingsystem.com/i-family-practice.png', 'scopes' => array(URL::to('/') . '/fhir/FamilyHistory/?subject:Patient=1'));
                 $resource_set_array[] = array('name' => 'Binary Files', 'icon' => 'https://noshchartingsystem.com/i-file.png', 'scopes' => array(URL::to('/') . '/fhir/Binary/?subject:Patient=1'));
                 $resource_set_array[] = array('name' => 'Observation', 'icon' => 'https://noshchartingsystem.com/i-cardiology.png', 'scopes' => array(URL::to('/') . '/fhir/Observation/?subject:Patient=1'));
                 $oidc1 = new OpenIDConnectClient($open_id_url, $client_id, $client_secret);
                 $oidc1->refresh($refresh_data['uma_refresh_token'], true);
                 foreach ($resource_set_array as $resource_set_item) {
                     $response = $oidc1->resource_set($resource_set_item['name'], $resource_set_item['icon'], $resource_set_item['scopes']);
                     if (isset($response['resource_set_id'])) {
                         foreach ($resource_set_item['scopes'] as $scope_item) {
                             $response_data1 = array('resource_set_id' => $response['resource_set_id'], 'scope' => $scope_item, 'user_access_policy_uri' => $response['user_access_policy_uri']);
                             DB::table('uma')->insert($response_data1);
                             $this->audit('Add');
                         }
                     }
                 }
             }
         }
         Auth::login($user);
         $practice = Practiceinfo::find($user->practice_id);
         Session::put('user_id', $user->id);
         Session::put('group_id', $user->group_id);
         Session::put('practice_id', $user->practice_id);
         Session::put('version', $practice->version);
         Session::put('practice_active', $practice->active);
         Session::put('displayname', $user->displayname);
         Session::put('documents_dir', $practice->documents_dir);
         Session::put('rcopia', $practice->rcopia_extension);
         Session::put('mtm_extension', $practice->mtm_extension);
         Session::put('patient_centric', $practice->patient_centric);
         Session::put('uma_auth_access_token', $access_token);
         setcookie("login_attempts", 0, time() + 900, '/');
         return Redirect::intended('/');
     } else {
         $practice_npi = $oidc->requestUserInfo('practice_npi');
         $practice_id = false;
         if ($practice_npi != '') {
             $practice_npi_array = explode(',', $practice_npi);
             $practice_npi_array_null = array();
             foreach ($practice_npi_array as $practice_npi_item) {
                 $practice_query = DB::table('practiceinfo')->where('npi', '=', $practice_npi_item)->first();
                 if ($practice_query) {
                     $practice_id = $practice_query->practice_id;
                 } else {
                     $practice_npi_array_null[] = $practice_npi_item;
                 }
             }
         }
         if ($practice_id == false) {
             if (count($practice_npi_array_null) == 1) {
                 $url = 'http://docnpi.com/api/index.php?ident=' . $practice_npi_array_null[0] . '&is_ident=true&format=aha';
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $url);
                 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 15);
                 $data1 = curl_exec($ch);
                 curl_close($ch);
                 $html = new Htmldom($data1);
                 $practicename = '';
                 $address = '';
                 $street_address1 = '';
                 $city = '';
                 $state = '';
                 $zip = '';
                 if (isset($html)) {
                     $li = $html->find('li', 0);
                     if (isset($li)) {
                         $nomatch = $li->innertext;
                         if ($nomatch != ' no matching results ') {
                             $name_item = $li->find('span[class=org]', 0);
                             $practicename = $name_item->innertext;
                             $address_item = $li->find('span[class=address]', 0);
                             $address = $address_item->innertext;
                         }
                     }
                 }
                 if ($address != '') {
                     $address_array = explode(',', $address);
                     if (isset($address_array[0])) {
                         $street_address1 = trim($address_array[0]);
                     }
                     if (isset($address_array[1])) {
                         $zip = trim($address_array[1]);
                     }
                     if (isset($address_array[2])) {
                         $city = trim($address_array[2]);
                     }
                     if (isset($address_array[3])) {
                         $state = trim($address_array[3]);
                     }
                 }
                 $practice_data = array('npi' => $practice_npi_array_null[0], 'practice_name' => $practicename, 'street_address1' => $street_address1, 'city' => $city, 'state' => $state, 'zip' => $zip, 'documents_dir' => $practice->documents_dir, 'version' => $practice->version, 'active' => 'Y', 'fax_type' => '', 'vivacare' => '', 'patient_centric' => 'yp', 'smtp_user' => $practice->smtp_user, 'smtp_pass' => $practice->smtp_pass);
                 $practice_id = DB::table('practiceinfo')->insertGetId($practice_data);
                 $this->audit('Add');
             } else {
                 Session::put('practice_npi_array', implode(',', $practice_npi_array_null));
                 Session::put('firstname', $firstname);
                 Session::put('lastname', $lastname);
                 Session::put('username', $oidc->requestUserInfo('sub'));
                 Session::put('middle', $oidc->requestUserInfo('middle_name'));
                 Session::put('displayname', $oidc->requestUserInfo('name'));
                 Session::put('email', $email);
                 Session::put('npi', $npi);
                 Session::put('practice_choose', 'y');
                 Session::put('uid', $oidc->requestUserInfo('sub'));
                 Session::put('uma_auth_access_token', $access_token);
                 return Redirect::to('practice_choose');
             }
         }
         $data = array('username' => $oidc->requestUserInfo('sub'), 'firstname' => $firstname, 'middle' => $oidc->requestUserInfo('middle_name'), 'lastname' => $lastname, 'displayname' => $oidc->requestUserInfo('name'), 'email' => $email, 'group_id' => '2', 'active' => '1', 'practice_id' => $practice_id, 'secret_question' => 'Use HIEofOne to reset your password!', 'uid' => $oidc->requestUserInfo('sub'));
         $id = DB::table('users')->insertGetId($data);
         $this->audit('Add');
         $data1 = array('id' => $id, 'npi' => $npi, 'practice_id' => $practice_id);
         DB::table('providers')->insert($data1);
         $this->audit('Add');
         $user1 = User::where('id', '=', $id)->first();
         Auth::login($user1);
         $practice1 = Practiceinfo::find($user1->practice_id);
         Session::put('user_id', $user1->id);
         Session::put('group_id', $user1->group_id);
         Session::put('practice_id', $user1->practice_id);
         Session::put('version', $practice1->version);
         Session::put('practice_active', $practice1->active);
         Session::put('displayname', $user1->displayname);
         Session::put('documents_dir', $practice1->documents_dir);
         Session::put('rcopia', $practice1->rcopia_extension);
         Session::put('mtm_extension', $practice1->mtm_extension);
         Session::put('patient_centric', $practice1->patient_centric);
         Session::put('uma_auth_access_token', $access_token);
         setcookie("login_attempts", 0, time() + 900, '/');
         return Redirect::intended('/');
     }
 }
Ejemplo n.º 11
0
 public function uma_auth()
 {
     $open_id_url = str_replace('/nosh', '/uma-server-webapp/', URL::to('/'));
     $practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first();
     $client_id = $practice->uma_client_id;
     $client_secret = $practice->uma_client_secret;
     $url = route('uma_auth');
     $oidc = new OpenIDConnectClient($open_id_url, $client_id, $client_secret);
     $oidc->setRedirectURL($url);
     $oidc->authenticate(true, 'user');
     $firstname = $oidc->requestUserInfo('given_name');
     $lastname = $oidc->requestUserInfo('family_name');
     $email = $oidc->requestUserInfo('email');
     $npi = $oidc->requestUserInfo('npi');
     $access_token = $oidc->getAccessToken();
     if ($npi != '') {
         $provider = DB::table('providers')->where('npi', '=', $npi)->first();
         if ($provider) {
             $user = User::where('id', '=', $provider->id)->first();
         } else {
             $user = false;
         }
     } else {
         $user = User::where('uid', '=', $oidc->requestUserInfo('sub'))->first();
         //$user = User::where('firstname', '=', $firstname)->where('email', '=', $email)->where('lastname', '=', $lastname)->where('active', '=', '1')->first();
     }
     if ($user) {
         Auth::login($user);
         $practice = Practiceinfo::find($user->practice_id);
         Session::put('user_id', $user->id);
         Session::put('group_id', $user->group_id);
         Session::put('practice_id', $user->practice_id);
         Session::put('version', $practice->version);
         Session::put('practice_active', $practice->active);
         Session::put('displayname', $user->displayname);
         Session::put('documents_dir', $practice->documents_dir);
         Session::put('rcopia', $practice->rcopia_extension);
         Session::put('mtm_extension', $practice->mtm_extension);
         Session::put('patient_centric', $practice->patient_centric);
         Session::put('uma_auth_access_token', $access_token);
         setcookie("login_attempts", 0, time() + 900, '/');
         return Redirect::intended('/');
     } else {
         $practice_npi = $oidc->requestUserInfo('practice_npi');
         $practice_id = false;
         if ($practice_npi != '') {
             $practice_npi_array = explode(',', $practice_npi);
             $practice_npi_array_null = array();
             foreach ($practice_npi_array as $practice_npi_item) {
                 $practice_query = DB::table('practiceinfo')->where('npi', '=', $practice_npi_item)->first();
                 if ($practice_query) {
                     $practice_id = $practice_query->practice_id;
                 } else {
                     $practice_npi_array_null[] = $practice_npi_item;
                 }
             }
         }
         if ($practice_id == false) {
             if (count($practice_npi_array_null) == 1) {
                 $url = 'http://docnpi.com/api/index.php?ident=' . $practice_npi_array_null[0] . '&is_ident=true&format=aha';
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $url);
                 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 15);
                 $data1 = curl_exec($ch);
                 curl_close($ch);
                 $html = new Htmldom($data1);
                 $practicename = '';
                 $address = '';
                 $street_address1 = '';
                 $city = '';
                 $state = '';
                 $zip = '';
                 if (isset($html)) {
                     $li = $html->find('li', 0);
                     if (isset($li)) {
                         $nomatch = $li->innertext;
                         if ($nomatch != ' no matching results ') {
                             $name_item = $li->find('span[class=org]', 0);
                             $practicename = $name_item->innertext;
                             $address_item = $li->find('span[class=address]', 0);
                             $address = $address_item->innertext;
                         }
                     }
                 }
                 if ($address != '') {
                     $address_array = explode(',', $address);
                     if (isset($address_array[0])) {
                         $street_address1 = trim($address_array[0]);
                     }
                     if (isset($address_array[1])) {
                         $zip = trim($address_array[1]);
                     }
                     if (isset($address_array[2])) {
                         $city = trim($address_array[2]);
                     }
                     if (isset($address_array[3])) {
                         $state = trim($address_array[3]);
                     }
                 }
                 $practice_data = array('npi' => $practice_npi_array_null[0], 'practice_name' => $practicename, 'street_address1' => $street_address1, 'city' => $city, 'state' => $state, 'zip' => $zip, 'documents_dir' => $practice->documents_dir, 'version' => $practice->version, 'active' => 'Y', 'fax_type' => '', 'vivacare' => '', 'patient_centric' => 'yp', 'smtp_user' => $practice->smtp_user, 'smtp_pass' => $practice->smtp_pass);
                 $practice_id = DB::table('practiceinfo')->insertGetId($practice_data);
                 $this->audit('Add');
             } else {
                 Session::put('practice_npi_array', implode(',', $practice_npi_array_null));
                 Session::put('firstname', $firstname);
                 Session::put('lastname', $lastname);
                 Session::put('username', $oidc->requestUserInfo('sub'));
                 Session::put('middle', $oidc->requestUserInfo('middle_name'));
                 Session::put('displayname', $oidc->requestUserInfo('name'));
                 Session::put('email', $email);
                 Session::put('npi', $npi);
                 Session::put('practice_choose', 'y');
                 Session::put('uid', $oidc->requestUserInfo('sub'));
                 Session::put('uma_auth_access_token', $access_token);
                 return Redirect::to('practice_choose');
             }
         }
         $data = array('username' => $oidc->requestUserInfo('sub'), 'firstname' => $firstname, 'middle' => $oidc->requestUserInfo('middle_name'), 'lastname' => $lastname, 'displayname' => $oidc->requestUserInfo('name'), 'email' => $email, 'group_id' => '2', 'active' => '1', 'practice_id' => $practice_id, 'secret_question' => 'Use HIEofOne to reset your password!', 'uid' => $oidc->requestUserInfo('sub'));
         $id = DB::table('users')->insertGetId($data);
         $this->audit('Add');
         $data1 = array('id' => $id, 'npi' => $npi, 'practice_id' => $practice_id);
         DB::table('providers')->insert($data1);
         $this->audit('Add');
         $user1 = User::where('id', '=', $id)->first();
         Auth::login($user1);
         $practice1 = Practiceinfo::find($user1->practice_id);
         Session::put('user_id', $user1->id);
         Session::put('group_id', $user1->group_id);
         Session::put('practice_id', $user1->practice_id);
         Session::put('version', $practice1->version);
         Session::put('practice_active', $practice1->active);
         Session::put('displayname', $user1->displayname);
         Session::put('documents_dir', $practice1->documents_dir);
         Session::put('rcopia', $practice1->rcopia_extension);
         Session::put('mtm_extension', $practice1->mtm_extension);
         Session::put('patient_centric', $practice1->patient_centric);
         Session::put('uma_auth_access_token', $access_token);
         setcookie("login_attempts", 0, time() + 900, '/');
         return Redirect::intended('/');
     }
 }
Ejemplo n.º 12
0
 public static function update($user)
 {
     if (!$user->can_fetch()) {
         return [];
     }
     // Add the next fornight's lessons
     $keys = static::keys($user);
     echo "Got authentication keys.\n";
     $lessons = array();
     $date = Carbon::now();
     $periods = [[[8, 35], [8, 45]], [[8, 45], [9, 40]], [[9, 40], [10, 35]], [[10, 55], [11, 45]], [[11, 45], [12, 35]], [[13, 25], [13, 50]], [[13, 50], [14, 40]], [[14, 40], [15, 30]]];
     for ($d = 0; $d < 14; $d++) {
         if (!$date->isWeekend()) {
             echo "Adding: " . $date->toCookieString() . "\n";
             $date_str = $date->format('j/m/Y');
             $html = new \Htmldom();
             $html->load(self::keystone_post(self::TIMETABLE_URL, array('__VIEWSTATE' => $keys['__VIEWSTATE'], '__EVENTVALIDATION' => $keys['__EVENTVALIDATION'], 'ctl00$PlaceHolderMain$ctl00$_uiCurrentDaySel$_uiCurrentDaySelDate' => $date_str), $user));
             $lesson_uls = $html->find('ul[class=TimetableEntry]');
             $start_lesson_n = count($lessons);
             foreach ($lesson_uls as $index => $lesson) {
                 $times_raw = trim($lesson->find('li[class=TimetableEntryLesson]')[0]->innertext);
                 $subject_raw = trim($lesson->find('li[class=TimetableEntryClassName]')[0]->innertext);
                 $location_raw = trim($lesson->find('li[class=TimetableEntryLocation]')[0]->innertext);
                 preg_match_all('/(\\d+:\\d\\d [AP]M) - (\\d+:\\d\\d [AP]M)/', $times_raw, $time_matches);
                 $start = Carbon::createFromFormat('g:i A j/m/Y', $time_matches[1][0] . ' ' . $date_str);
                 $end = Carbon::createFromFormat('g:i A j/m/Y', $time_matches[2][0] . ' ' . $date_str);
                 preg_match_all('/Class: (?:\\d+|\\d+\\w+|\\w+) - (?:(.+)(?:\\s\\d+$|\\s\\w{3}$|\\s\\d+\\w)|(.+))/', $subject_raw, $subject_matches);
                 $subject = strlen($subject_matches[1][0]) == 0 ? $subject_matches[2][0] : $subject_matches[1][0];
                 if (preg_match("/\\d\\dPC/", $subject)) {
                     $subject = "Pastoral Care";
                 }
                 preg_match_all('/Location: (.+)/', $location_raw, $location_matches);
                 $location = $location_matches[1][0];
                 // is a double
                 if ($index != 0 && end($lessons) && end($lessons)['subject'] == $subject) {
                     $lessons[count($lessons) - 1]['end'] = $end;
                 } else {
                     $lessons[] = array('start' => $start, 'end' => $end, 'subject' => $subject, 'location' => $location);
                 }
             }
             $min_period = 0;
             $insert_frees = [];
             for ($index = $start_lesson_n; $index < count($lessons); $index++) {
                 $lesson = $lessons[$index];
                 $start_hour = $lesson['start']->hour;
                 $start_minute = $lesson['start']->minute;
                 $end_hour = $lesson['end']->hour;
                 $end_minute = $lesson['end']->minute;
                 $start_min = $min_period;
                 $found = false;
                 for ($i = $min_period; $i < count($periods); $i++) {
                     $period = $periods[$i];
                     if ($start_hour == $period[0][0] && $start_minute == $period[0][1]) {
                         $min_period = $i + 1;
                         $found = true;
                     } else {
                         if ($end_hour == $period[1][0] && $end_minute == $period[1][1]) {
                             $min_period = $i + 1;
                             $found = true;
                         } else {
                             if (!$found) {
                                 $min_period++;
                                 $end = $lesson['end']->copy();
                                 $end->hour = $period[1][0];
                                 $end->minute = $period[1][1];
                                 if (isset($insert_frees[$index])) {
                                     $insert_frees[$index]['end'] = $end;
                                 } else {
                                     $start = $lesson['start']->copy();
                                     $start->hour = $period[0][0];
                                     $start->minute = $period[0][1];
                                     $insert_frees[$index] = array('start' => $start, 'end' => $end, 'subject' => "Free", 'location' => "");
                                 }
                             } else {
                                 break;
                             }
                         }
                     }
                 }
             }
             $inserted = 0;
             foreach ($insert_frees as $index => $value) {
                 array_splice($lessons, $index + $inserted, 0, array($value));
                 $inserted++;
             }
         }
         $date->addDay();
     }
     // foreach ($lessons as $key => $value) {
     // 	var_dump($value['subject']);
     // 	var_dump($value['start']->toCookieString());
     // }
     echo "Purging old lessons.\n";
     $user->lessons()->delete();
     foreach ($lessons as $index => $lesson) {
         Lesson::updateOrCreate(array('start' => $lesson['start'], 'end' => $lesson['end'], 'subject' => $lesson['subject'], 'location' => $lesson['location'], 'user_id' => $user->user_id));
     }
     echo "Inserted new lessons.\n";
 }
Ejemplo n.º 13
0
 function str_get_html($str, $lowercase = true, $forceTagsClosed = true, $target_charset = 'UTF-8', $stripRN = true, $defaultBRText = "\r\n", $defaultSpanText = " ")
 {
     $dom = new Htmldom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
     if (empty($str) || strlen($str) > 600000) {
         $dom->clear();
         return false;
     }
     $dom->load($str, $lowercase, $stripRN);
     return $dom;
 }
Ejemplo n.º 14
0
 public function postNpiUpdate()
 {
     $track = __DIR__ . '/../../public/temp/track';
     $tracknote = __DIR__ . '/../../public/temp/tracknote';
     $trackcomplete = __DIR__ . '/../../public/temp/trackcomplete';
     ini_set('memory_limit', '96M');
     $html = new Htmldom("http://www.nucc.org/index.php?option=com_content&view=article&id=107&Itemid=132");
     if (isset($html)) {
         $e = $html->find('a[href*=csv]', 0);
         $link = $e->href;
         $wget = "wget http://www.nucc.org/" . $link . " --directory-prefix='" . __DIR__ . "/../../import/' --output-document='npi_taxonomy.csv'";
         $last_line = system($wget, $return_val);
         File::put($tracknote, 'Retrieved data from the NUCC website.');
         DB::table('npi')->truncate();
         $i = 0;
         if (($npi_handle = fopen(__DIR__ . '/../../import/npi_taxonomy.csv', "r")) !== FALSE) {
             while (($npi1 = fgetcsv($npi_handle, 0, ",", '"')) !== FALSE) {
                 if ($npi1[0] != '' && $npi1[0] != 'Code') {
                     $npi_data = array('code' => $npi1[0], 'type' => $npi1[1], 'classification' => $npi1[2], 'specialization' => $npi1[3]);
                     DB::table('npi')->insert($npi_data);
                     $i++;
                 }
                 File::put($track, $i);
             }
             fclose($npi_handle);
         }
         File::put($trackcomplete, 'true');
         echo 'NPI database updated!';
     } else {
         File::put($trackcomplete, 'true');
         echo 'Unable to contact NUCC website.  Please try again later.';
     }
 }
Ejemplo n.º 15
0
 public function postPrintVivacare($link)
 {
     set_time_limit(0);
     ini_set('memory_limit', '196M');
     $practice = Practiceinfo::find(Session::get('practice_id'));
     $html = new Htmldom("http://informationrx.com/" . $practice->vivacare . "/HealthTopic/" . $link);
     if (isset($html)) {
         $final_html = $this->page_intro('Patient Instructions', Session::get('practice_id'))->render();
         $title = $html->find('h1', 0);
         $final_html .= '<div style="width:100%">';
         $final_html .= '<h2 style="text-align: center;">';
         $final_html .= trim(str_replace("Print Page", "", $title->plaintext));
         $final_html .= '</h2>';
         $div = $html->find('[class=col-main]', 0);
         $final_html .= $div->outertext;
         $div1 = $html->find('[class=col-right]', 0);
         $final_html .= $div1->outertext;
         $div2 = $html->find('[id=nav-topic]', 0);
         $final_html .= '<h2>Related Topics</h2>';
         $final_html .= $div2->outertext;
         $final_html .= '</div></body></html>';
         $directory = $practice->documents_dir . Session::get('pid');
         $file_path = $directory . '/instructions_' . time() . '.pdf';
         $this->generate_pdf($final_html, $file_path);
         while (!file_exists($file_path)) {
             sleep(2);
         }
         $pages_data = array('documents_url' => $file_path, 'pid' => Session::get('pid'), 'documents_type' => 'Letters', 'documents_desc' => 'Instructions for ' . Session::get('ptname'), 'documents_from' => Session::get('displayname'), 'documents_viewed' => Session::get('displayname'), 'documents_date' => date("Y-m-d H:i:s", time()));
         $arr['message'] = "OK";
         $arr['id'] = DB::table('documents')->insertGetId($pages_data);
         $this->audit('Add');
     } else {
         $arr['message'] = "Unable to download instructions from Vivacare.  Try again later.";
     }
     echo json_encode($arr);
 }
Ejemplo n.º 16
0
 private function fectch($D0, $D1, $course_department, $is_special = false)
 {
     $days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
     $page = 1;
     $basicUrl = "http://selcrs.nsysu.edu.tw/menu1/dplycourse.asp?D0=" . $D0 . "&D1=" . $D1 . "&TYP=1";
     $flag = true;
     $need_course_dimensions_department = [7];
     $convert_course_dimensions = ['一' => 1, '二' => 2, '三' => 3, '四' => 4, '五' => 5, '六' => 6];
     while ($flag) {
         $url = $basicUrl . "&page=" . $page;
         $html = new \Htmldom($url);
         $trCollect = $html->find('tr');
         $totalTr = count($trCollect);
         for ($i = 3; $i < $totalTr - 2; ++$i) {
             $data = [];
             $tr = $trCollect[$i];
             @($course = preg_split("/\r\n/", $tr->children[7]->plaintext));
             @($data['course_nameCH'] = $course[0]);
             @($data['course_nameEN'] = $course[1]);
             @($data['course_grade'] = str_replace("</small>", "", $tr->children[5]->plaintext));
             @($data['unit'] = $tr->children[8]->plaintext);
             @($data['professor'] = $tr->children[15]->plaintext);
             @($data['place'] = $tr->children[16]->plaintext);
             @($data['course_department'] = $course_department);
             $time1 = array();
             $time2 = array();
             foreach ($days as $key => $value) {
                 @($time = $tr->children[17 + $key]->plaintext);
                 if ($time != "&nbsp") {
                     array_push($time1, $value);
                     array_push($time2, $time);
                 }
             }
             if (in_array($data['course_department'], $need_course_dimensions_department)) {
                 @($course_dimensions = $tr->children[3]->plaintext);
                 foreach ($convert_course_dimensions as $key => $value) {
                     if (mb_stripos($course_dimensions, $key, 0, 'UTF-8') !== FALSE) {
                         $data['course_dimensions'] = $value;
                         break;
                     }
                 }
             }
             if ($is_special && $data['course_department'] >= 18) {
                 $data['course_grade'] = 5;
             }
             if (array_search("", $data) !== false) {
                 continue;
             }
             $data['time1'] = implode(",", $time1);
             $data['time2'] = implode(",", $time2);
             $this->addCourse($data);
             //print_r($data);
         }
         ++$page;
         if (mb_stripos($trCollect[$totalTr - 2]->plaintext, "下一頁", 0, 'UTF-8') === FALSE) {
             $flag = false;
         }
     }
 }
Ejemplo n.º 17
0
 public static function update($user)
 {
     if (!$user->can_fetch()) {
         return [];
     }
     $keys = [];
     $matches = [];
     for ($i = 1; $i <= 4; $i++) {
         // if ($i == 2){
         // echo self::keystone_post(self::SPORTSZONE_URL, $keys, $user);
         // exit;}
         var_dump($i);
         $html = new \Htmldom();
         $html->load(self::keystone_post(self::SPORTSZONE_URL, $keys, $user));
         $keys = static::keys($html);
         $id_matches = [];
         preg_match_all("/p_ID=(.+)}'\\);/", $html->find('img[alt="View Earlier Match"]')[0]->parent()->href, $id_matches);
         $id = $id_matches[1][0];
         $team_name = $html->find('.ms-vb')[0]->find('b')[0]->innertext;
         $opponent_matches = [];
         preg_match_all("/<\\/a>(.+), playing/", $html->find('td[colspan="99"]')[0]->innertext, $opponent_matches);
         if (count($opponent_matches) > 0 && count($opponent_matches[1]) > 0) {
             $opponent_name = $opponent_matches[1][0];
         } else {
             $opponent_name = '';
         }
         $date_matches = [];
         preg_match_all("/<br>Week \\d+, Term \\d, (.+?)(?: - .+)?\$/", $html->find('.ms-vb')[0]->innertext, $date_matches);
         if (count($date_matches) > 0 && count($date_matches[1]) > 0) {
             $date = Carbon::createFromFormat('d/m/Y g:i A', $date_matches[1][0]);
         } else {
             continue;
         }
         $venue_matches = [];
         preg_match_all("/Venue Map -\\s+(.+)/", $html->find('table[cellpadding="2"]')[0]->find('th')[2]->innertext, $venue_matches);
         $venue = $venue_matches[1][0];
         $location_matches = [];
         preg_match_all("/new google\\.maps\\.LatLng\\((-?\\d+.\\d+,-?\\d+.\\d+)\\);/", $html->find('table[cellpadding="2"]')[0]->find('script')[1]->innertext, $location_matches);
         $location = $location_matches[1][0];
         $pre_comments = static::heading_body($html->find('table[cellpadding="2"]')[0], 'Pre-Game Comments');
         $post_comments = static::heading_body($html->find('table[cellpadding="2"]')[1], 'Game Comments');
         $team_list = Person::from_names(array_filter(explode('; ', static::heading_body($html->find('table[cellpadding="2"]')[0], 'Team List'))));
         $staff_list = Person::from_names(array_filter(explode('; ', static::heading_body($html->find('table[cellpadding="2"]')[1], 'Team Staff'))));
         $result = str_replace('<b>Result:</b>&nbsp;', '', $html->find('table[cellpadding="2"]')[1]->find('td')[0]->innertext);
         $table = $html->find('table[width="350px"]');
         $score_self = $table ? $table[0]->find('td')[0]->innertext : '';
         $score_opponent = $table ? $table[0]->find('td')[2]->innertext : '';
         if ($match = Match::find($id)) {
             $match->match_id = $id;
             $match->team_name = $team_name;
             $match->opponent_name = $opponent_name;
             $match->venue = $venue;
             $match->location = $location;
             $match->result = $result;
             $match->date = $date;
             $match->score_self = $score_self;
             $match->score_opponent = $score_opponent;
             $match->pre_comments = $pre_comments;
             $match->post_comments = $post_comments;
             $match->save();
         } else {
             $match = Match::updateOrCreate(array('match_id' => $id, 'team_name' => $team_name, 'opponent_name' => $opponent_name, 'venue' => $venue, 'location' => $location, 'result' => $result, 'date' => $date, 'score_self' => $score_self, 'score_opponent' => $score_opponent, 'pre_comments' => $pre_comments, 'post_comments' => $post_comments));
         }
         $attach = [$user->user_id => 0];
         foreach ($team_list as $index => $person) {
             $attach[$person->person_id] = 1;
         }
         foreach ($staff_list as $index => $person) {
             if (!isset($attach[$person->person_id])) {
                 $attach[$person->person_id] = 2;
             } else {
                 $attach[$person->person_id] += 2;
             }
         }
         foreach ($attach as $user_id => $value) {
             if (!$match->members->contains($user_id)) {
                 $match->members()->attach($user_id, ['is_team' => ($value & 1) == 1, 'is_staff' => ($value & 2) == 2]);
             } else {
                 $match->members()->updateExistingPivot($user_id, ['is_team' => ($value & 1) == 1, 'is_staff' => ($value & 2) == 2]);
             }
         }
         $matches[] = $match;
     }
 }
 public function postVivacareData()
 {
     set_time_limit(0);
     ini_set('memory_limit', '196M');
     $practice = Practiceinfo::find(Session::get('practice_id'));
     $data['response'] = "false";
     if ($practice->vivacare != "") {
         $html = new Htmldom("http://informationrx.com/" . $practice->vivacare);
         if (isset($html)) {
             $div = $html->find('[id=nav-topic-dropdown]', 0);
             $div1 = $html->find('[id=formselectA]', 0);
             if (isset($div)) {
                 $data['response'] = "true";
                 foreach ($div->find('select') as $select) {
                     $category = $select->id;
                     foreach ($select->find('option') as $option) {
                         $text = $option->innertext;
                         $link = $option->value;
                         $data['message'][] = array('label' => $text, 'value' => $text, 'link' => $link, 'category' => $category);
                     }
                 }
             }
         }
     }
     echo json_encode($data);
 }
Ejemplo n.º 19
0
function parseSimpleContentData($url)
{
    $data = @simplexml_load_file($url, "SimpleXMLElement", LIBXML_NOCDATA);
    $json = json_encode($data);
    $array = json_decode($json, TRUE);
    $output = '';
    $newarray = array_pluck($array, 'item');
    $html = new \Htmldom();
    $html->load($newarray[1][0]['description']);
    echo $newarray[1][0]['description'];
    #$newarray[1][0]['description'];
    dump($newarray);
    foreach ($html->find('font') as $font) {
        foreach ($font->find('font') as $k => $f) {
            if ($k == 2) {
                echo $f->plaintext . '<br><br>';
            }
        }
    }
    #dump($descriptions[0]->plaintext);
}