Example #1
0
 function antilink($folder = NULL, $url = NULL, $base = NULL)
 {
     if (!$folder || !$url) {
         return;
     }
     if (!is_dir(ROOT . 'application/app/' . $folder)) {
         return;
     }
     $url = base64_decode($url);
     $base = base64_decode($base);
     if (strtolower(substr($url, 0, 7)) != 'http://') {
         $url = $base . $url;
     }
     if (strtolower(substr($url, 0, 7)) != 'http://') {
         return;
     }
     $md5 = md5($url);
     $web_dir = "static/data/hash/snaps/" . $folder . '/' . myhashstr($md5);
     $web_file = $web_dir . $md5 . '.gif';
     if (file_exists(ROOT . $web_file)) {
         readfile($web_file);
     }
     $parse = parse_url($url);
     $ref = dirname($url);
     $this->load->library('snoopy');
     $this->snoopy->referer = $ref;
     if ($this->snoopy->fetch($url)) {
         MakeDir(ROOT . $web_dir);
         $remote_file = $this->snoopy->results;
         file_put_contents(ROOT . $web_file, $remote_file);
         echo $remote_file;
     }
 }
Example #2
0
define('BASEPATH', dirname(__FILE__) . '/../..');
function myhashstr($str)
{
    return $str[0] . $str[1] . '/' . $str[2] . $str[3] . '/';
}
function MakeDir($path)
{
    if (!file_exists($path)) {
        MakeDir(dirname($path));
        @mkdir($path, 0777);
    }
}
$size = intval($_REQUEST['size']) > 0 ? intval($_REQUEST['size']) : 80;
$url = $_REQUEST['url'];
$md5 = md5($url);
$web_path = "/static/data/hash/pic_icon/" . myhashstr($md5);
$path = BASEPATH . $web_path;
$web_file = $web_path . $md5 . $size . '.gif';
$file = BASEPATH . $web_file;
$source_file = BASEPATH . $url;
if (!file_exists($file)) {
    @MakeDir($path);
    if (file_exists($source_file)) {
        include_once BASEPATH . '/application/libraries/Icon.php';
        $icon = new icon();
        $icon->path = $source_file;
        $icon->size = $size;
        $icon->dest = $file;
        $icon->createIcon();
    }
}