Exemplo n.º 1
0
function get_page_rank($url)
{
    $p = new PageRank();
    return $p->getRank($url);
}
Exemplo n.º 2
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}' />";
}
Exemplo n.º 3
0
#!/usr/bin/php
<?php 
/*
    Google PageRank PHP Command Line Interface (CLI) Script
    Requires: pagerank2.class.php
    Install: Rename to pr.php (mv pagerank.cli.php pr.php) and make executable (chmod 755 pr.php)
    Usage: ./pr.php <url>
*/
require 'pagerank2.class.php';
$pr = new PageRank();
echo $pr->get($argv[1]);