コード例 #1
0
ファイル: class_ico.php プロジェクト: druphliu/dzzoffice
 /**
  * Ico::LoadFile()
  * Load an ICO file (don't need to call this is if fill the
  * parameter in the class constructor)
  *
  * @param   string   $path   Path to ICO file
  * @return  boolean          Success
  **/
 function LoadFile($path)
 {
     $this->_filename = $path;
     /*if (($fp = @fopen($path, 'rb')) !== false) {
                     $data = '';
                     while (!feof($fp)) {
                         $data .= fread($fp, 4096);
                     }
                     fclose($fp);
     
                     return $this->LoadData($data);
                 }*/
     if ($data = dzz_file_get_contents($path)) {
         return $this->LoadData($data);
     }
     return false;
 }
コード例 #2
0
ファイル: class_image.php プロジェクト: druphliu/dzzoffice
 function init($method, $source, $target, $nosuffix = 0)
 {
     global $_G;
     $this->errorcode = 0;
     if (empty($source)) {
         return -2;
     }
     $parse = parse_url($source);
     if (isset($parse['host'])) {
         if (empty($target)) {
             return -2;
         }
         $data = dzz_file_get_contents($source);
         $this->tmpfile = $source = tempnam($_G['setting']['attachdir'] . './temp/', 'tmpimg_');
         if (!$data || $source === FALSE) {
             return -2;
         }
         file_put_contents($source, $data);
     }
     if ($method == 'thumb') {
         $target = empty($target) ? !$nosuffix ? getimgthumbname($source) : $source : $_G['setting']['attachdir'] . './' . $target;
     } elseif ($method == 'watermask') {
         $target = empty($target) ? $source : $_G['setting']['attachdir'] . './' . $target;
     }
     $targetpath = dirname($target);
     dmkdir($targetpath);
     clearstatcache();
     if (!is_readable($source) || !is_writable($targetpath)) {
         return -2;
     }
     $imginfo = @getimagesize($source);
     if ($imginfo === FALSE) {
         return -1;
     }
     $this->source = $source;
     $this->target = $target;
     $this->imginfo['width'] = $imginfo[0];
     $this->imginfo['height'] = $imginfo[1];
     $this->imginfo['mime'] = $imginfo['mime'];
     $this->imginfo['size'] = @filesize($source);
     $this->libmethod = $this->param['imagelib'] && $this->param['imageimpath'];
     if (!$this->libmethod) {
         switch ($this->imginfo['mime']) {
             case 'image/jpeg':
                 $this->imagecreatefromfunc = function_exists('imagecreatefromjpeg') ? 'imagecreatefromjpeg' : '';
                 $this->imagefunc = function_exists('imagejpeg') ? 'imagejpeg' : '';
                 break;
             case 'image/gif':
                 $this->imagecreatefromfunc = function_exists('imagecreatefromgif') ? 'imagecreatefromgif' : '';
                 $this->imagefunc = function_exists('imagegif') ? 'imagegif' : '';
                 break;
             case 'image/png':
                 $this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : '';
                 $this->imagefunc = function_exists('imagepng') ? 'imagepng' : '';
                 break;
         }
     } else {
         $this->imagecreatefromfunc = $this->imagefunc = TRUE;
     }
     if (!$this->libmethod && $this->imginfo['mime'] == 'image/gif') {
         if (!$this->imagecreatefromfunc) {
             return -4;
         }
         if (!($fp = @fopen($source, 'rb'))) {
             return -2;
         }
         $content = fread($fp, $this->imginfo['size']);
         fclose($fp);
         $this->imginfo['animated'] = strpos($content, 'NETSCAPE2.0') === FALSE ? 0 : 1;
     }
     return $this->imagecreatefromfunc ? 1 : -4;
 }
