Exemple #1
0
 function get_file($key, $method)
 {
     $dirPath = $this->_dirs . '/' . (strpos($key, '/') !== false ? dirname($key) : '');
     if ($this->_dir_level != -1) {
         $a = str_split(md5($key), $this->_dir_level);
         $dirPath .= '/' . implode('/', $a) . '/';
     }
     if (!file_exists($dirPath) && $method == 'add') {
         createdir($dirPath);
     }
     $strrchr = strrchr($key, '/');
     $strrchr !== false && ($key = $strrchr);
     return $dirPath . $key . '.php';
 }
Exemple #2
0
 public function upload()
 {
     if (is_array($this->uploadFiles['name'])) {
         for ($i = 0; $i < count($this->uploadFiles['name']); $i++) {
             //如果文件上传没有出现错误
             if ($this->uploadFiles['error'][$i] == 0) {
                 //获取当前文件名,临时文件名,文件大小,扩展名
                 $name = $this->uploadFiles['name'][$i];
                 $tmpname = $this->uploadFiles['tmp_name'][$i];
                 $size = $this->uploadFiles['size'][$i];
                 $minetype = $this->uploadFiles['type'][$i];
                 $type = $this->getFileExt($this->uploadFiles['name'][$i]);
                 //检查文件大小是否合法
                 if (!$this->checkSize($size)) {
                     $this->lastError = "文件大小超出限制.文件名称:" . $name;
                     $this->printMsg($this->lastError);
                     continue;
                 }
                 //检查文件扩展名是否合法
                 if (!$this->checkType($type)) {
                     $this->lastError = "非法的文件类型.文件名称:" . $name;
                     $this->printMsg($this->lastError);
                     continue;
                 }
                 //检测当前文件是否非法提交
                 if (!is_uploaded_file($tmpname)) {
                     $this->lastError = "上传文件无效.文件名称:" . $name;
                     $this->printMsg($this->lastError);
                     continue;
                 }
                 //移动后的文件名称
                 $basename = $this->getBaseName($name, '.' . $type);
                 //上传文件重新命名
                 list($usec, $sec) = explode(" ", microtime());
                 $savename = substr($usec, 2) . '.' . $type;
                 //创建上传文件的文件夹
                 createdir($this->saveFilePath);
                 $dir1 = $this->saveFilePath . '/' . date('Y');
                 createdir($dir1);
                 $dir2 = $this->saveFilePath . '/' . date('Y') . '/' . date('m');
                 $thumb_dir = $dir2 . '/thumb';
                 $cover_dir = $dir2 . "/cover";
                 createdir($dir2);
                 createdir($thumb_dir);
                 createdir($cover_dir);
                 //最终组合的文件路径
                 $this->finalFile = $dir2 . '/' . $savename;
                 //把上传的文件从临时目录移到目标目录
                 if (!move_uploaded_file($tmpname, $this->finalFile)) {
                     $this->{$this}->uploadFiles['error'][$i];
                     $this->printMsg($this->lastError);
                     continue;
                 }
                 //存储已经上传的文件信息
                 $tembasename = $this->getBaseName($savename, '.' . $type);
                 $FileInfo = array('name' => $name, 'type' => $type, 'minetype' => $minetype, 'file' => $this->finalFile, 'size' => $size, 'basename' => $tembasename, 'savename' => $savename, 'path' => $dir2, 'thumb_dir' => $thumb_dir . "/", 'cover_dir' => $cover_dir . "/");
                 $this->saveFileInfo[] = $FileInfo;
             }
         }
     } else {
         if ($this->uploadFiles['error'] == 0) {
             //获取当前文件名,临时文件名,文件大小,扩展名
             $name = $this->uploadFiles['name'];
             $tmpname = $this->uploadFiles['tmp_name'];
             $size = $this->uploadFiles['size'];
             $minetype = $this->uploadFiles['type'];
             $type = $this->getFileExt($this->uploadFiles['name']);
             //检查文件大小是否合法
             if (!$this->checkSize($size)) {
                 $this->lastError = "文件大小超出限制.文件名称:" . $name;
                 $this->printMsg($this->lastError);
                 continue;
             }
             //检查文件扩展名是否合法
             if (!$this->checkType($type)) {
                 $this->lastError = "非法的文件类型.文件名称:" . $name;
                 $this->printMsg($this->lastError);
                 continue;
             }
             //检测当前文件是否非法提交
             if (!is_uploaded_file($tmpname)) {
                 $this->lastError = "上传文件无效.文件名称:" . $name;
                 $this->printMsg($this->lastError);
                 continue;
             }
             //移动后的文件名称
             $basename = $this->getBaseName($name, '.' . $type);
             //上传文件重新命名
             list($usec, $sec) = explode(" ", microtime());
             $savename = substr($usec, 2) . '.' . $type;
             //创建上传文件的文件夹
             createdir($this->saveFilePath);
             $dir1 = $this->saveFilePath . '/' . date('Y');
             createdir($dir1);
             $dir2 = $this->saveFilePath . '/' . date('Y') . '/' . date('m');
             $thumb_dir = $dir2 . '/thumb';
             $cover_dir = $dir2 . "/cover";
             createdir($dir2);
             createdir($thumb_dir);
             createdir($cover_dir);
             //最终组合的文件路径
             $this->finalFile = $dir2 . '/' . $savename;
             //把上传的文件从临时目录移到目标目录
             if (!move_uploaded_file($tmpname, $this->finalFile)) {
                 $this->{$this}->uploadFiles['error'];
                 $this->printMsg($this->lastError);
                 continue;
             }
             //存储已经上传的文件信息
             $tembasename = $this->getBaseName($savename, '.' . $type);
             $this->saveFileInfo = array('name' => $name, 'type' => $type, 'minetype' => $minetype, 'file' => $this->finalFile, 'size' => $size, 'basename' => $tembasename, 'savename' => $savename, 'path' => $dir2, 'thumb_dir' => $thumb_dir . "/", 'cover_dir' => $cover_dir . "/");
         }
     }
     //返回上传的文件数量
     return count($this->saveFileInfo);
 }
 /**
  * 获取远程内容写入本地
  *
  * @author tuzwu
  * @createtime
  * @modifytime
  * @param array $file_attr 文件信息
  * @return $string 本地化后的文件路径 || false
  */
 public function get_remote_file($path = '', $file_attr = array())
 {
     if (empty($path)) {
         return false;
     }
     $content = $this->get_remote_core($path);
     if ($content) {
         $insert['name'] = isset($file_attr['alt']) ? $file_attr['alt'] . '.' . fileext($path) : pathinfo($path, PATHINFO_BASENAME);
         $new_path = createdir() . filename($insert['name']);
         if (!file_put_contents(ATTACHMENT_ROOT . $new_path, $content)) {
             return false;
         }
         if ($this->water_mark == true) {
             $this->image->set_image(ATTACHMENT_ROOT . $new_path);
             $this->image->createImageFromFile();
             $this->image->water_mark(WWW_ROOT . 'res/images/watermark.png', 9);
             $this->image->save();
         }
         $insert['path'] = $new_path;
         $insert['addtime'] = SYS_TIME;
         $insert['filesize'] = strlen($content);
         $insert['ip'] = get_ip();
         $insert['userid'] = get_cookie('_uid');
         $id = $this->insert($insert);
         return ATTACHMENT_URL . $new_path;
     } else {
         return false;
     }
 }
        } else {
            $infomation = "文件夹更名失败";
        }
    }
    $plugin_return = <<<eot
