function onquick_add() { $backReturn = array(); // 是否有主分类修改/添加权限updateQtype $hasAddQuickPrivilege = $_ENV['menu']->checkPermission($this->ask_login_name, $_SERVER['QUERY_STRING'], "updateQuick"); if ($hasAddQuickPrivilege['return']) { if (isset($this->post['submit_add'])) { $id = !empty($this->post['Id']) ? $this->post['Id'] : 0; if ($id) { $quicklinkInfo = $_ENV['quick']->GetQuicklink($id); $quicklinkInfo['LinkName'] = trim($this->post['LinkName']); $quicklinkInfo['Parent'] = intval($this->post['Parent']); $quicklinkInfo['LinkUrl'] = trim($this->post['LinkUrl']); $quicklinkInfo['LinkType'] = trim($this->post['LinkType']); if (!empty($_FILES['LinkIcon']['name'])) { @(require TIPASK_ROOT . '/api/FastDFSClient/FastDFSClient.php'); $FastDFSClient = new FastDFSClient(); $FastDFSClient->maxSize = 4194304; // 设置附件上传大小 默认为4M $FastDFSClient->allowExts = array('gif', 'jpg', 'jpeg', 'bmp', 'png'); // 设置附件上传类型 $FastDFSClient->savePath = TIPASK_ROOT . '/data/attach/' . gmdate('ym', $this->time) . '/'; // 设置附件上传目录 $FastDFSInfo = $FastDFSClient->upload("sk"); $quicklinkInfo['LinkIcon'] = $FastDFSInfo != -1 ? $FastDFSInfo : ''; } unset($quicklinkInfo['Id']); $update = $_ENV['quick']->updateQuicklink($id, $quicklinkInfo); $this->onquick("快捷链接修改成功!"); } else { $quicklinkInfo['LinkName'] = trim($this->post['LinkName']); $quicklinkInfo['Parent'] = intval($this->post['Parent']); $quicklinkInfo['LinkUrl'] = trim($this->post['LinkUrl']); $quicklinkInfo['LinkType'] = trim($this->post['LinkType']); if (!empty($_FILES['LinkIcon']['name'])) { @(require TIPASK_ROOT . '/api/FastDFSClient/FastDFSClient.php'); $FastDFSClient = new FastDFSClient(); $FastDFSClient->maxSize = 4194304; // 设置附件上传大小 默认为4M $FastDFSClient->allowExts = array('gif', 'jpg', 'jpeg', 'bmp', 'png'); // 设置附件上传类型 $FastDFSClient->savePath = TIPASK_ROOT . '/data/attach/' . gmdate('ym', $this->time) . '/'; // 设置附件上传目录 $FastDFSInfo = $FastDFSClient->upload("sk"); $quicklinkInfo['LinkIcon'] = $FastDFSInfo != -1 ? $FastDFSInfo : ''; } $update = $_ENV['quick']->insertQuicklink($quicklinkInfo); $this->onquick("快捷链接添加成功!"); } } } else { $hasAddQuickPrivilege['url'] = "?admin_quick/quick"; __msg($hasAddQuickPrivilege); } }
function onuploadimage() { //上传配置 $config = array("uploadPath" => "data/attach/", "fileType" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp"), "fileSize" => 500); //原始文件名,表单名固定,不可配置 $oriName = htmlspecialchars($this->post['fileName'], ENT_QUOTES); //上传图片框中的描述表单名称, $title = htmlspecialchars($this->post['pictitle'], ENT_QUOTES); //文件句柄 $file = $_FILES["upfile"]; //文件上传状态,当成功时返回SUCCESS,其余值将直接返回对应字符窜并显示在图片预览框,同时可以在前端页面通过回调函数获取对应字符窜 $state = "SUCCESS"; //格式验证 $current_type = strtolower(strrchr($file["name"], '.')); if (!in_array($current_type, $config['fileType'])) { $state = $current_type; } //大小验证 $file_size = 1024 * $config['fileSize']; if ($file["size"] > $file_size) { $state = "b"; } //保存图片 if ($state == "SUCCESS") { $targetfile = $config['uploadPath'] . gmdate('ym', $this->time) . '/' . random(8) . strrchr($file["name"], '.'); $result = $_ENV['attach']->movetmpfile($file, $targetfile); if (!$result) { $state = "c"; } else { @(require TIPASK_ROOT . '/api/FastDFSClient/FastDFSClient.php'); $FastDFSClient = new FastDFSClient(); $FastDFSInfo = $FastDFSClient->upload("sk", $targetfile); if ($FastDFSInfo == -1) { $state = "c"; } //$_ENV['attach']->add($file["name"], $current_type, $file["size"], $targetfile); } @unlink($targetfile); //fastDFS上传成功后删除服务器上的图片 } echo "{'url':'" . $FastDFSInfo . "','title':'" . $title . "','original':'" . $oriName . "','state':'" . $state . "'}"; }
function onhandle_attach_dt() { $hasHandleAnsweAttachDeletePrivilege = $_ENV['menu']->checkPermission($this->ask_login_name, $_SERVER['QUERY_STRING'], "handleAttachDelete"); !$hasHandleAnsweAttachDeletePrivilege['return'] && exit('3'); $id = isset($this->post['id']) ? intval($this->post['id']) : 0; $attach = isset($this->post['attach']) ? trim($this->post['attach']) : ''; if ($id != 0 && attach != '') { $questionInfo = array('attach' => ''); $_ENV['question']->updateQuestion($id, $questionInfo); require_once TIPASK_ROOT . '/api/FastDFSClient/FastDFSClient.php'; $FastDFSClient = new FastDFSClient(); $FastDFSClient->delete('sk', $attach); $this->sys_admin_log($id, $this->ask_login_name, $this->ask_login_name . '删除了问题附件', 12); //系统操作日志 exit('1'); } else { exit('0'); } }
function onqtype_add() { $backReturn = array(); // 是否有主分类修改/添加权限updateQtype $hasAddQtypePrivilege = $_ENV['menu']->checkPermission($this->ask_login_name, $_SERVER['QUERY_STRING'], "updateQtype"); if ($hasAddQtypePrivilege['return']) { if (isset($this->post['submit_add'])) { $id = !empty($this->post['id']) ? $this->post['id'] : 0; if ($id) { $qtypeInfo = $_ENV['qtype']->GetQType($id); $qtypeInfo['name'] = trim($this->post['name']); $qtypeInfo['complain_type_id'] = intval($this->post['complain_type_id']); $qtypeInfo['complain'] = unserialize($qtypeInfo['complain']); $qtypeInfo['complain']['manager_name'] = trim($this->post['complain']['manager_name']); //$qtypeInfo['complain']['icon'] = trim($this->post['complain']['icon']); $qtypeInfo['complain']['visiable'] = trim($this->post['complain']['visiable']); //$qtypeInfo['complain'] = serialize($qtypeInfo['complain']); $qtypeInfo['visiable'] = trim($this->post['visiable']); $qtypeInfo['pid'] = intval($this->post['pid']); $qtypeInfo['displayOrder'] = intval($this->post['displayOrder']); $qtypeInfo['faq'] = unserialize($qtypeInfo['faq']); $qtypeInfo['faq']['visiable'] = intval($this->post['faq']['visiable']); $qtypeInfo['faq'] = serialize($qtypeInfo['faq']); $qtypeInfo['trading'] = unserialize($qtypeInfo['trading']); $qtypeInfo['trading']['ServiceType'] = intval($this->post['trading']['ServiceType']); $qtypeInfo['trading']['sellingOrderUrl'] = trim($this->post['trading']['sellingOrderUrl']); $qtypeInfo['trading']['buyerOrderUrl'] = trim($this->post['trading']['buyerOrderUrl']); $qtypeInfo['trading']['sellerOrderUrl'] = trim($this->post['trading']['sellerOrderUrl']); $qtypeInfo['trading']['checkOrderUrl'] = trim($this->post['trading']['checkOrderUrl']); $qtypeInfo['trading']['directOrderUrl'] = trim($this->post['trading']['directOrderUrl']); $qtypeInfo['trading']['directPostOrderUrl'] = trim($this->post['trading']['directPostOrderUrl']); $qtypeInfo['trading'] = serialize($qtypeInfo['trading']); if (!empty($_FILES['managerphoto']['name'])) { @(require TIPASK_ROOT . '/api/FastDFSClient/FastDFSClient.php'); $FastDFSClient = new FastDFSClient(); $FastDFSClient->maxSize = 4194304; // 设置附件上传大小 默认为4M $FastDFSClient->allowExts = array('gif', 'jpg', 'jpeg', 'bmp', 'png'); // 设置附件上传类型 $FastDFSClient->savePath = TIPASK_ROOT . '/data/attach/' . gmdate('ym', $this->time) . '/'; // 设置附件上传目录 $FastDFSInfo = $FastDFSClient->upload("sk"); $qtypeInfo['complain']['icon'] = $FastDFSInfo != -1 ? $FastDFSInfo : ''; } $qtypeInfo['complain'] = serialize($qtypeInfo['complain']); unset($qtypeInfo['id']); $update = $_ENV['qtype']->updateQtype($id, $qtypeInfo); $qtypeList = $_ENV['qtype']->GetAllQType(1, "", 0); $this->cache->set('qtype_list', json_encode($qtypeList), 30 * 60); //缓存60秒 $this->onqtype("主分类修改成功!"); } else { $qtypeInfo['name'] = trim($this->post['name']); $qtypeInfo['complain_type_id'] = intval($this->post['complain_type_id']); $qtypeInfo['complain']['manager_name'] = trim($this->post['complain']['manager_name']); //$qtypeInfo['complain']['icon'] = trim($this->post['complain']['icon']); $qtypeInfo['complain']['visiable'] = trim($this->post['complain']['visiable']); //$qtypeInfo['complain'] = serialize($qtypeInfo['complain']); $qtypeInfo['visiable'] = trim($this->post['visiable']); $qtypeInfo['pid'] = intval($this->post['pid']); $qtypeInfo['displayOrder'] = intval($this->post['displayOrder']); $qtypeInfo['faq']['visiable'] = intval($this->post['faq']['visiable']); $qtypeInfo['faq'] = serialize($qtypeInfo['faq']); $qtypeInfo['trading']['ServiceType'] = intval($this->post['trading']['ServiceType']); $qtypeInfo['trading']['sellingOrderUrl'] = trim($this->post['trading']['sellingOrderUrl']); $qtypeInfo['trading']['buyerOrderUrl'] = trim($this->post['trading']['buyerOrderUrl']); $qtypeInfo['trading']['sellerOrderUrl'] = trim($this->post['trading']['sellerOrderUrl']); $qtypeInfo['trading']['checkOrderUrl'] = trim($this->post['trading']['checkOrderUrl']); $qtypeInfo['trading']['directOrderUrl'] = trim($this->post['trading']['directOrderUrl']); $qtypeInfo['trading']['directPostOrderUrl'] = trim($this->post['trading']['directPostOrderUrl']); $qtypeInfo['trading'] = serialize($qtypeInfo['trading']); if (!empty($_FILES['managerphoto']['name'])) { @(require TIPASK_ROOT . '/api/FastDFSClient/FastDFSClient.php'); $FastDFSClient = new FastDFSClient(); $FastDFSClient->maxSize = 4194304; // 设置附件上传大小 默认为4M $FastDFSClient->allowExts = array('gif', 'jpg', 'jpeg', 'bmp', 'png'); // 设置附件上传类型 $FastDFSClient->savePath = TIPASK_ROOT . '/data/attach/' . gmdate('ym', $this->time) . '/'; // 设置附件上传目录 $FastDFSInfo = $FastDFSClient->upload("sk"); } $qtypeInfo['complain']['icon'] = $FastDFSInfo != -1 ? $FastDFSInfo : ''; $qtypeInfo['complain'] = serialize($qtypeInfo['complain']); $insert = $_ENV['qtype']->insertQtype($qtypeInfo); $qtypeList = $_ENV['qtype']->GetAllQType(1, "", 0); $this->cache->set('qtype_list', json_encode($qtypeList), 30 * 60); //缓存60秒 $this->onqtype("主分类修改成功!"); } } } else { $hasAddQtypePrivilege['url'] = "?admin_qtype/qtype"; __msg($hasAddQtypePrivilege); } }
<?php //error_reporting(0); define('IN_TIPASK', TRUE); define('TIPASK_ROOT', substr(dirname(__FILE__), 0, -4)); date_default_timezone_set('Etc/GMT-8'); defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); @(require TIPASK_ROOT . '/api/FastDFSClient/FastDFSClient.php'); $FastDFSClient = new FastDFSClient(); $FastDFSClient->maxSize = 4194304; // 设置附件上传大小 默认为4M $FastDFSClient->allowExts = array('gif', 'jpg', 'jpeg', 'bmp', 'png'); // 设置附件上传类型 $FastDFSClient->savePath = TIPASK_ROOT . '/data/attach/' . gmdate('ym', time()) . '/'; // 设置附件上传目录 $FastDFSInfo = $FastDFSClient->upload("sk"); if ($FastDFSInfo != -1) { $arr = array("state" => 1, "small_pic" => $FastDFSInfo, "big_pic" => $FastDFSInfo); } else { $arr = array("state" => 0); } echo json_encode($arr);