'star-o', 'stars' => 'star' ); // store rating stars $retval = ''; // final result $pdfval = ''; // pdf description result $is_pdf = $logged_in ? $is_pdf : false; // disable pdf is user is not logged in foreach( $json as $key => $properties ): if( $score == 0 ): // score output here $sitescreen = !is_null( $properties->thumbnail ) ? '' : ''; $report_url = $report->urls[0]->url; $totalscore = $properties->factors->green + $properties->factors->red + $properties->factors->orange + $properties->factors->missing; $retval .= '
'; $retval .= '
' // factors-percent . '' . '
Download PDF Report
' . '
' // end factors-percent . '
' // factors score . '

Report of

' . '

' . $report_url . '

' . '' . '
' // end factors-score . '
' // site screen . '
' . $sitescreen // actual site screen . '
' . '
'; // end factors-site $retval .= '
'; // end score-table elseif( $score > 0 ): // factors output here $status = ''; $retval .= '
'; // group all data within the row if( !in_array( $properties->model->category->display, $categories ) ): array_push( $categories, $properties->model->category->display ); $retval .= empty( $properties->model->category->display ) ? '' : '

' . $properties->model->category->display . '

' . '
' . '
'; $pdfval .= $is_pdf ? '
' . $properties->model->category->display . '
' : ''; endif; if( !in_array( $properties->model->category->group->name, $groups ) ): array_push( $groups, $properties->model->category->group->name ); $retval .= empty( $properties->model->category->group->name ) ? '' : '
' . $properties->model->category->group->name . '
' . '
'; $pdfval .= $is_pdf ? '
' . $properties->model->category->group->name . '
' : ''; endif; switch( $properties->model->status ): case 'MISSING': case 'RED': { $status = 'times'; break; } case 'ORANGE': { $status = 'minus'; break; } case 'GREEN': { $status = 'check'; break; } case 'NEUTRAL':{ $status = 'info'; break; } default: { $status = 'question-circle'; } endswitch; $status = $logged_in ? $status : 'question-circle'; $statuscolor = $logged_in ? strtolower( $properties->model->status ) : ''; $rendering = array( 'name' => $properties->model->name, 'type' => $properties->model->type, 'model' => $properties->model->model, 'data' => $properties->data, 'status'=> $properties->model->status, 'free' => $properties->model->free, 'pro' => $properties->model->pro_only, ); if( $properties->model->display == 'Text/HTML ratio' ) $rendering['data'] = intval( round( $rendering['data'] ) ); $retval .= '
' . '' . '
'; $retval .= '
' . ( $status ? '' : '' ) . $properties->model->display . '
'; $pdfval .= $is_pdf ? '
  • ' . $properties->model->display . ': ' : ''; $retval .= '
    '; $retval .= render2html( $rendering['name'], $rendering['type'], $rendering['model'], $rendering['data'], $rendering['status'], $rendering['free'], $rendering['pro'], $logged_in ); $retval .= '
    '; if( $is_pdf ): $pdfval .= html_entity_decode( $properties->model->description ) . '
    Solution: ' . $properties->model->solution . '
    Article: ' . $properties->model->article . '' . '
  • '; // close factors item else: $retval .= $logged_in ? '

    ' . html_entity_decode( $properties->model->description ) . '

    ' : ''; endif; $retval .= '
    ' // close inside section row . '
    ' . '
    '; // row ends here endif; $score++; endforeach; if( $is_pdf ): $retval .= '

      Factors description

      ' . $pdfval . '
    '; endif; return '
    ' . $retval . '
    '; } function render2html( $name, $type, $model, $data, $status, $free, $pro, $logged ) { if( $logged || ( !$logged && $free ) ): $model = html_entity_decode( $model ); // get factor type from data-type, in case it's missing in DB $factor_type = "NULL"; if( !is_null( $data ) ): if( is_bool( $data ) ): $factor_type = "BOOLEAN"; endif; if( is_numeric( $data ) ): $factor_type = "NUMBER"; endif; if( is_string( $data ) ): $factor_type = "STRING"; endif; if( is_array( $data ) ): $factor_type = "ARRAY"; endif; if( is_object( $data ) ): $factor_type = "OBJECT"; endif; endif; // if present in DB use DB factor-type if( !is_null( $type ) && !is_null( $data ) ): $factor_type = $type; endif; switch( $factor_type ): case 'NULL': { $html = $model; break; } case 'BOOLEAN': { $html = !is_null( $model ) ? $model : $data; break; } case 'NUMBER': { $html = !is_null( $model ) ? sprintf( $model, $data ) : $data; break; } case 'STRING': { $html = !is_null( $model ) && !empty( $model ) ? sprintf( $model, $data ) : $data; break; } case 'ARRAY': { $html = !is_null( $model ) || !$model ? sprintf( $model, implode( ', ', $data ) ) : ''; break; } case 'OBJECT': { $html = ''; foreach( $data as $prop => $value ): $html .= $prop . '(' . $value .')'; endforeach; break; } case 'HTML_VALIDITY': { $html = render_htmlvalidity( $model, $data ); break; } case 'META_DESCRIPTION': case 'URL': { $html = !is_null( $model ) && !empty( $model ) ? sprintf( $model, $data, strlen( $data ) ) : $data; break; } case 'HEADINGS': { $html = render_headings( $model, $data ); break; } case 'SPEED_ANALYSIS': { $html = render_speed_analysis( $model, $data ); break; } case 'BACKLINKS': { $html = render_backlinks( $data ); break; } case 'GMAPS': { // TO-TEST $html = render_gmaps( $data ); break; } case 'GOOGLEPREVIEW': { // TODO - TEST and FIX $html = render_google_preview( $data ); break; } case 'LOCATION': { $html = render_location( $data ); break; } case 'IMAGE': { $html = ''; $html_temp = ''; if( $name == 'emails' ): foreach( $data as $emailinfo ): $html_temp .= '
    '; endforeach; endif; if( $name == 'phone' ): $phone_temp = ''; foreach( $data as $phoneinfo ): if($phoneinfo->region == null) { $phone_temp = "Phone International: " . $phoneinfo->phone_international . ";" ."Phone: ". $phoneinfo->phone . ';'."Type: " . $phoneinfo->type; } elseif($phoneinfo->phone_international == null){ $phone_temp ="Region: ".$phoneinfo->region .";" ."Phone: ". $phoneinfo->phone . ';'."Type: " . $phoneinfo->type; } elseif($phoneinfo->phone == null){ $phone_temp = "Region: ".$phoneinfo->region . ";"."Phone International: " . $phoneinfo->phone_international . ";" ."Type: " . $phoneinfo->type; } elseif($phoneinfo->type == null){ $phone_temp = "Region: ".$phoneinfo->region . ";"."Phone International: " . $phoneinfo->phone_international . ";" ."Phone: ". $phoneinfo->phone; } else { $phone_temp = "Region: ".$phoneinfo->region . ";"."Phone International: " . $phoneinfo->phone_international . ";" ."Phone: ". $phoneinfo->phone . ';'."Type: " . $phoneinfo->type ; } $phone_arr = explode(";" , $phone_temp); foreach($phone_arr as $value){ $html_temp .= '
    '; } endforeach; endif; $html = !empty( $data ) ? $html_temp : $model; break; } case 'BASE64': { $html = ''; $html_temp = ''; $img = get_base64image( $data ); switch( $name): case 'favicon': $width = 24; break; case 'logo': $width = 50; break; endswitch; $html_temp = !is_null( $img ) ? sprintf( $model, '' ) : ''; $html = !empty( $data ) ? $html_temp : $model; break; } default: { } endswitch; else: $html = '
    '; endif; return $html ?: false; } function render_speed_analysis( $model, $data ) { $html = !is_null( $model ) && !empty( $model ) ? sprintf( $model, $data->score ) : $data; $html .= $data->grades ? '
    ' : ''; // trick div $factors_labels = array( 'favicon' => 'Make favicon small and cacheable', 'no404' => 'Avoid HTTP 404 (Not Found) error', 'cdn' => 'Use a Content Delivery Network (CDN)', 'expires' => 'Add Expires headers', 'compress' => 'Compress components with gzip', 'numreq' => 'Make fewer HTTP Requests', 'emptysrc' => 'Avoid empty src or href', 'csstop' => 'Put CSS at top', 'jsbottom' => 'Put JavaScript at bottom', 'mindom' => 'Reduce the number of DOM elements', 'mincookie' => 'Reduce cookie size', 'imgnoscale'=> 'Do not scale images in HTML', 'etags' => 'Configure entity tags (ETags)', 'dns' => 'Reduce DNS lookups', 'cookiefree'=> 'Use cookie-free domains', 'dupes' => 'Remove duplicate JavasScript and CSS', 'redirects' => 'Avoid URL redirects', 'xhr' => 'Make AJAX cacheable', 'xhrmethod' => 'Use GET for AJAX requests', ); foreach( $data->grades as $label => $grade ): $html .= '
    '; $html .= '
    ' . $factors_labels[$label] . '
    ' . '
    ' . '
     
    ' . '
    ' . '
    ' . $grade . '%
    '; $html .= '
    '; // close row endforeach; $html .= '
    '; return $html; } function get_base64image( $value ) { $favicon = str_replace("http://", "", str_replace("https://", "", $value)); $valueLen = strlen($favicon); $result = null; $has_favicon = false; if ($valueLen > 0) { if (strpos($favicon, ".ico") !== false) { $has_favicon = true; $has_mime = "data:image/png;base64,"; } if (strpos($favicon, ".jpg") !== false) { $has_favicon = true; $has_mime = "data:image/jpeg;base64,"; } if (strpos($favicon, ".png") !== false) { $has_favicon = true; $has_mime = "data:image/png;base64,"; } if (strpos($favicon, ".gif") !== false) { $has_favicon = true; $has_mime = "data:image/gif;base64,"; } if (strpos($favicon, ".svg") !== false) { $has_favicon = true; $has_mime = "data:image/svg+xml;base64,"; } if ($has_favicon && $has_mime) { $callback = @file_get_contents($value); if ($callback) { $result = $has_mime . base64_encode($callback); } else { $result = $has_mime; } } } return $result; } function get_imagefromtext( $string ) { ob_start(); $width = 100; $height = 25; $font = 4; $font_family = 'fonts/open-sans/OpenSans-Regular.ttf'; $width = imagefontwidth($font) * strlen($string); $height = imagefontheight($font); $image = imagecreatetruecolor ($width,$height); $white = imagecolorallocate ($image,255,255,255); $black = imagecolorallocate ($image,0,0,0); imagefill($image,0,0,$white); imagestring ($image,$font,0,0,$string,$black); //imagettftext($image, 20, 0, 10, 20, $black, $font_family, $string); imagepng ($image); imagedestroy($image); $sImage = base64_encode(ob_get_contents()); ob_end_clean(); return 'data:image/png;base64,'.$sImage; } function render_backlinks( $value ) { $out = ''; $pairs = array( /* pairs of min. two as key => label */ array( 'text' => 'Text', 'image' => 'Images' ), array( 'refpages' => 'Referal Pages', 'pages' => 'Pages' ), array( 'nofollow' => 'NoFollow', 'dofollow' => 'DoFollow' ), array( 'sitewide' => 'Site Wide', 'not_sitewide' => 'Not Site Wide' ), array( 'links_internal' => 'Internal links', 'links_external' => 'External links' ), array( 'gov' => 'Gov', 'edu' => 'Edu', 'rss' => 'Rss' ), array( 'redirect' => 'Redirect', 'canonical' => 'Canonical' ), array( 'alternate' => 'Alternate', 'html_pages' => 'HTML Pages' ), ); if( is_object( $value ) ) { foreach( $pairs as $pair ) { $chart = ''; $out .= $chart; } } return 'Total: ' . $value->total . '
    ' // trick div . '
    ' . $out . '
    ' . '
    '; } function render_gmaps( $value ) { $ispdf = $_GET['pdf'] ? true : false; if( is_object( $value ) ) { if( !empty( $value->longitude ) && !empty( $value->latitude ) ) { $map = '
    companyname ) ) $map .= 'data-title="' . $value->companyname . '" '; $map .= 'data-maplng="' . $value->longitude . '" data-maplat="' . $value->latitude . '">
    '; } } return $map ?: false; } function render_google_preview( $value ) { $out = ''; if( is_object( $value ) ): $out .= '

    ' . $value->title . '

    '; $out .= '' . $value->url . ''; $out .= '' . $value->meta_description . ''; endif; return empty( $out ) ? false : '
    ' . $out . '
    '; } function render_headings( $model, $value ) { $out = ''; if( is_object( $value ) ): $out .= '

    ' . $model . ' (' . $value->total . ' items)

    '; $out .= ''; for( $i = 1; $i <= 6; $i++ ): $out .= $i == 1 ? '' : ''; $out .= ''; $out .= $i == 6 ? '' : ''; endfor; for( $i = 1; $i <= 6; $i++ ): $out .= $i == 1 ? '' : ''; $hd_i = (string) 'h' . $i; $out .= ''; $out .= $i == 6 ? '' : ''; endfor; $out .= '
    H' . $i . '
    ' . $value->$hd_i . '
    '; endif; return empty( $out ) ? false : '
    ' . $out . '
    '; } function render_htmlvalidity( $model, $value ) { $out = ''; if( is_object( $value ) ): $out .= sprintf( $model, $value->errors, $value->warnings ); endif; return empty( $out ) ? $value : $out; } function render_location( $value ) { $out = ''; if( is_object( $value ) ): $flag = '' . $value->country_name . ''; $out .= $value->city . ', ' . $value->country_name . ' (' . $value->country_code . ') ' . $flag . '
    ' . $value->state . ', ' . $value->zip; endif; return empty( $out ) ? false : '
    ' . trim( $out, " ," ) . '
    '; } /* * eRanker default methods */ if( !function_exists('get_date_time') ) { function get_date_time( $date_time ) { return date( 'd/m/y, H:i', strtotime( get_date_from_gmt( $date_time, get_option( 'date_format' ) . ' ' . get_option('time_format') ) ) ); } } ?>