コード例 #3
0
ファイル: class_caiji.php プロジェクト: druphliu/dzzoffice
 public function getFavicon()
 {
     $parseurl = parse_url($this->_url);
     $host = $parseurl['host'];
     if ($parseurl['scheme'] == 'https') {
         $parseurl['scheme'] = 'http';
     }
     $host = preg_replace("/^www./", '', $host);
     //strstr('.',$host);
     $ico = $parseurl['scheme'] . '://' . $host . '/favicon.ico';
     $ico_not_www = $parseurl['scheme'] . '://www.' . $host . '/favicon.ico';
     if (check_remote_file_exists($ico, $this->_proxy)) {
         return $ico;
     } elseif (check_remote_file_exists($ico_not_www, $this->_proxy)) {
         return $ico_not_www;
     } else {
         if (!$this->_content) {
             $this->_content = dzz_file_get_contents($this->_url, $this->_redirect, $this->_proxy);
         }
         if (preg_match("/<link(.+?)rel=\"[shortcut\\s+icon|shortcut|icon]+\"(.+?)>/i", $this->_content, $matches2)) {
             if (preg_match("/href=\"(.+?)\"/i", $matches2[0], $matches3)) {
                 $ico = trim($matches3[1]);
                 $purl = parse_url($ico);
                 if (empty($purl['host'])) {
                     //exit('dfdsf');
                     $ico0 = $parseurl['scheme'] . '://' . preg_replace("/\\/\\//i", '/', $host . '/' . $ico);
                     $ico1 = $parseurl['scheme'] . '://' . preg_replace("/\\/\\//i", '/', 'www.' . $host . '/' . $ico);
                 } else {
                     $ico0 = $ico1 = preg_replace("/^https/i", 'http', $ico);
                 }
                 //exit($ico0.'===='.$ico1);
                 if (check_remote_file_exists($ico1, $this->_proxy)) {
                     return $ico1;
                 }
                 if (check_remote_file_exists($ico0, $this->_proxy)) {
                     return $ico0;
                 }
             }
         }
     }
     return '';
 }
