function follow_notpl($mode, $url, $player) { global $players, $player_width, $player_height; if ($mode == 'down') { down_url($url); } else { $item = array('url' => $url); load_cache('players'); $plid = empty($player) ? 0 : $player; if (!$plid) { $ext = strtolower(mextension($url)); foreach ($players as $k => $player) { if ($player['available'] && $player['ptype'] == $mode && in_array($ext, array_filter(explode(',', $player['exts'])))) { $plid = $k; break; } } } !$plid && message(lang('noplayer')); $player = read_cache('player', $plid); $item['width'] = empty($player_width) ? '100%' : $player_width; $item['height'] = empty($player_height) ? '100%' : $player_height; $_content = sqlstr_replace($player['template'], $item); mexit($_content); } }
function findfiles($absdir, $str = '', $inc = 0) { //$inc 0按扩展名查询,1按包含字串查询 $tempfiles = array(); if (is_dir($absdir)) { if ($tempdir = opendir($absdir)) { while (($tempfile = readdir($tempdir)) !== false) { if (filetype($absdir . "/" . $tempfile) == 'file') { if (!$str) { $tempfiles[] = $tempfile; } elseif (!$inc && mextension($tempfile) == $str) { $tempfiles[] = $tempfile; } elseif ($inc && in_str($str, $tempfile)) { $tempfiles[] = $tempfile; } } } closedir($tempdir); } } return $tempfiles; }
function face_files($absdir) { $rets = array(); if (is_dir($absdir)) { if ($tempdir = opendir($absdir)) { while (($tempfile = readdir($tempdir)) !== false) { if (filetype($absdir . "/" . $tempfile) == 'file' && in_array(strtolower(mextension($tempfile)), array('gif', 'jpg', 'png'))) { $rets[] = $tempfile; } } closedir($tempdir); } } return $rets; }
function common_field($fname, &$html, $reflink) { //当前任务,当前url情况下 if ($html == '') { return ''; } empty($this->fields) && $this->gather_fields(); if (!($field = $this->fields[$fname]) || empty($field['ftag'])) { return ''; } $linkparse = new linkparse(); if (!in_array($field['datatype'], array('images', 'files', 'flashs', 'medias'))) { $content = $this->fetch_detail($field['ftag'], $html); $this->c_replace($field['fromreplace'], $field['toreplace'], $content); $this->clearhtml($field['clearhtml'], $content); $linkparse->setsource($content, $reflink, $field['rpid'], $field['jumpfile']); if (!$field['islink']) { $linkparse->handlelinks(); $content = $linkparse->html; } else { $content = $linkparse->handlelink($content); if (in_array(mextension($content), array('jpg', 'gif', 'png', 'jpeg', 'bmp'))) { $imageinfo = @getimagesize(view_url($content)); !empty($imageinfo) && ($content .= '#' . $imageinfo[0] . '#' . $imageinfo[1]); } } } else { $content = $this->fetch_detail($field['ftag'], $html); $fregions = explode($field['splittag'], $content); $furls = array(); $linkparse->setsource('', $reflink, $field['rpid'], $field['jumpfile']); foreach ($fregions as $fregion) { $urlarr = array(); $this->clean_blank($fregion); if (!($furl = $this->fetch_detail($field['remotetag'], $fregion))) { continue; } $furl = $linkparse->handlelink($furl); $urlarr['remote'] = $furl; if ($field['datatype'] == 'images') { $imageinfo = @getimagesize(view_url($furl)); !empty($imageinfo[0]) && ($urlarr['width'] = $imageinfo[0]); !empty($imageinfo[1]) && ($urlarr['height'] = $imageinfo[1]); } $urlarr['title'] = $this->fetch_detail($field['titletag'], $fregion); $furls[] = $urlarr; } $content = serialize($furls); } !empty($field['func']) && $this->func_deal($field['func'], $content); unset($linkparse, $urlarr, $furls); return $content; }
function zip_upload($localname, $type = 'image') { global $curuser, $memberid, $_FILES, $localfiles, $dir_userfile, $db, $tblprefix, $timestamp, $ftp_enabled; include_once 'include/zip.cls.php'; $uploadfile = $result = array(); $file_saved = false; $localfile = $localfiles[$type]; foreach ($localfile as $k => $v) { if (empty($v['islocal'])) { unset($localfile[$k]); } } if (!$_FILES[$localname] || !mis_uploaded_file($_FILES[$localname]['tmp_name']) || !$_FILES[$localname]['tmp_name'] || !$_FILES[$localname]['name'] || $_FILES[$localname]['tmp_name'] == 'none') { $result['error'] = 1; //'不存在的上传文件!' return $result; } $uploadfile = $_FILES[$localname]; $localfilename = addslashes($uploadfile['name']); $uploadfile['mid'] = $curuser->info['mid']; $uploadfile['mname'] = $curuser->info['mname']; $uploadpath = $this->upload_path($type); $fuploadpath = M_ROOT . $uploadpath; if (empty($localfile)) { //本地上传方案为空 @unlink($uploadfile['tmp_name']); $result['error'] = 1; return $result; } if ($this->capacity != -1 && $uploadfile['size'] > 1024 * $this->capacity) { //超过空间 @unlink($uploadfile['tmp_name']); $result['error'] = 1; return $result; } $zip = new PHPZip($uploadfile['tmp_name']); $lst = $zip->filelist(); $result['count'] = count($lst); $ret = array(); $capacity = 1024 * $this->capacity; $size = 0; foreach ($lst as $z) { if ($z['folder']) { $result['count']--; continue; } $extension = strtolower(mextension($z['name'])); if (!in_array($extension, array_keys($localfile))) { //文件类型不在本地上传方案中 continue; } if (!empty($localfile[$extension]['minisize']) && $z['size'] < 1024 * $localfile[$extension]['minisize']) { //'超出该文件类型大小限制!' continue; } if (!empty($localfile[$extension]['maxsize']) && $z['size'] > 1024 * $localfile[$extension]['maxsize']) { //'超出该文件类型大小限制!' continue; } $size += $z['size']; if ($this->capacity != -1 && $size > $capacity) { break; } $ret[] = $z['index']; } if (empty($ret)) { $result['error'] = -2; return $result; } $tzip = "{$fuploadpath}{$memberid}_" . random(6) . '/'; $lst = $zip->Extract($tzip, $ret); @unlink($uploadfile['tmp_name']); $ret = array(); foreach ($lst as $k => $v) { if (substr($k, -1) == '/') { continue; } $uploadfile['filename'] = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", date('dHis') . substr(md5($k . microtime()), 5, 10) . random(4, 1) . '.' . $extension); $uploadfile['url'] = $uploadpath . $uploadfile['filename']; $target = $fuploadpath . $uploadfile['filename']; if (!rename($tzip . $k, $target)) { continue; } $uploadfile['thumbed'] = 0; if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp'))) { if (!($infos = @getimagesize($target))) { @unlink($target); continue; } if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { /* if(isset($infos[0]) && isset($infos[1])){ $result['width'] = $infos[0]; $result['height'] = $infos[1]; }*/ if ($this->image_thumb($target)) { $uploadfile['thumbed'] = 1; } if ($this->image_watermark($target)) { $uploadfile['size'] = filesize($target); } } } if ($ftp_enabled) { include_once M_ROOT . "./include/ftp.fun.php"; ftp_upload($target, $uploadfile); } $this->upload_size += ceil($uploadfile['size'] / 1024); if ($this->capacity != -1) { $this->capacity -= ceil($uploadfile['size'] / 1024); $this->capacity = max(0, $this->capacity); } $db->query("INSERT INTO {$tblprefix}userfiles SET\n\t\t\t\t\tfilename='{$uploadfile['filename']}',\n\t\t\t\t\turl='{$uploadfile['url']}',\n\t\t\t\t\ttype='{$type}',\n\t\t\t\t\tcreatedate='{$timestamp}',\n\t\t\t\t\tmid='{$uploadfile['mid']}',\n\t\t\t\t\tmname='{$uploadfile['mname']}',\n\t\t\t\t\tsize='{$uploadfile['size']}',\n\t\t\t\t\tthumbed='{$uploadfile['thumbed']}'"); if ($ufid = $db->insert_id()) { $this->ufids[] = $ufid; } $ret[] = $uploadfile['url']; } unset($uploadfile); clear_dir($tzip, 1); $result['remote'] = $ret; return $result; }