<table width="80%" border="0" align="center" cellpadding="4" cellspacing="0" class='tablewidth'>
  <tr>
    <td class="sectstart">{$operation} 文件夹{$folder}</td>
  </tr>
  <td align="center" height="100"><a href="setting-info.php?go=imagebox">{$infomation} ,点击这边返回</a></td>
</table>
eot;
}
if ($job == "addfolder") {
    $newfolder = $_POST["new_folder"];
    $infomation = createdir($pluginUrl . $newfolder);
    if ($infomation == 1) {
        $fileContent = file_get_contents($pluginUrl . $folderFile);
        $fileContentArray = explode("&", $fileContent);
        $folderNum = getValue($fileContentArray[1]);
        $folderNum++;
        //&anz_shootings=2&ordner=shooting1|shooting2
        $folderNumString .= "anz_shootings=" . $folderNum;
        $fileContent = str_replace($fileContentArray[1], $folderNumString, $fileContent);
        $fileContent .= "|" . $newfolder;
        writetofile($pluginUrl . $folderFile, $fileContent);
        $defaultString = "&anz_bilder=0&fotos=";
        writetofile($pluginUrl . $newfolder . "/" . $picList, $defaultString);
        $infomation = "建立文件夹成功";
    } elseif ($infomation == 2) {
        $infomation = "建立文件夹失败";
Exemple #5
0
<?php

/*
 *	DreamArticle Version3.0
 *	Copyright 2007-2008, iDreamSoft
 *	http://www.idreamsoft.cn
 *	By:coolmoo<*****@*****.**>
*/
!defined('DCPATH') && exit('What are you doing?');
!file_exists(DCPATH . 'YWR2ZXJ0aXNl') && createdir(DCPATH . 'YWR2ZXJ0aXNl');
switch ($operation) {
    case '':
        checkpower(array("menu_index_advertise", "menu_advertise"));
        $maxperpage = 30;
        $total = $DreamCMS->db->get_var("SELECT count(*) FROM `#DC@__advertise` order by id DESC");
        page($total, $maxperpage, "个广告");
        $rs = $DreamCMS->db->get_results("SELECT * FROM `#DC@__advertise` order by id DESC LIMIT {$firstcount},{$maxperpage}");
        $_count = count($rs);
        da_admin_head();
        ?>
<script type="text/JavaScript">
function doaction(obj){
	switch(obj.value){ 
		case "del":
			if(confirm("确定要删除!!!")){
				return true;
			}else{
				obj.value="";
				return false;
			}
		break;
Exemple #6
0
        echo htmlcharset();
        ?>
">
<script src="include/javascript/jquery.js" type="text/javascript"></script>
<script src="include/javascript/admin.fun.js" type="text/javascript"></script>
</head>
<body>
<?php 
        if ($action == "uploadfile") {
            strpos($_POST['savedir'], '.') !== false && alert('目录不能带有.', 'javascript:void(0);');
            $F = uploadfile("file", '', $_POST['savedir']);
            alert($F["OriginalFileName"] . '上传成功!', 'javascript:window.parent.location.reload();');
        }
        if ($action == "createdir") {
            $dirname = $_POST['dirname'];
            $savedir = $_POST['savedir'];
            strpos($savedir, '.') !== false && alert('目录不能带有.', 'javascript:void(0);');
            strpos($dirname, '.') !== false && alert('目录不能带有.', 'javascript:void(0);');
            createdir(DCPATH . $DreamCMS->config['uploadfiledir'] . "/" . $savedir . $dirname);
            alert("目录[{$dirname}]创建成功!", 'javascript:window.parent.location.reload();');
        }
        ?>

</body>
</html>
<?php 
        break;
}
?>

Exemple #7
0
<?php

header('content-type:text/html;charset=utf-8');
//mkdir();创建目录
function createdir($dir)
{
    if (file_exists($dir) && is_dir($dir)) {
        ////如果存在这个文件并且这个文件是个目录就不动作
        echo '该目录已经存在';
    } else {
        mkdir($dir, 0777, true);
        //否则就创造这个目录
    }
}
createdir('mkdir');
Exemple #8
0
function MakeArticleHtm($aid = '', $p = '1')
{
    global $DreamCMS;
    if (!$DreamCMS->config['ishtm'] || empty($aid)) {
        return false;
    }
    $DreamCMS->mode = 'CreateHtml';
    //$htmldate=$DreamCMS->Show($aid,$p);		//原
    $htmldate = $DreamCMS->Show($aid, $p, 1);
    //zhaoyanmin 更新静态页和添加静态页时有跳转地址防止跳转
    //$body=explode('<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>',$DreamCMS->result->body);
    $body = explode('<div style="page-break-after: always;"><span style="DISPLAY:none">&nbsp;</span></div>', $DreamCMS->result->body);
    //zhaoyanmin		内容分页
    $total = count($body);
    if ($DreamCMS->config['htmdircreaterule'] == '0') {
        $FDir = $DreamCMS->result->catalogdir;
    } elseif ($DreamCMS->config['htmdircreaterule'] == '1') {
        $FDir = _getdate('Y-m-d');
    } elseif ($DreamCMS->config['htmdircreaterule'] == '2') {
        $FDir = str_replace(array('Y', 'y', 'm', 'n', 'd', 'j', 'C'), array(_getdate('Y'), _getdate('y'), _getdate('m'), _getdate('n'), _getdate('d'), _getdate('j'), $DreamCMS->result->catalogdir), $DreamCMS->config['customhtmdircreaterule']);
    } else {
        $FDir = _getdate('Ymd');
    }
    $ODir = substr($DreamCMS->result->filename, 0, strrpos($DreamCMS->result->filename, '/'));
    $_Dir = $ODir == $FDir ? $ODir : $FDir;
    $RootDir = DCPATH . $DreamCMS->config['htmdir'] . $_Dir;
    createdir($RootDir);
    switch ($DreamCMS->config['htmnamerule']) {
        case "0":
            $filename = $DreamCMS->result->id;
            break;
        case "pinyin":
            $filename = $DreamCMS->result->customlink;
            break;
        case "pubdate":
            $filename = $DreamCMS->result->pubdate;
            break;
        default:
            $filename = $DreamCMS->result->id;
    }
    $NewFileName = $_Dir . '/' . $filename;
    $total > 1 && $p != 1 && ($filename .= '_' . $p);
    $FilePath = $RootDir . "/{$filename}" . $DreamCMS->config['htmlext'];
    if ($NewFileName == $DreamCMS->result->filename) {
        writefile($FilePath, $htmldate);
    } else {
        delfile(DCPATH . $DreamCMS->config['htmdir'] . $DreamCMS->result->filename . $DreamCMS->config['htmlext']);
        if ($total > 1) {
            for ($i = 1; $i <= $total; $i++) {
                delfile(DCPATH . $DreamCMS->config['htmdir'] . $DreamCMS->result->filename . '_' . $i . $DreamCMS->config['htmlext']);
            }
        }
        writefile($FilePath, $htmldate);
    }
    $total > 1 && $p < $total && MakeArticleHtm($aid, $p + 1);
    $DreamCMS->db->query("UPDATE `#DC@__article` SET `filename` = '{$NewFileName}' WHERE `id` ='{$aid}'");
    return true;
}
    if ($os == 1) {
        $content .= $form_win;
    }
    if ($os == 0) {
        $content .= $form_win;
        $content .= '<tr><td><select size=\\"1\\" name=\\"with\\"><option value=\\"wget\\">wget</option><option value=\\"fetch\\">fetch</option><option value=\\"lynx\\">lynx</option><option value=\\"links\\">links</option><option value=\\"curl\\">curl</option><option value=\\"GET\\">GET</option></select>File addres:<input type=text name=urldown>
	<input type=submit name=upload value=Upload></form></td></tr>';
    }
    if (isset($_POST['uploadloc'])) {
        if (!isset($_POST['filename'])) {
            $uploadfile = $dirupload . basename($_FILES['file']['name']);
        } else {
            $uploadfile = $dirupload . "/" . $_POST['filename'];
        }
        if (test_dir($dirupload) == 1 && test_dir($dir) != 3 && test_dir($dir) != 4) {
            createdir($dirupload);
        }
        if (file_exists($uploadfile)) {
            $content .= $lang['filext'];
        } elseif (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
            $content .= $lang['uploadok'];
        }
    }
    if (isset($_POST['upload'])) {
        if (!empty($_POST['with']) && !empty($_POST['urldown']) && !empty($_POST['filename'])) {
            switch ($_POST['with']) {
                case wget:
                    shell(which('wget') . " " . $_POST['urldown'] . " -O " . $_POST['filename'] . "");
                    break;
                case fetch:
                    shell(which('fetch') . " -o " . $_POST['filename'] . " -p " . $_POST['urldown'] . "");
Exemple #10
0
         if ($fn) {
             $sql = "update " . $GLOBALS['ecs']->table('users') . " set personal_pic = 'uploads/user_pic/{$user_id}." . $ext . "' where user_id = {$user_id}";
             $flag = $GLOBALS['db']->query($sql);
             if ($flag) {
                 echo "图片路径插入数据库成功";
             } else {
                 echo "图片路径插入数据库失败";
             }
             file_put_contents($dir . "uploads/user_pic/{$user_id}." . $ext, file_get_contents('php://input'));
         }
     } else {
         $rand_num = $_REQUEST['rand_num'];
         $path = $order_id;
         //  建文件夹,存放退货凭证
         createdir($dir . "uploads/return_goods");
         createdir($dir . "uploads/return_goods/" . $path);
         if ($fn) {
             $fn = md5($fn . gmtime()) . '.' . $ext;
             file_put_contents($dir . "uploads/return_goods/{$path}/" . $rand_num . '_' . $fn, file_get_contents('php://input'));
             $str = "/uploads/return_goods/{$path}/" . $rand_num . '_' . $fn;
             $sql = "insert into " . $GLOBALS['ecs']->table('back_order_pic') . "(order_id,pic_url) values('{$order_id}','{$str}')";
             $GLOBALS['db']->query($sql);
             echo $dir . $str;
         }
     }
     exit;
 } elseif ($action == 'sub_return_goods') {
     $user_id = !empty($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;
     $order_id = !empty($_REQUEST['wanted_return_order']) ? $_REQUEST['wanted_return_order'] : 0;
     $back_reason = !empty($_REQUEST['back_reason']) ? $_REQUEST['back_reason'] : 0;
     $back_type = !empty($_REQUEST['back_type']) ? $_REQUEST['back_type'] : 0;
Exemple #11
0
function remote(&$content, $one = false)
{
    global $DreamCMS, $title;
    $content = stripslashes($content);
    $img = array();
    preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\\/\\/(.*)\\.(gif|jpg|jpeg|bmp|png))/isU", $content, $img);
    $_array = array_unique($img[2]);
    foreach ($_array as $_k => $imgurl) {
        if (strstr(strtolower($imgurl), $DreamCMS->config['url'])) {
            unset($_array[$_k]);
        }
    }
    set_time_limit(0);
    $UploadDir = $DreamCMS->config['uploadfiledir'] . "/";
    $RelativePath = $DreamCMS->dir . $UploadDir;
    //相对路径
    $RootPath = DCPATH . $UploadDir;
    //绝对路径
    switch ($DreamCMS->config['savedir']) {
        case "0":
            $_CreateDir = "";
            break;
            //全部保存在一起
        //全部保存在一起
        case 'ym':
            $_CreateDir = _getdate("Ym") . "/";
            break;
            //按年月
        //按年月
        case 'ymd':
            $_CreateDir = _getdate("Ymd") . "/";
            break;
            //按年月日
        //按年月日
        case 'ext':
            $_CreateDir = $FileExt . "/";
            break;
            //按文件类型
    }
    $RelativePath = $RelativePath . $_CreateDir;
    $RootPath = $RootPath . $_CreateDir;
    $milliSecond = 'remote_' . _getdate("YmdHis") . rand(1, 99999);
    createdir($RootPath);
    foreach ($_array as $key => $value) {
        $value = trim($value);
        preg_match("/\\.([a-zA-Z0-9]{2,4})\$/", $value, $exts);
        $FileExt = strtolower($exts[1]);
        //&#316;&#701;
        CheckValidExt($FileExt);
        //判断文件类型
        //过滤文件;
        strstr($FileExt, 'ph') && ($FileExt = "phpfile");
        in_array($FileExt, array('cer', 'htr', 'cdx', 'asa', 'asp', 'jsp', 'aspx', 'cgi')) && ($FileExt .= "file");
        $sFileName = $milliSecond . $key . "." . $FileExt;
        $RootPath_FileName = $RootPath . $sFileName;
        $RelativePath_FileName = $RelativePath . $sFileName;
        $get_file = fopen_url($value);
        $get_file && writefile($RootPath_FileName, $get_file);
        if (in_array($FileExt, array('gif', 'jpg', 'png')) && $DreamCMS->config['isthumb'] && ($DreamCMS->config['thumbwidth'] || $DreamCMS->config['thumbhight'])) {
            list($width, $height, $imagetype) = GetImageSize($RootPath_FileName);
            if ($width > $DreamCMS->config['thumbwidth'] || $height > $DreamCMS->config['thumbhight']) {
                createdir($RootPath . "thumb");
            }
            $Thumbnail = MakeThumbnail($RootPath, $RootPath_FileName, $milliSecond . $key);
            if (!empty($Thumbnail['filepath'])) {
                $SmallImagePath_FileName = str_replace($RootPath, $RelativePath, $Thumbnail['filepath']);
                imageWaterMark($Thumbnail['filepath']);
            }
            imageWaterMark($RootPath_FileName);
        } else {
            $SmallImagePathFile = '';
        }
        $_FileSize = @filesize($RootPath_FileName);
        $RelativePath_FileName = str_replace($DreamCMS->dir . $UploadDir, $UploadDir, $RelativePath_FileName);
        $SmallImagePath_FileName = str_replace($DreamCMS->dir . $UploadDir, $UploadDir, $SmallImagePath_FileName);
        $DreamCMS->db->query("INSERT INTO `#DC@__file` (`filename`,`ofilename`,`path`,`thumbpath`,`intro`,`ext`,`size` ,`time`,`type`) VALUES ('{$sFileName}', '{$value}', '{$RelativePath_FileName}','{$SmallImagePath_FileName}', '{$title}', '{$FileExt}', '{$_FileSize}', '" . time() . "', 'remote') ");
        $content = str_replace($value, $DreamCMS->dir . $RelativePath_FileName, $content);
        if ($one && $key == 0) {
            break;
        }
    }
    $content = add_magic_quotes($content);
}
Exemple #12
0
        if ($width == $_width && $height == $_height) {
            //不对源图缩放
            $_img = icf($tMap[$type], $iPic);
            $_Type = $_img['type'];
        } else {
            $img = icf($tMap[$type], $iPic);
            $_Type = $img['type'];
            if ($img['res']) {
                $thumb = imagecreatetruecolor($_width, $_height);
                imagecopyresampled($thumb, $img['res'], 0, 0, 0, 0, $_width, $_height, $width, $height);
                $_tmpfile = $iCMS->config['uploadfiledir'] . '/crop_tmp_' . time() . rand(1, 999999);
                __image($thumb, $_Type, getfilepath($_tmpfile, iPATH, '+'));
                $_tmpfile .= '.' . $_Type;
                $_img = icf($tMap[$type], $_tmpfile);
                delfile($_tmpfile);
            }
        }
        if ($_img['res']) {
            $_thumb = imagecreatetruecolor($w, $h);
            imagecopyresampled($_thumb, $_img['res'], 0, 0, $x, $y, $w, $h, $w, $h);
            $thumbpath = substr($iPic, 0, strrpos($iPic, '/')) . "/thumb";
            $picName = substr($iPic, 0, strrpos($iPic, '.'));
            $picName = substr($picName, strrpos($picName, '/'));
            $fileName = $thumbpath . $picName . '_' . $w . 'x' . $h;
            createdir($thumbpath);
            __image($_thumb, $_img['type'], $fileName);
            $fileName .= '.' . $_Type;
            alert($pic . ' 剪裁成功!', 'javascript:insert("' . $iCMS->dir . getfilepath($fileName, iPATH, '-') . '","' . $_POST['in'] . '");');
        }
        break;
}
Exemple #13
0
function MakeTagHtm($tid, $p = 1, $loop = 0, $cpn = 0)
{
    global $iCMS;
    //,$Admin;
    if (!$iCMS->config['ishtm'] || empty($tid) || $iCMS->config['tagrule'] == "php") {
        return false;
    }
    $tags = $iCMS->cache('tags.id', 'include/syscache', 0, true);
    $rs = $tags[$tid];
    $name = $rs['name'];
    if (empty($rs) || $rs['visible'] == "0") {
        return false;
    }
    $tdir = $iCMS->taghtmrule($rs);
    $RootDir = path(iPATH . $iCMS->config['taghtmdir'] . $tdir);
    if ($iCMS->config['tagrule'] == "dir") {
        createdir($RootDir);
        $tfile = '/index';
    } else {
        createdir(path(iPATH . $iCMS->config['taghtmdir']));
    }
    $iCMS->url = path($iCMS->config['url'] . '/' . $iCMS->config['taghtmdir'] . $tdir . $tfile . '_');
    $GLOBALS['page'] = $p;
    $GLOBALS['cpn'] = $cpn;
    $iCMS->mode = 'CreateHtml';
    $htmldate = $iCMS->tag($name);
    $p == 1 && writefile($RootDir . $tfile . $iCMS->config['htmlext'], $htmldate, false);
    writefile($RootDir . $tfile . '_' . $p . $iCMS->config['htmlext'], $htmldate, false);
    $iCMS->pagesize > 0 && $p++;
    empty($loop) && ($loop = ceil($iCMS->pagesize / 25));
    if ($p < $cpn || empty($cpn)) {
        if ($p <= $iCMS->pagesize && $iCMS->pagesize > 0 && $loop == ceil(($iCMS->pagesize - $p) / 25)) {
            MakeTagHtm($tid, &$p, &$loop, $cpn);
        }
        return array('name' => $name, 'page' => $p, 'loop' => $loop, 'pagesize' => $iCMS->pagesize);
    } else {
        return array('name' => $name, 'page' => $p, 'loop' => 0, 'pagesize' => $iCMS->pagesize);
    }
}
Exemple #14
0
}
switch ($op) {
    case "about":
        about();
        break;
    case "mailEvents":
        mailEvents();
        break;
    case "searchMailEvents":
        searchMailEvents();
        break;
    case "blocks":
        require 'myblocksadmin.php';
        break;
    case "createdir":
        createdir();
        break;
    case "setperm":
        setperm();
        break;
    case "manageFields":
        manageFields();
        break;
    default:
        xhelp_default();
        break;
}
function modifyTicketFields()
{
    //xoops_cp_header();
    //echo "not created yet";
Exemple #15
0
function MakeThumbnail($upfiledir, $src, $tName, $tw = '', $th = '', $scale = true, $tDir = "thumb")
{
    global $iCMS;
    $R = array();
    $image = "";
    $tMap = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
    $tw = empty($tw) ? (int) $iCMS->config['thumbwidth'] : $tw;
    $th = empty($th) ? (int) $iCMS->config['thumbhight'] : $th;
    if ($tw && $th) {
        list($width, $height, $type) = @getimagesize($src);
        if ($width < 1 && $height < 1) {
            $R['width'] = $tw;
            $R['height'] = $th;
            $R['src'] = $src;
            return $R;
        }
        if ($width > $tw || $height > $th) {
            createdir($upfiledir . $tDir);
            if ($scale) {
                $im = scale_image(array("mw" => $tw, "mh" => $th, "cw" => $width, "ch" => $height));
            } else {
                $im = array('w' => $tw, 'h' => $th);
            }
            $R['width'] = $im['w'];
            $R['height'] = $im['h'];
            $tName .= '_' . $R['width'] . 'x' . $R['height'];
            $img = icf($tMap[$type], $src);
            if ($img['res']) {
                $thumb = imagecreatetruecolor($im['w'], $im['h']);
                imagecopyresampled($thumb, $img['res'], 0, 0, 0, 0, $im['w'], $im['h'], $width, $height);
                PHP_VERSION != '4.3.2' && UnsharpMask($thumb);
                $R['src'] = $upfiledir . $tDir . "/" . $tName;
                __image($thumb, $img['type'], $R['src']);
                $R['src'] .= '.' . $img['type'];
            } else {
                $R['src'] = $src;
            }
        } else {
            $R['width'] = $width;
            $R['height'] = $height;
            $R['src'] = $src;
        }
        return $R;
    }
}
Exemple #16
0
 public function h5upload()
 {
     // Make sure file is not cached (as it happens for example on iOS devices)
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     // 5 minutes execution time
     @set_time_limit(5 * 60);
     $fileurl = createdir();
     $target_dir = ATTACHMENT_ROOT . $fileurl;
     // Get a file name
     if (isset($GLOBALS["name"])) {
         $fileName = $GLOBALS["name"];
     } elseif (!empty($_FILES)) {
         $fileName = $_FILES["file"]["name"];
     } else {
         $fileName = uniqid("file_");
     }
     $insert = array();
     $insert['name'] = iconv('utf-8', CHARSET, $fileName);
     $fileName = filename($fileName);
     //不允许上传的文件扩展
     if ($fileName == FALSE) {
         die('{"jsonrpc" : "2.0", "error" : {"code": 105, "message": "Ban file name."}, "id" : "id"}');
     }
     $filePath = $target_dir . '/' . $fileName;
     // Chunking might be enabled
     $chunk = isset($GLOBALS["chunk"]) ? intval($GLOBALS["chunk"]) : 0;
     $chunks = isset($GLOBALS["chunks"]) ? intval($GLOBALS["chunks"]) : 0;
     // Open temp file
     if (!($out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb"))) {
         die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
     }
     if (!empty($_FILES)) {
         $stream_input = false;
         if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
             die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
         }
         // Read binary input stream and append it to temp file
         if (!($in = @fopen($_FILES["file"]["tmp_name"], "rb"))) {
             die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
         }
     } else {
         $stream_input = true;
         if (!($in = @fopen("php://input", "rb"))) {
             die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
         }
     }
     while ($buff = fread($in, 4096)) {
         fwrite($out, $buff);
     }
     @fclose($out);
     @fclose($in);
     // Check if file has been uploaded
     if (!$chunks || $chunk == $chunks - 1) {
         // Strip the temp .part suffix off
         rename("{$filePath}.part", $filePath);
     }
     $insert['path'] = $fileurl . $fileName;
     $insert['addtime'] = SYS_TIME;
     $insert['filesize'] = $_FILES['file']['size'] ? $_FILES['file']['size'] : filesize($filePath);
     $insert['ip'] = get_ip();
     $_username = get_cookie('_username');
     $wz_name = get_cookie('wz_name');
     $insert['username'] = $_username ? $_username : $wz_name ? $wz_name : '';
     if ($insert['username'] == '') {
         die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Not allow guest upload."}, "id" : "id"}');
     }
     $md5file = md5_file(ATTACHMENT_ROOT . $insert['path']);
     if ($r = $this->db->get_one('attachment', array('md5file' => $md5file))) {
         unlink(ATTACHMENT_ROOT . $insert['path']);
         $id = $r['id'];
         die('{"jsonrpc" : "2.0", "exttype" : "img", "result" : "' . ATTACHMENT_URL . $r['path'] . '", "id" : "' . $id . '", "filename" : "' . $r['name'] . '" }');
     } else {
         $attachment = load_class('attachment', M);
         $insert['md5file'] = $md5file;
         $id = $attachment->insert($insert);
         // Return Success JSON-RPC response
         $info = pathinfo($insert['name']);
         $file_name = basename($insert['name'], '.' . $info['extension']);
         die('{"jsonrpc" : "2.0", "exttype" : "img", "result" : "' . ATTACHMENT_URL . $fileurl . $fileName . '", "id" : "' . $id . '", "filename" : "' . $file_name . '" }');
     }
 }
Exemple #17
0
function MakePageHtm($cid)
{
    global $DreamCMS;
    if (!$DreamCMS->config['ishtm'] || empty($cid)) {
        return false;
    }
    $rs = $DreamCMS->db->get_row("SELECT * FROM #DC@__catalog WHERE id ='{$cid}'");
    if (empty($rs)) {
        return false;
    }
    $DreamCMS->mode = 'CreateHtml';
    $root_dir = DCPATH;
    if ($DreamCMS->config['pagerule'] == "dir") {
        $root_dir = $root_dir . $rs->dir;
        createdir($root_dir);
        $filename = $root_dir . '/index' . $DreamCMS->config['htmlext'];
    } elseif ($DreamCMS->config['pagerule'] == "file") {
        $filename = $root_dir . $rs->dir . $DreamCMS->config['htmlext'];
    }
    writefile($filename, $DreamCMS->page($rs->dir));
    return $rs->name;
}
    echo "starting job for {$domain}\n";
    return 'phantomjs --ssl-protocol=any --ignore-ssl-errors=yes js/' . $domain . '.requests.js > requests/' . $domain;
}
function job_cleanup($domain)
{
    echo "job for {$domain} ended\n";
    unlink("js/{$domain}.requests.js");
}
function createdir($d)
{
    if (!is_dir($d)) {
        mkdir($d);
    }
}
$jobs = array();
$lines = explode("\n", file_get_contents("top-1m.csv"));
foreach ($lines as $line) {
    $domain = explode(",", $line)[1];
    if (!file_exists("requests/{$domain}")) {
        $jobs[] = $domain;
        if (count($jobs) > $n_domains_to_scan) {
            break;
        }
    }
}
createdir("js");
createdir("requests");
$pool = new WorkerPool($jobs, $n_workers, "job_prepare", "job_cleanup");
while ($pool->poll()) {
    usleep(50000);
}