Пример #1
0
/**
 * Generates Google Rank Html display Fragment
 * 
 * @access  public
 * @return  string   html fragment
 */
function GooglePageRank()
{
    $cache_dir = JAWS_DATA . 'launcher' . DIRECTORY_SEPARATOR;
    if (!Jaws_Utils::mkdir($cache_dir)) {
        return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $cache_dir), __FUNCTION__);
    }
    $url = $GLOBALS['app']->GetSiteURL('/');
    $file = $cache_dir . 'rank_' . md5($url);
    $timedif = time() - (file_exists($file) ? @filemtime($file) : 0);
    $gRank = new PageRank();
    if ($timedif < 604800) {
        // a week
        //cache file is fresh
        $rank = $gRank->loadFile($file);
    } else {
        $rank = $gRank->GetRank($url);
        $gRank->saveFile($file, $rank);
    }
    unset($gRank);
    $theme = $GLOBALS['app']->GetTheme();
    if (is_dir($theme['path'] . 'PageRank')) {
        $pg_images = $theme['url'] . 'PageRank/';
    } else {
        $pg_images = $GLOBALS['app']->getSiteURL('/gadgets/Launcher/Resources/images/PageRank/', true);
    }
    return "<img src='{$pg_images}pr{$rank}.gif' alt='{$rank}' />";
}