コード例 #4
0
ファイル: function_video.php プロジェクト: druphliu/dzzoffice
function parseflv($url, $width = 0, $height = 0)
{
    $lowerurl = strtolower($url);
    $flv = '';
    $imgurl = '';
    if ($lowerurl != str_replace(array('player.youku.com/player.php/sid/', 'tudou.com/v/', 'player.ku6.com/refer/'), '', $lowerurl)) {
        $flv = $url;
    } elseif (strpos($lowerurl, 'v.youku.com/v_show/') !== FALSE) {
        if (preg_match("/http:\\/\\/v.youku.com\\/v_show\\/id_(\\w+)(.html)/i", $url, $matches)) {
            $flv = 'http://player.youku.com/player.php/sid/' . $matches[1] . '/v.swf';
            if (!$width && !$height) {
                $api = 'http://v.youku.com/player/getPlayList/VideoIDS/' . $matches[1];
                $str = stripslashes(file_get_contents($api));
                if (!empty($str) && preg_match("/\"logo\":\"(.+?)\"/i", $str, $image)) {
                    $url = substr($image[1], 0, strrpos($image[1], '/') + 1);
                    $filename = substr($image[1], strrpos($image[1], '/') + 2);
                    $imgurl = $url . '0' . $filename;
                }
            }
        }
        //http://www.tudou.com/programs/view/TCwDFnpZuH8/
    } elseif (strpos($lowerurl, 'tudou.com/programs/view/') !== FALSE) {
        if (preg_match("/http:\\/\\/(www.)?tudou.com\\/programs\\/view\\/([^\\/]+)/i", $url, $matches)) {
            $flv = 'http://www.tudou.com/v/' . $matches[2];
            if (!$width && !$height) {
                $str = dzz_file_get_contents($url);
                if (!empty($str) && preg_match("/pic:\\s\\'(.+?)\\'/i", $str, $image)) {
                    $imgurl = trim($image[1]);
                }
            }
        }
    } elseif (strpos($lowerurl, 'v.ku6.com/show/') !== FALSE) {
        if (preg_match("/http:\\/\\/v.ku6.com\\/show\\/([^\\/]+).html/i", $url, $matches)) {
            $flv = 'http://player.ku6.com/refer/' . $matches[1] . '/v.swf';
            if (!$width && !$height) {
                $api = 'http://vo.ku6.com/fetchVideo4Player/1/' . $matches[1] . '.html';
                $str = dzz_file_get_contents($api);
                if (!empty($str) && preg_match("/\"picpath\":\"(.+?)\"/i", $str, $image)) {
                    $imgurl = str_replace(array('\\u003a', '\\u002e'), array(':', '.'), $image[1]);
                }
            }
        }
    } elseif (strpos($lowerurl, 'v.ku6.com/special/show_') !== FALSE) {
        if (preg_match("/http:\\/\\/v.ku6.com\\/special\\/show_\\d+\\/([^\\/]+).html/i", $url, $matches)) {
            $flv = 'http://player.ku6.com/refer/' . $matches[1] . '/v.swf';
            if (!$width && !$height) {
                $api = 'http://vo.ku6.com/fetchVideo4Player/1/' . $matches[1] . '.html';
                $str = dzz_file_get_contents($api);
                if (!empty($str) && preg_match("/\"picpath\":\"(.+?)\"/i", $str, $image)) {
                    $imgurl = str_replace(array('\\u003a', '\\u002e'), array(':', '.'), $image[1]);
                }
            }
        }
    } elseif (strpos($lowerurl, 'www.youtube.com/watch?') !== FALSE) {
        if (preg_match("/http:\\/\\/www.youtube.com\\/watch\\?v=([^\\/&]+)&?/i", $url, $matches)) {
            $flv = 'http://www.youtube.com/v/' . $matches[1] . '&hl=zh_CN&fs=1';
            if (!$width && !$height) {
                $str = dzz_file_get_contents($url);
                if (!empty($str) && preg_match("/'VIDEO_HQ_THUMB':\\s'(.+?)'/i", $str, $image)) {
                    $url = substr($image[1], 0, strrpos($image[1], '/') + 1);
                    $filename = substr($image[1], strrpos($image[1], '/') + 3);
                    $imgurl = $url . $filename;
                }
            }
        }
    } elseif (strpos($lowerurl, 'tv.mofile.com/') !== FALSE) {
        if (preg_match("/http:\\/\\/tv.mofile.com\\/([^\\/]+)/i", $url, $matches)) {
            $flv = 'http://tv.mofile.com/cn/xplayer.swf?v=' . $matches[1];
            if (!$width && !$height) {
                $str = dzz_file_get_contents($url);
                if (!empty($str) && preg_match("/thumbpath=\"(.+?)\";/i", $str, $image)) {
                    $imgurl = trim($image[1]);
                }
            }
        }
    } elseif (strpos($lowerurl, 'v.mofile.com/show/') !== FALSE) {
        if (preg_match("/http:\\/\\/v.mofile.com\\/show\\/([^\\/]+).shtml/i", $url, $matches)) {
            $flv = 'http://tv.mofile.com/cn/xplayer.swf?v=' . $matches[1];
            if (!$width && !$height) {
                $str = dzz_file_get_contents($url);
                if (!empty($str) && preg_match("/thumbpath=\"(.+?)\";/i", $str, $image)) {
                    $imgurl = trim($image[1]);
                }
            }
        }
        //http://you.video.sina.com.cn/b/9809684-1268992255.html
    } elseif (strpos($lowerurl, 'you.video.sina.com.cn/b/') !== FALSE) {
        if (preg_match("/http:\\/\\/you.video.sina.com.cn\\/b\\/(\\d+)-(\\d+).html/i", $url, $matches)) {
            $flv = 'http://vhead.blog.sina.com.cn/player/outer_player.swf?vid=' . $matches[1];
            if (!$width && !$height) {
                $api = 'http://interface.video.sina.com.cn/interface/common/getVideoImage.php?vid=' . $matches[1];
                $str = dzz_file_get_contents($api);
                if (!empty($str)) {
                    $imgurl = str_replace('imgurl=', '', trim($str));
                }
            }
        }
    } elseif (strpos($lowerurl, 'http://v.blog.sohu.com/u/') !== FALSE) {
        if (preg_match("/http:\\/\\/v.blog.sohu.com\\/u\\/[^\\/]+\\/(\\d+)/i", $url, $matches)) {
            $flv = 'http://v.blog.sohu.com/fo/v4/' . $matches[1];
            if (!$width && !$height) {
                $api = 'http://v.blog.sohu.com/videinfo.jhtml?m=view&id=' . $matches[1] . '&outType=3';
                $str = dzz_file_get_contents($api);
                if (!empty($str) && preg_match("/\"cutCoverURL\":\"(.+?)\"/i", $str, $image)) {
                    $imgurl = str_replace(array('\\u003a', '\\u002e'), array(':', '.'), $image[1]);
                }
            }
        }
    } elseif (strpos($lowerurl, 'http://www.ouou.com/fun_funview') !== FALSE) {
        $str = dzz_file_get_contents($url);
        if (!empty($str) && preg_match("/var\\sflv\\s=\\s'(.+?)';/i", $str, $matches)) {
            $flv = $_G['style']['imgdir'] . '/flvplayer.swf?&autostart=true&file=' . urlencode($matches[1]);
            if (!$width && !$height && preg_match("/var\\simga=\\s'(.+?)';/i", $str, $image)) {
                $imgurl = trim($image[1]);
            }
        }
    } elseif (strpos($lowerurl, 'http://www.56.com') !== FALSE) {
        if (preg_match("/http:\\/\\/www.56.com\\/\\S+\\/play_album-aid-(\\d+)_vid-(.+?).html/i", $url, $matches)) {
            $flv = 'http://player.56.com/v_' . $matches[2] . '.swf';
            $matches[1] = $matches[2];
        } elseif (preg_match("/http:\\/\\/www.56.com\\/\\S+\\/([^\\/]+).html/i", $url, $matches)) {
            $flv = 'http://player.56.com/' . $matches[1] . '.swf';
        }
        if (!$width && !$height && !empty($matches[1])) {
            $api = 'http://vxml.56.com/json/' . str_replace('v_', '', $matches[1]) . '/?src=out';
            $str = dzz_file_get_contents($api);
            if (!empty($str) && preg_match("/\"img\":\"(.+?)\"/i", $str, $image)) {
                $imgurl = trim($image[1]);
            }
        }
    }
    if ($flv) {
        if (!$width && !$height) {
            return array('url' => $flv, 'img' => $imgurl);
        } else {
            $width = addslashes($width);
            $height = addslashes($height);
            $flv = addslashes($flv);
            $randomid = 'flv_' . random(3);
            return '<span id="' . $randomid . '"></span><script type="text/javascript" reload="1">$(\'' . $randomid . '\').innerHTML=AC_FL_RunContent(\'width\', \'' . $width . '\', \'height\', \'' . $height . '\', \'allowNetworking\', \'internal\', \'allowScriptAccess\', \'never\', \'src\', \'' . $flv . '\', \'quality\', \'high\', \'bgcolor\', \'#ffffff\', \'wmode\', \'transparent\', \'allowfullscreen\', \'true\');</script>';
        }
    } else {
        return FALSE;
    }
}
コード例 #5
0
ファイル: dzz_core.php プロジェクト: druphliu/dzzoffice
function image_to_icon($source, $target, $domain)
{
    global $_G;
    if (!($data = dzz_file_get_contents($source))) {
        return false;
    }
    if (!$target) {
        $imageext = array('jpg', 'jpeg', 'png', 'gif');
        $ext = strtolower(substr(strrchr($source, '.'), 1, 10));
        if (!in_array($ext, $imageext)) {
            $ext = 'jpg';
        }
        $subdir = $subdir1 = $subdir2 = '';
        $subdir1 = date('Ym');
        $subdir2 = date('d');
        $subdir = $subdir1 . '/' . $subdir2 . '/';
        $target = 'icon/' . $subdir . '' . $domain . '_' . strtolower(random(8)) . '.' . $ext;
        $target_attach = $_G['setting']['attachdir'] . $target;
    } else {
        $target_attach = $_G['setting']['attachdir'] . $target;
    }
    $targetpath = dirname($target_attach);
    dmkdir($targetpath);
    if (file_put_contents($target_attach, $data)) {
        return $target;
    } else {
        return false;
    }
}