Example #1
0
 public function uploadTplAction()
 {
     $zipFile = isset($_FILES['pluzip']) ? $_FILES['pluzip'] : '';
     $tmp_name = $zipFile["tmp_name"];
     $name = $zipFile["name"];
     $type = $zipFile["type"];
     $size = $zipFile["size"];
     $error = $zipFile["error"];
     if (getFileSuffix($zipFile['name']) != 'zip') {
         return '文件类型错误';
     }
     if (!$zipFile || $error >= 1 || empty($tmp_name)) {
         return '插件上传失败';
     }
     $ret = unZip($tmp_name, "/Content/Templates", "tpl");
     switch ($ret) {
         case -3:
             return JsonObject(array("error" => '上传错误:请先开启ZipArchive'));
             break;
         case -2:
             return JsonObject(array("error" => '上传错误:请检查模板文件完整性'));
             break;
         case 0:
             //更新记录
             $info = array();
             $templateModel = new templateModel();
             $data = file_get_contents(APP_TEMP_PATH . "/" . basename($name, ".zip") . "/info.log");
             $data = explode("\r\n", $data);
             foreach ($data as $v) {
                 $v = str_replace(":", ":", $v);
                 $infos = explode(":", $v);
                 if (in_array($infos[0], $templateModel::$infoKey)) {
                     $info[$infos[0]] = $infos[1];
                 }
             }
             $info['name'] = basename($name, ".zip");
             $r = $templateModel->addTpl($info);
             if ($r) {
                 return JsonObject(array("success" => '上传成功'));
             } else {
                 return JsonObject(array("error" => '请联系管理员'));
             }
             break;
         case 1:
             return JsonObject(array("error" => '上传成功,解压失败'));
             break;
         case 2:
             return JsonObject(array("error" => '打开模板压缩包失败'));
             break;
     }
 }
Example #2
0
    include View::getView('header');
    require_once View::getView('template_install');
    include View::getView('footer');
    View::output();
}
//上传zip模板
if ($action == 'upload_zip') {
    LoginAuth::checkToken();
    $zipfile = isset($_FILES['tplzip']) ? $_FILES['tplzip'] : '';
    if ($zipfile['error'] == 4) {
        emDirect("./template.php?action=install&error_d=1");
    }
    if (!$zipfile || $zipfile['error'] >= 1 || empty($zipfile['tmp_name'])) {
        emMsg('模板上传失败');
    }
    if (getFileSuffix($zipfile['name']) != 'zip') {
        emDirect("./template.php?action=install&error_a=1");
    }
    $ret = emUnZip($zipfile['tmp_name'], '../content/templates/', 'tpl');
    switch ($ret) {
        case 0:
            emDirect("./template.php?activate_install=1#tpllib");
            break;
        case -2:
            emDirect("./template.php?action=install&error_e=1");
            break;
        case 1:
        case 2:
            emDirect("./template.php?action=install&error_b=1");
            break;
        case 3:
Example #3
0
/**
 * @des 读取附件数据库 获取日志非图片类型附件 友好显示附件下载情况
 * @param logid
 * @return string 
 */
function blog_att($logid)
{
    if (!_g('show_attr')) {
        return '';
    }
    $DbModel = Database::getInstance();
    $sql = "SELECT filename,filesize,filepath FROM " . DB_PREFIX . "attachment WHERE blogid=" . $logid . " ORDER BY aid ASC";
    $res = $DbModel->query($sql);
    $attArr = array();
    while ($row = $DbModel->fetch_array($res)) {
        #过滤图片格式的附件
        if (in_array(getFileSuffix($row['filepath']), array('jpg', 'jpeg', 'bmp', 'gif', 'png', 'webp'))) {
            continue;
        }
        $row['size'] = format_bytes($row['filesize']);
        $row['filename'] = htmlspecialchars($row['filename']);
        $row['url'] = BLOG_URL . ltrim(ltrim($row['filepath'], '.'), '/');
        $attArr[] = $row;
    }
    if (!$attArr) {
        return '';
    }
    $fileType = array('rar' => 'fa fa-file-zip-o', 'zip' => 'fa fa-file-zip-o', 'gif' => 'fa fa-file-image-o', 'jpg' => 'fa fa-file-image-o', 'jpeg' => 'fa fa-file-image-o', 'png' => 'fa fa-file-image-o', 'txt' => 'fa fa-file-text-o', 'pdf' => 'fa fa-file-pdf-o', 'docx' => 'fa fa-file-word-o', 'doc' => 'fa fa-file-word-o', 'xls' => 'fa fa-file-excel-o', 'xlsx' => 'fa fa-file-excel-o', 'ppt' => 'fa fa-file-powerpoint-o', 'pptx' => 'fa fa-file-powerpoint-o', 'mp3' => 'fa fa-file-audio-o', 'mp4' => 'fa fa-file-video-o');
    $logAttstr = '<div class="article_att"><h3>附件下载:</h3><ol>';
    foreach ($attArr as $key => $value) {
        $fileSuffix = getFileSuffix($value['url']);
        $logAttstr .= '<li>';
        if ($fileType[$fileSuffix]) {
            $logAttstr .= '<i class="' . $fileType[$fileSuffix] . '"></i> ';
        } else {
            $logAttstr .= '<i class="fa fa-file"></i> ';
        }
        $logAttstr .= '<a href="' . $value['url'] . '" target=_blank>' . $value['filename'] . '</a> <em>' . $value['size'] . '</em></li>';
    }
    return $logAttstr .= '</ol></div>';
}
Example #4
0
            case -3:
                emDirect('./data.php?error_e=1');
                break;
            case 1:
            case 2:
                emDirect('./data.php?error_d=1');
                break;
            case 3:
                emDirect('./data.php?error_c=1');
                break;
        }
        $sqlfile['tmp_name'] = dirname($sqlfile['tmp_name']) . '/' . str_replace('.zip', '.sql', $sqlfile['name']);
        if (!file_exists($sqlfile['tmp_name'])) {
            emMsg('只能导入emlog备份的压缩包,且不能修改压缩包文件名!');
        }
    } elseif (getFileSuffix($sqlfile['name']) != 'sql') {
        emMsg('只能导入emlog备份的SQL文件');
    }
    checkSqlFileInfo($sqlfile['tmp_name']);
    bakindata($sqlfile['tmp_name']);
    $CACHE->updateCache();
    emDirect('./data.php?active_import=1');
}
if ($action == 'dell_all_bak') {
    if (!isset($_POST['bak'])) {
        emDirect('./data.php?error_a=1');
    } else {
        foreach ($_POST['bak'] as $val) {
            unlink($val);
        }
        emDirect('./data.php?active_del=1');
Example #5
0
 /**
  * 获取缓存模板路径
  * @param string $template_path 原始模板路径
  */
 private function getCacheTemplatePath($template_path)
 {
     $cache_template_path = str_replace(getFileSuffix($template_path), '.php', $template_path);
     $cache_template_path = str_replace('View', 'Cache/Template', $cache_template_path);
     return $cache_template_path;
 }
Example #6
0
File: module.php Project: jnan77/J2
/**
 * @des 获取日志附件 友好显示附件下载情况 
 * @param logid
 * @return string 
 */
function blog_att($logid)
{
    return '';
    //此方法已废除
    global $CACHE;
    $logatts = $CACHE->readCache('logatts');
    if (empty($logatts)) {
        return '';
    }
    if (empty($logatts[$logid])) {
        return '';
    }
    $attArr = $logatts[$logid];
    //文章所附带附件的数组信息 可能有多个附件
    $fileType = array('rar' => 'fa fa-file-zip-o', 'zip' => 'fa fa-file-zip-o', 'gif' => 'fa fa-file-image-o', 'jpg' => 'fa fa-file-image-o', 'jpeg' => 'fa fa-file-image-o', 'png' => 'fa fa-file-image-o', 'txt' => 'fa fa-file-text-o', 'pdf' => 'fa fa-file-pdf-o', 'docx' => 'fa fa-file-word-o', 'doc' => 'fa fa-file-word-o', 'xls' => 'fa fa-file-excel-o', 'xlsx' => 'fa fa-file-excel-o', 'ppt' => 'fa fa-file-powerpoint-o', 'pptx' => 'fa fa-file-powerpoint-o');
    $logAttstr = '<div class="article_att"><h3>附件下载:</h3><ol>';
    foreach ($attArr as $key => $value) {
        $fileSuffix = getFileSuffix($value['url']);
        $logAttstr .= '<li><a href="' . BLOG_URL . $value['url'] . '" target=_blank>';
        if ($fileType[$fileSuffix]) {
            $logAttstr .= '<i class="' . $fileType[$fileSuffix] . '"></i> ';
        } else {
            $logAttstr .= '<i class="fa fa-file"></i> ';
        }
        $logAttstr .= $value['filename'] . '</a> (文件体积: ' . $value['size'] . ')</li>';
    }
    return $logAttstr .= '</ol></div>';
}
Example #7
0
/**
 * 解压zip
 * @param type $zipfile 要解压的文件
 * @param type $path 解压到该目录
 * @param type $type
 * @return int
 */
function emUnZip($zipfile, $path, $type = 'tpl')
{
    if (!class_exists('ZipArchive', FALSE)) {
        return 3;
        //zip模块问题
    }
    $zip = new ZipArchive();
    if (@$zip->open($zipfile) !== TRUE) {
        return 2;
        //文件权限问题
    }
    $r = explode('/', $zip->getNameIndex(0), 2);
    $dir = isset($r[0]) ? $r[0] . '/' : '';
    switch ($type) {
        case 'tpl':
            $re = $zip->getFromName($dir . 'header.php');
            if (false === $re) {
                return -2;
            }
            break;
        case 'plugin':
            $plugin_name = substr($dir, 0, -1);
            $re = $zip->getFromName($dir . $plugin_name . '.php');
            if (false === $re) {
                return -1;
            }
            break;
        case 'backup':
            $sql_name = substr($dir, 0, -1);
            if (getFileSuffix($sql_name) != 'sql') {
                return -3;
            }
            break;
        case 'update':
            break;
    }
    if (true === @$zip->extractTo($path)) {
        $zip->close();
        return 0;
    } else {
        return 1;
        //文件权限问题
    }
}
Example #8
0
/**
 * @des 裁剪大图并缩略成220*150封面图
 * @param rdir 源图dir
 * @param cdir 裁剪后的封面图dir
 * @param width  源图width
 * @param height 源图height
 * @return boolean 
 */
function JcorpImage($rdir, $cdir, $width, $height)
{
    if (!is_file($rdir)) {
        return false;
    }
    #当源图不存在时没必要执行裁剪
    //计算拷贝原图的大小和坐标
    $rate = min($width / 220, $height / 150);
    $w = $rate * 220;
    $h = $rate * 150;
    //裁剪并缩略位置控制  模板设置可控制
    switch (_g('corp_pos')) {
        case '1':
            //方法1:从左上角开始裁剪并缩略
            $x = 0;
            $y = 0;
            break;
        case '2':
            //方法2:从右上角开始裁剪并缩略
            $x = $width - $w;
            $y = 0;
            break;
        case '3':
            //方法3:从左下角开始裁剪并缩略
            $x = 0;
            $y = $height - $h;
            break;
        case '4':
            //方法4:从左下角开始裁剪并缩略
            $x = $width - $w;
            $y = $height - $h;
            break;
        default:
            //默认:居中开始裁剪并缩略
            $x = ($width - $w) / 2;
            $y = ($height - $h) / 2;
            break;
    }
    if (function_exists('imagecreatefromstring')) {
        $source_image = imagecreatefromstring(file_get_contents($rdir));
    } else {
        switch (getFileSuffix($rdir)) {
            case 'gif':
                $source_image = imagecreatefromgif($rdir);
                break;
            case 'jpeg' || 'jpg':
                $source_image = imagecreatefromjpeg($rdir);
                break;
            case 'png':
                $source_image = imagecreatefrompng($rdir);
                break;
            default:
                return false;
                break;
        }
    }
    if (function_exists('imagecopyresampled')) {
        $target_image = imagecreatetruecolor(220, 150);
        $cropped_image = imagecreatetruecolor($w, $h);
        imagecopy($cropped_image, $source_image, 0, 0, $x, $y, $w, $h);
        imagecopyresampled($target_image, $cropped_image, 0, 0, 0, 0, 220, 150, $w, $h);
    } elseif (function_exists('imagecopyresized')) {
        $target_image = imagecreate(220, 150);
        $cropped_image = imagecreate($w, $h);
        imagecopy($cropped_image, $source_image, 0, 0, $x, $y, $w, $h);
        imagecopyresized($target_image, $cropped_image, 0, 0, 0, 0, 220, 150, $w, $h);
    } else {
        return false;
    }
    ImageDestroy($cropped_image);
    //销毁
    if (function_exists('imagejpeg') && imagejpeg($target_image, $cdir, 100)) {
        ImageDestroy($target_image);
        $status = true;
    } else {
        $status = false;
    }
    return $status;
}
Example #9
0
    $pageurl = pagination($usernum, Option::get('admin_perpage_num'), $page, "./vip.php?page=");
    include View::getView('header');
    require_once View::getView('vip');
    include View::getView('footer');
    View::output();
}
//上传excel
if ($action == 'upload') {
    $vipfile = isset($_FILES['vipfile']) ? $_FILES['vipfile'] : '';
    if ($vipfile['error'] == 4) {
        emDirect("./vip.php?error_d=1");
    }
    if (!$vipfile || $vipfile['error'] >= 1 || empty($vipfile['tmp_name'])) {
        emMsg('上传失败');
    }
    if (getFileSuffix($vipfile['name']) != 'xls') {
        emDirect("./vip.php?error_a=1");
    }
    set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
    /** PHPExcel_IOFactory */
    include 'PHPExcel/IOFactory.php';
    $inputFileName = $vipfile['tmp_name'];
    $objReader = new PHPExcel_Reader_Excel5();
    //        $objReader = new PHPExcel_Reader_Excel2007();
    //        $objReader = new PHPExcel_Reader_Excel2003XML();
    //        $objReader = new PHPExcel_Reader_OOCalc();
    //        $objReader = new PHPExcel_Reader_SYLK();
    //        $objReader = new PHPExcel_Reader_Gnumeric();
    //        $objReader = new PHPExcel_Reader_CSV();
    $objPHPExcel = $objReader->load($inputFileName);
    $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
Example #10
0
 public function view_aliAddNewShipTplSubmit()
 {
     $account = isset($_POST['aliaccount']) ? trim($_POST['aliaccount']) : FALSE;
     if (empty($account)) {
         $msgdata = array('data' => array('请指定账号!'), 'link' => 'index.php?mod=messageTemplate&act=aliShipingTemplate');
         goErrMsgPage($msgdata);
         exit;
     }
     if (!isset($_FILES['tpl'])) {
         $msgdata = array('data' => array('请上传模板文件!'), 'link' => 'index.php?mod=messageTemplate&act=aliShipingTemplate');
         goErrMsgPage($msgdata);
         exit;
     }
     if ($_FILES['tpl']['error'] != 0) {
         //文件上传出错
         $msgdata = array('data' => array('文件上传出错!'), 'link' => 'index.php?mod=messageTemplate&act=aliShipingTemplate');
         goErrMsgPage($msgdata);
         exit;
     }
     $fileSuffix = getFileSuffix($_FILES['tpl']['name']);
     if ($fileSuffix != '.zip') {
         $msgdata = array('data' => array('请上传zip格式文件!'), 'link' => 'index.php?mod=messageTemplate&act=aliShipingTemplate');
         goErrMsgPage($msgdata);
         exit;
     }
     $AliShipModel_obj = new AliShipTemplateModel();
     $storePath = $AliShipModel_obj->storeTplFile($_FILES['tpl']['tmp_name']);
     if (FALSE === $storePath) {
         //存储失败
         $msgdata = array('data' => array(AliShipTemplateModel::$errMsg), 'link' => 'index.php?mod=messageTemplate&act=aliShipingTemplate');
         goErrMsgPage($msgdata);
         exit;
     }
     $result = $AliShipModel_obj->insertRelationShip($account, $storePath, $_FILES['tpl']['name']);
     if (FALSE === $result) {
         $msgdata = array('data' => array('数据库操作错误!'), 'link' => 'index.php?mod=messageTemplate&act=aliShipingTemplate');
         goErrMsgPage($msgdata);
         exit;
     } else {
         $msgdata = array('data' => array('操作成功!'), 'link' => 'index.php?mod=messageTemplate&act=aliShipingTemplate');
         goOkMsgPage($msgdata);
         exit;
     }
 }