Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once( '../../helpers/vars.php' );
- require_once( '../../helpers/dom_parser.php' );
- require_once( '../../helpers/formaters_text.php' );
- //require_once( './auto_scrap_vars.php' );
- class california_crawler {
- private $url;
- private $dbRow;
- private $html;
- private $dom;
- public static $table = '__import_ca_bar';
- public static $ID = 'UID';
- public static $URL = 'SourceURL';
- public static $updatedAt = 'UpdatedAt';
- public static $barNumber = 'idNumber';
- public static $name = 'Name';
- public static $firstName = 'firstName';
- public static $middleName = 'middleName';
- public static $lastName = 'lastName';
- public static $suffix = 'Suffix';
- public static $memberStatus = 'member_status';
- public static $hasactive = 'HasActiveLicense';
- public static $address = 'Address';
- public static $firm = 'Firm';
- public static $school = 'lawSchool';
- public static $email = 'Email';
- public static $addressLine2 = 'Address2';
- public static $city = 'City';
- public static $state = 'State';
- public static $zip = 'Zip';
- public static $lat = 'Lat';
- public static $long = 'Lng';
- public static $phone = 'Phone';
- public static $disciplinaryHistory = 'DisciplinaryHistoryB';
- public static $dateadmitted = 'DateAdmitted';
- public static $cDateAdmitted = 'cDateAdmitted';
- public static $boardCertified = 'CertifiedLegalSpecialty';
- public static $boardCodes = 'Board_Certified_Codes';
- // public static $sections = 'Sections';
- public static $isJudge = 'is_a_judge';
- public $data = array( );
- private $isDeceased = null;
- private $isEligible = null;
- public function __construct( $url, $dbRow ) {
- $this->url = $url;
- $this->dbRow = $dbRow;
- }
- public static function get_select_string( ) {
- $select = array(
- self::$ID,
- self::$URL,
- self::$name,
- self::$firstName,
- self::$middleName,
- self::$lastName,
- self::$suffix,
- self::$memberStatus,
- self::$hasactive,
- self::$phone,
- self::$address,
- self::$firm,
- self::$school,
- self::$email,
- self::$addressLine2,
- self::$city,
- self::$state,
- self::$zip,
- self::$long,
- self::$lat,
- self::$dateadmitted,
- self::$boardCertified,
- self::$boardCodes,
- // self::$sections,
- self::$barNumber
- );
- return '`' . implode( '`,`', $select ) . '`';
- }
- public function get_data( ) {
- if ( !empty( $this->data ) ) {
- return $this->data;
- }
- $this->crawl_page();
- $this->data[ self::$memberStatus ] = $this->get_member_status();
- if ( $this->is_deceased() || !$this->is_eligible() ) {
- return $this->data;
- }
- $LL = $this->get_address2();
- $this->data[ self::$name ] = $this->get_full_name_string();
- $this->data[ self::$firstName ] = $this->get_first_name();
- $this->data[ self::$middleName ] = $this->get_middle_name();
- $this->data[ self::$lastName ] = $this->get_last_name();
- $this->data[ self::$suffix ] = $this->get_suffix_name();
- $this->data[ self::$address ] = $LL[ 'Address' ];
- $this->data[ self::$firm ] = $this->get_firm_name();
- $this->data[ self::$school ] = $this->get_law_school();
- $this->data[ self::$email ] = $this->get_email();
- $this->data[ self::$memberStatus ] = $this->get_member_status();
- $this->data[ self::$hasactive ] = $this->get_has_active();
- $this->data[ self::$city ] = $LL[ 'City' ];
- $this->data[ self::$addressLine2 ] = $LL[ 'Subpremise' ];
- $this->data[ self::$state ] = $LL[ 'State' ];
- $this->data[ self::$zip ] = $LL[ 'Zip' ];
- $this->data[ self::$phone ] = $this->get_phone();
- $this->data[ self::$disciplinaryHistory ] = $this->get_disciplinary_history() ? 1 : 0;
- $this->data[ self::$dateadmitted ] = $this->get_date_admitted();
- $this->data[ self::$cDateAdmitted ] = date( 'c', $this->data[ self::$dateadmitted ] );
- // $this->data[self::$sections] = $this->get_sections();
- $this->data[ self::$boardCertified ] = $this->get_board_certified();
- $this->data[ self::$boardCodes ] = $this->get_board_codes();
- //Don't know for sure if address changes, so always update lat and long
- $this->data[ self::$long ] = $LL[ 'lng' ];
- $this->data[ self::$lat ] = $LL[ 'lat' ];
- // die(print_r($this->data));
- return $this->data;
- }
- public function get_data_diff( ) {
- $response = array( );
- // if($this->is_deceased() && $this->dbRow[self::$memberStatus] !== 'Deceased') {
- // $response[self::$memberStatus] = $this->get_member_status();
- // return $response;
- // }
- // if(!$this->is_eligible() && $this->dbRow[self::$memberStatus] != 'Inactive') {
- // $response[self::$memberStatus] = $this->get_member_status();
- // return $response;
- // }
- // die(print_r($this->dbRow));
- foreach ( $this->dbRow as $column => $value ) {
- if ( isset( $this->data[ $column ] ) && $this->data[ $column ] !== $this->dbRow[ $column ] ) {
- // echo $response[$column] . ' : ' . $this->data[$column];
- $response[ $column ] = $this->data[ $column ];
- } else if ( array_key_exists( $column, $this->data ) && $this->data[ $column ] === null && $this->dbRow[ $column ] !== null ) {
- echo $column . '<br>';
- //because isset() will pretend variables that are set to null are unset
- $response[ $column ] = null;
- }
- }
- return $response;
- }
- public function is_deceased( ) {
- if ( isset( $this->isDeceased ) ) {
- return $this->isDeceased;
- }
- if ( $this->is_page_empty() ) {
- if ( strstr( $this->html, 'This licensee is deceased.' ) !== false ) { //They're def dead
- $this->isDeceased = true;
- return $this->isDeceased;
- } else if ( $this->confirm_status_by_search('Deceased') ) {
- $this->isDeceased = true;
- return $this->isDeceased;
- } else if ( $this->confirm_status_by_search('Judge') ) {
- echo $this->url;
- $sqlu = "UPDATE `__import_ca_bar` SET `member_status` = 'Judge', `UpdatedAt` = NOW() WHERE `UID` = " . d_iwt( $this->dbRow[ 'UID' ] );
- db_query_( $sqlu );
- meta_refresh_soft( 5 );
- die( 'Judge was found! ' . $sqlu );
- } else {
- echo $this->url;
- $sqlu = "UPDATE `__import_ca_bar` SET `member_status` = 'Unknown?', `UpdatedAt` = NOW() WHERE `UID` = " . d_iwt( $this->dbRow[ 'UID' ] );
- db_query_( $sqlu );
- meta_refresh_soft( 5 );
- die( 'Page was empty, but status not confirmed! ' . $sqlu );
- }
- }
- $this->isDeceased = false;
- return $this->isDeceased;
- }
- private function confirm_judge_by_search( ) {
- // $paragraphs = $this->dom->find('p');
- // foreach($paragraphs as $paragraph) {
- // if(isset($paragraph->plaintext)) {
- // echo $paragraph->plaintext."<br>";
- // $text = str_replace(array("\n", "\r"), '', $paragraph->plaintext);
- // $text = preg_replace('/\s\s+/', ' ', $text);
- // if(strstr($text, 'This person is currently serving as a Judge of a court') !== false) {
- // echo strstr('hello world', 'world');
- // }
- // // echo strstr($this->dom->plaintext, 'This person is currently serving as a Judge')."<br>";
- // // $search = preg_match('/.*(Th/is person is currently serving as a Judge).*/', $this->dom->plaintext, $matches);
- // // if(isset($matches[0])) {
- // // die ($matches[0]);
- // // return true;
- // // }
- // }
- // }
- // die();
- // return false;
- }
- private function is_page_empty( ) {
- if ( empty( $this->get_full_name_string() ) || !$this->get_full_name_string() ) {
- return true;
- }
- return false;
- }
- private function confirm_status_by_search($searchFor) {
- global $curl_cached_response_code;
- $name = urlencode( $this->dbRow[ self::$name ] );
- $url = 'http://members.calbar.ca.gov/fal/LicenseeSearch/QuickSearch?ResultType=0&SearchType=0&SoundsLike=False&FreeText=' . $name;
- $html = curl_cached_scrape( $url );
- if ( $curl_cached_response_code != '200' ) {
- $this->crawl_failure();
- }
- $dom = str_get_html( $html );
- $rows = $dom->find( 'table#tblAttorney tbody', 0 )->find( 'tr' );
- if ( is_array( $rows ) ) {
- foreach ( $rows as $row ) {
- if ( method_exists( $row, 'find' ) ) {
- $barNumber = $row->find( 'td', 2 );
- $status = $row->find( 'td', 1 );
- }
- if ( isset( $barNumber->plaintext ) && isset( $status->plaintext ) ) {
- $barNumber = trim( $barNumber->plaintext );
- $status = trim( $status->plaintext );
- if ( $barNumber == $this->dbRow[ self::$barNumber ] && $status == $searchFor ) {
- return true;
- }
- }
- }
- }
- return false;
- }
- public function is_eligible( ) {
- if ( $this->isEligible !== null ) {
- return $this->isEligible;
- }
- $tr = $this->dom->find( 'table tr', 1 );
- if ( method_exists( $tr, 'find' ) ) {
- if ( method_exists( $tr, 'find' ) ) {
- $td = $tr->find( 'td', 1 );
- if ( isset( $td->plaintext ) ) {
- $activeText = trim( $td->plaintext );
- $this->isEligible = $activeText === 'Active';
- return $this->isEligible;
- }
- }
- }
- $this->isEligible = false;
- return $this->isEligible;
- }
- private function get_member_status( ) {
- if ( $this->is_deceased() ) {
- return 'Deceased';
- }
- return $this->is_eligible() ? 'Active' : 'Inactive';
- }
- private function get_has_active( ) {
- $theirstatus = $this->is_eligible() ? 'Active' : 'Inactive';
- if ( $theirstatus == 'Active' ) {
- return true;
- } else {
- return false;
- }
- }
- // private function get_address_old() {
- // $response = [];
- // $paragraphs = $this->dom->find('p');
- // foreach($paragraphs as $paragraph) {
- // if(isset($paragraph->plaintext)) {
- // if(strstr($paragraph->plaintext, 'Address: ') !== false) {
- // $rawaddy = str_replace('Address: ', '', $paragraph->plaintext);
- // }
- // }
- // }
- // return null;
- // }
- private function get_firm_name( ) {
- $response = array( );
- $paragraphs = $this->dom->find( 'p' );
- foreach ( $paragraphs as $paragraph ) {
- if ( isset( $paragraph->plaintext ) ) {
- if ( strstr( $paragraph->plaintext, 'Address: ' ) !== false ) {
- $addy = str_replace( 'Address: ', '', $paragraph->plaintext );
- $aa = explode( ",", $addy );
- $firm = array( );
- $aaaa = array( );
- $found = false;
- foreach ( $aa as $word ) {
- $word = trim( $word );
- if ( $found === false ) {
- if ( !is_numeric( substr( $word, 0, 1 ) ) && !find_po_box( $word ) ) {
- $firm[ ] = $word;
- } else {
- $found = true;
- $aaaa[ ] = $word;
- }
- } else {
- $aaaa[ ] = $word;
- }
- }
- $firmname = implode( ", ", $firm );
- if ( isset( $firm ) ) {
- return $firmname;
- } else {
- return null;
- }
- }
- }
- }
- return null;
- }
- private function get_address2( ) {
- $response = array( );
- $paragraphs = $this->dom->find( 'p' );
- foreach ( $paragraphs as $paragraph ) {
- if ( isset( $paragraph->plaintext ) ) {
- if ( strstr( $paragraph->plaintext, 'Address: ' ) !== false ) {
- $addy = str_replace( 'Address: ', '', $paragraph->plaintext );
- $aa = explode( ",", $addy );
- $firm = array( );
- $aaaa = array( );
- $found = false;
- foreach ( $aa as $word ) {
- $word = trim( $word );
- if ( $found === false ) {
- if ( !is_numeric( substr( $word, 0, 1 ) ) && !find_po_box( $word ) ) {
- $firm[ ] = $word;
- } else {
- $found = true;
- $aaaa[ ] = $word;
- }
- } else {
- $aaaa[ ] = $word;
- }
- }
- $addressa = implode( " ", $aaaa );
- $LL = geocoderA::getLocation_fullc( $addy );
- if ( find_po_box( $addy ) ) {
- $addya = explode( ",", $addy );
- if ( find_po_box( $addya[ 0 ] ) ) {
- $addyF = trim( $addya[ 0 ] );
- }
- }
- return $LL;
- }
- }
- }
- return null;
- }
- private function get_email( ) {
- $response = array( );
- $em = -1;
- for ( $ii = 0; $ii <= 20; $ii++ ) {
- if ( strstr( $this->dom, '#e' . $ii . '{display:inline;}' ) ) {
- $em = $ii;
- $emid = "e" . $em;
- //return $emid;
- }
- }
- $findemail = "span[id=" . $emid . "]";
- $rets = $this->dom->find( $findemail );
- foreach ( $rets as $ret ) {
- $rdd[ ] = trim( $ret->plaintext );
- }
- if ( isset( $rdd ) ) {
- $emspaced = trim( $rdd[ 0 ] );
- $foundemail = str_replace( ' ', '', $emspaced );
- $foundemail = str_replace( '.', '.', $foundemail );
- $foundemail = str_replace( '@', '@', $foundemail );
- if ( $foundemail == 'Not Available' ) {
- return null;
- }
- if ( filter_var( $foundemail, FILTER_VALIDATE_EMAIL ) ) {
- return $foundemail;
- } else {
- var_dump( filter_var( $foundemail, FILTER_VALIDATE_EMAIL ) );
- }
- } else {
- return null;
- }
- }
- private function get_law_school( ) {
- $response = array( );
- $paragraphs = $this->dom->find( 'p' );
- foreach ( $paragraphs as $paragraph ) {
- if ( isset( $paragraph->plaintext ) ) {
- if ( strstr( $paragraph->plaintext, 'Law School: ' ) !== false ) {
- $lawschool = str_replace( 'Law School: ', '', $paragraph->plaintext );
- return $lawschool;
- }
- }
- }
- return null;
- }
- private function get_full_name_string( ) {
- $response = array( );
- $name = $this->dom->find( 'h3 b', 1 );
- if ( isset( $name->plaintext ) ) {
- $name = $name->plaintext;
- } else {
- return false;
- }
- preg_match( '/^.*(\s#.*)$/', $name, $matches );
- if ( isset( $matches[ 1 ] ) ) {
- $name = str_replace( $matches[ 1 ], '', $name );
- } else {
- die( 'No bar number!' );
- }
- $name = preg_replace( '/\s\s+/', ' ', $name );
- return $name;
- }
- private function get_full_name_array( ) {
- $response = array( );
- $name = $this->get_full_name_string();
- $name = nix_nicknames( $name );
- $name = fix_names( $name );
- if ( isset( $name[ 0 ] ) && strtolower( $name[ 0 ] ) == 'judge' ) {
- die( 'Name prefix was found!' );
- unset( $name[ 0 ] );
- $name = array_values( $name );
- }
- // if(isset($name[0]) && strtolower($name[0]) == 'justice') {
- // unset($name[0]);
- // $name = array_values($name);
- // }
- if ( lmatch( $this->data[ self::$name ], 'Chief Justice' ) ) {
- die( 'Name prefix was found!' );
- // foreach($name as $index => $part) {
- // if($part == 'Chief Justice') {
- // unset($name[$index]);
- // }
- // if($part == 'Chief' && isset($name[$index+1]) && $name[$index+1] == 'Justice') {
- // unset($name[$index]);
- // unset($name[$index+1]);
- // }
- // }
- // $name = array_values($name);
- }
- if ( isset( $name[ 'f' ] ) ) {
- //First middle and last names
- $response[ 'first' ] = ucfirst( strtolower( $name[ 'f' ] ) );
- if ( isset( $name[ 'm' ] ) ) {
- $response[ 'middle' ] = ucfirst( strtolower( $name[ 'm' ] ) );
- } else {
- $response[ 'middle' ] = null;
- }
- $response[ 'last' ] = ucfirst( strtolower( $name[ 'l' ] ) );
- } else if ( !isset( $name[ 1 ] ) ) {
- //Only 1 string returned
- $nameb = explode( " ", $this->dbRow[ self::$name ] );
- if ( isset( $nameb[ 0 ] ) && isset( $nameb[ 1 ] ) ) {
- $response[ 'first' ] = ucfirst( strtolower( $nameb[ 0 ] ) );
- $response[ 'last' ] = ucfirst( strtolower( $nameb[ 1 ] ) );
- } else {
- die( "One Name??" );
- }
- } else if ( isset( $name[ 4 ] ) && ( $name[ 2 ] == "De" ) && ( $name[ 3 ] == "La" ) ) {
- //De La Name
- $response[ 'first' ] = ucfirst( strtolower( $name[ 0 ] ) );
- $response[ 'middle' ] = ucfirst( strtolower( $name[ 1 ] ) );
- $response[ 'last' ] = "De La " . ucfirst( strtolower( $name[ 4 ] ) );
- } else if ( isset( $name[ 4 ] ) && ( $name[ 3 ] == "De" ) ) {
- //De Name
- $response[ 'first' ] = ucfirst( strtolower( $name[ 0 ] ) );
- $response[ 'middle' ] = ucfirst( strtolower( $name[ 1 ] ) ) . " " . ucfirst( strtolower( $name[ 2 ] ) );
- $response[ 'last' ] = "De " . ucfirst( strtolower( $name[ 4 ] ) );
- } else if ( isset( $name[ 4 ] ) ) {
- //
- $response[ 'first' ] = ucfirst( strtolower( $name[ 0 ] ) );
- $response[ 'middle' ] = ucfirst( strtolower( $name[ 1 ] ) ) . " " . ucfirst( strtolower( $name[ 2 ] ) ) . " " . ucfirst( strtolower( $name[ 2 ] ) );
- $response[ 'last' ] = ucfirst( strtolower( $name[ 4 ] ) );
- } else if ( isset( $name[ 3 ] ) ) {
- //First middle and last names and extra
- $response[ 'first' ] = ucfirst( strtolower( $name[ 0 ] ) );
- $response[ 'middle' ] = ucfirst( strtolower( $name[ 1 ] ) ) . " " . ucfirst( strtolower( $name[ 2 ] ) );
- $response[ 'last' ] = ucfirst( strtolower( $name[ 3 ] ) );
- } else if ( isset( $name[ 2 ] ) ) {
- $response[ 'first' ] = ucfirst( strtolower( $name[ 0 ] ) );
- $response[ 'middle' ] = ucfirst( strtolower( $name[ 1 ] ) );
- $response[ 'last' ] = ucfirst( strtolower( $name[ 2 ] ) );
- } else if ( isset( $name[ 1 ] ) ) {
- $response[ 'first' ] = ucfirst( strtolower( $name[ 0 ] ) );
- $response[ 'middle' ] = '';
- $response[ 'last' ] = ucfirst( strtolower( $name[ 1 ] ) );
- } else if ( isset( $name[ 0 ] ) ) {
- $response[ 'first' ] = ucfirst( strtolower( $name[ 0 ] ) );
- $response[ 'middle' ] = '';
- $response[ 'last' ] = '';
- } else {
- die( 'no name!' );
- print_r( $response );
- }
- return $response;
- }
- private function get_first_name( ) {
- $name = $this->get_full_name_array();
- return $name[ 'first' ];
- }
- private function get_middle_name( ) {
- $name = $this->get_full_name_array();
- return $name[ 'middle' ];
- }
- private function get_last_name( ) {
- $name = $this->get_full_name_array();
- return $name[ 'last' ];
- }
- private function get_suffix_name( ) {
- $name = $this->get_full_name_string();
- $suffix = name_suffix( $name );
- if ( !empty( $suffix ) ) {
- return $suffix;
- }
- return null;
- }
- private function get_phone( ) {
- $response = array( );
- $paragraphs = $this->dom->find( 'p' );
- foreach ( $paragraphs as $paragraph ) {
- if ( isset( $paragraph->plaintext ) ) {
- if ( strstr( $paragraph->plaintext, 'Phone Number:' ) !== false ) {
- $phone = str_replace( 'Phone Number:', '', $paragraph->plaintext );
- return $phone;
- }
- }
- }
- return null;
- }
- // private function get_disciplinary_history() {
- // $table = $this->dom->find('div[class=margin-bottom]', 0);
- // if(method_exists($table, 'find')) {
- // foreach ($table->find('tr') as $row) {
- // //view the discipline td, not admin action
- // $disciplinary = $row->find('td', 2);
- // if(isset($disciplinary->plaintext) && !empty(trim($disciplinary->plaintext))){
- // if(strstr(trim($disciplinary->plaintext), 'Suspended') !== false) {
- // return true;
- // }
- // }
- // }
- // }
- // return false;
- // }
- private function get_disciplinary_history( ) {
- foreach ( $this->dom->find( 'div[class=margin-bottom]' ) as $table )
- $tablehtmlraw = $table->outertext;
- $tablehtml = str_get_html( $tablehtmlraw );
- $th1 = $text_description = str_replace( ' ', '', $tablehtml );
- $th2 = $text_description = str_replace( ' ', '', $tablehtml );
- $tableclean = str_get_html( $th2 );
- $tds = $tableclean->find( 'td' );
- foreach ( $tds as $td ) {
- $tdata[ ] = trim( $td->plaintext );
- }
- //create array of just the 3rd td which would be the discipline column. also exluding 1st instance whic his the label.
- $count = count( $tdata );
- for ( $i = 6; $i < $count; $i += 4 ) {
- $tddh[ ] = $tdata[ $i ];
- }
- if ( !array_filter( $tddh ) ) {
- return false;
- } else {
- return true;
- }
- }
- private function get_date_admitted( ) {
- foreach ( $this->dom->find( 'div[class=margin-bottom]' ) as $table )
- $tablehtmlraw = $table->outertext;
- $tablehtml = str_get_html( $tablehtmlraw );
- $th1 = $text_description = str_replace( ' ', '', $tablehtml );
- $th2 = $text_description = str_replace( ' ', '', $tablehtml );
- $tableclean = str_get_html( $th2 );
- $tds = $tableclean->find( 'td' );
- foreach ( $tds as $td ) {
- $tdata[ ] = trim( $td->plaintext );
- }
- //get second to last value which would be admitted date
- end( $tdata );
- $datea = prev( $tdata );
- return strtotime( $datea );
- }
- private function get_board_certified( ) {
- $table = $this->dom->find( 'table', 1 );
- if ( method_exists( $table, 'find' ) ) {
- if ( isset( $table->plaintext ) ) {
- $text = trim( $table->plaintext );
- if ( strstr( $text, 'Certified Legal Specialty' ) !== false ) {
- $row = $table->find( 'tr', 0 );
- if ( method_exists( $row, 'find' ) ) {
- $td = $row->find( 'td', 1 );
- if ( isset( $td->innertext ) ) {
- $certificates = explode( '<br />', $td->innertext );
- foreach ( $certificates as $index => $certificate ) {
- $certificates[ $index ] = trim( $certificate );
- if ( empty( $certificates[ $index ] ) ) {
- unset( $certificates[ $index ] );
- }
- }
- $certificates = implode( '|', $certificates );
- $certificates = str_replace( '(State Bar of California)', '', $certificates );
- return $certificates;
- }
- }
- }
- }
- // foreach ($table->find('tr') as $row) {
- // $disciplinary = $row->find('td', 3);
- // if(isset($disciplinary->plaintext) && !empty(trim($disciplinary->plaintext))){
- // if(strstr(trim($disciplinary->plaintext), 'Suspended') !== false) {
- // return true;
- // }
- // }
- // }
- }
- return null;
- }
- private function get_board_codes( ) {
- $rawcerts = $this->get_board_certified();
- $raw = $rawcerts;
- $raw = trim( $raw );
- $rawa = explode( "|", $raw );
- $certs = array( );
- foreach ( $rawa as $cert ) {
- $cert = trim( $cert );
- $key = sha1( $cert );
- if ( !isset( $known[ $key ] ) ) {
- $known[ $key ] = $cert;
- }
- $cert = strreplace( ' ', ' ', $cert );
- if ( 0 ) {
- //keep it alinged....
- } else if ( ( $cert == 'Admiralty and Maritime Law (State Bar of California)' ) || ( $cert == 'Admiralty and Maritime Law' ) ) {
- $certs[ ] = 'cbls-adma';
- } else if ( ( $cert == 'Appellate Law (State Bar of California)' ) || ( $cert == 'Appellate Law' ) ) {
- $certs[ ] = 'cbls-appl';
- } else if ( ( $cert == 'Bankruptcy Law (State Bar of California)' ) || ( $cert == 'Bankruptcy Law' ) ) {
- $certs[ ] = 'cbls-bank';
- } else if ( ( $cert == 'Business Bankruptcy Law (American Bd of Certification)' ) || ( $cert == 'Business Bankruptcy Law (American Bd of Certification)' ) ) {
- $certs[ ] = 'abc-bb';
- } else if ( $cert == 'Civil Trial Advocacy (Natl Board of Trial Advocacy)' ) {
- $certs[ ] = 'nbta-cpp';
- } else if ( $cert == 'Consumer Bankruptcy Law (American Bd of Certification)' ) {
- $certs[ ] = 'abc-cb';
- } else if ( $cert == "Creditor's Rights Law (American Bd of Certification)" ) {
- $certs[ ] = 'abc-cr';
- } else if ( ( $cert == 'Criminal Law (State Bar of California)' ) || ( $cert == 'Criminal Law' ) ) {
- $certs[ ] = 'cbls-crim';
- } else if ( $cert == 'Criminal Trial Advocacy (Natl Board of Trial Advocacy)' ) {
- $certs[ ] = 'nbta-crim';
- } else if ( $cert == 'Elder Law (National Elder Law Foundation)' ) {
- $certs[ ] = 'nelf-el';
- } else if ( ( $cert == 'Estate Planning, Trust & Probate Law (State Bar of California)' ) || ( $cert == 'Estate Planning, Trust & Probate Law' ) ) {
- $certs[ ] = 'cbls-wtep';
- } else if ( ( $cert == 'Family Law (State Bar of California)' ) || ( $cert == 'Family Law' ) ) {
- $certs[ ] = 'cbls-fmly';
- } else if ( $cert == 'Family Law Trial Advocacy (Natl Board of Trial Advocacy)' ) {
- $certs[ ] = 'nbta-fam';
- } else if ( ( $cert == 'Franchise & Distribution Law (State Bar of California)' ) || ( $cert == 'Franchise & Distribution Law' ) ) {
- $certs[ ] = 'cbls-fran';
- } else if ( ( $cert == 'Immigration & Nationality Law (State Bar of California)' ) || ( $cert == 'Immigration & Nationality Law' ) ) {
- $certs[ ] = 'cbls-immi';
- } else if ( $cert == 'Juvenile Law (Child Welfare) (Natl Assn/Counsel for Children)' ) {
- $certs[ ] = 'nacc-cw';
- } else if ( ( $cert == 'Legal Malpractice Law (State Bar of California)' ) || ( $cert == 'Legal Malpractice Law' ) ) {
- $certs[ ] = 'cbls-lgmp';
- } else if ( $cert == 'Legal Professional Liability (Am Brd of Prof Liability Attys)' ) {
- $certs[ ] = 'abpla-leg';
- } else if ( $cert == 'Medical Professional Liability (Am Brd of Prof Liability Attys)' ) {
- $certs[ ] = 'abpla-med';
- } else if ( $cert == 'Social Security Disability Law (Natl Board of Trial Advocacy)' ) {
- $certs[ ] = 'nbta-ssd';
- } else if ( ( $cert == 'Taxation Law (State Bar of California)' ) || ( $cert == 'Taxation Law' ) ) {
- $certs[ ] = 'cbls-taxl';
- } else if ( ( $cert == "Workers' Compensation Law (State Bar of California)" ) || ( $cert == "Workers' Compensation Law" ) ) {
- $certs[ ] = 'cbls-wcmp';
- } else {
- return null;
- }
- }
- if ( count( $certs ) > 0 ) {
- $certcodes = implode( "|", $certs );
- return $certcodes;
- } else {
- return null;
- }
- }
- //Sections needs to be fixed because currently breaks when both
- //section and board specialty exist. easy fix but no time.
- // private function get_sections() {
- // $tables = $this->dom->find('table');
- // foreach($tables as $table) {
- // $tablesa[] = $table;
- // }
- // $sect = str_get_html($tablesa[1]);
- // $tds = $sect->find('td');
- // foreach($tds as $td) {
- // $tda[] = $td;
- // }
- // $sectdraw = $tda[1];
- // if(isset($tda[1])) {
- // $sectdx = explode('<br />',$sectdraw);
- // $sectdx = array_map('strip_tags', $sectdx);
- // $sectdx = array_map('trim', $sectdx);
- // $sectdx = array_filter($sectdx);
- // $secti = implode('|', $sectdx);
- // $secti = trim($secti);
- // if($secti !==''){
- // return $secti;
- // } else {
- // return null;
- // }
- // } else {
- // return null;
- // }
- // }
- private function crawl_page( $url = false ) {
- global $curl_cached_response_code;
- $this->html = curl_cached_scrape( $url ? $url : $this->url );
- if ( $curl_cached_response_code != '200' ) {
- $this->crawl_failure();
- }
- $this->dom = str_get_html( $this->html );
- }
- private function crawl_failure( ) {
- global $file_get_contents_cached_as;
- unlink( $file_get_contents_cached_as[ 0 ] ); //Delete cache for this crawl
- echo "<strong>This page was unable to be crawled:</strong><br>" + $this->url;
- exit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement