public function __construct() { parent::__construct('wine_upload'); $this->CONF = $this->config->item('wine_upload'); $this->IMG_DIR = $this->CONF['upload_path'] . '/' . $this->CONF['root_path'] . '/'; $this->HOST = $this->CONF['host']; self::_mkAllDir($this->IMG_DIR); }
<?php $f3 = new BASE('base.php'); $f3->route('POST /auth/login', 'API->login'); $f3->route('POST /auth/login_facebook', 'API->login_facebook'); $f3->route('POST /auth/login_google', 'API->login_google'); $f3->route('POST /auth/register', 'API->register'); $f3->route('POST /auth/forgot-password', 'API->reserve_reset'); $f3->route('POST /auth/reset-password', 'API->reset_password'); $f3->route('POST /post/add', 'API->add_post'); $f3->route('POST /post/edit', 'API->edit_post'); $f3->route('POST /post/get-own', 'API->get_own_posts'); $f3->route('POST /post/get-all', 'API->get_all_posts'); $f3->route('POST /post/get-own-detail', 'API->get_own_post_detail'); $f3->route('POST /post/get-detail', 'API->get_post_detail'); $f3->route('POST /post/delete', 'API->delete_post'); $f3->route('POST /post/delete-from-match', 'API->delete_post_from_match'); $f3->route('POST /user/get-mine', 'API->get_my_profile'); $f3->route('POST /user/get', 'API->get_user_profile'); $f3->route('POST /user/rate', 'API->rate_user'); $f3->route('POST /user/upload-avatar', 'API->upload_avatar'); $f3->route('POST /user/upload-creci', 'API->upload_creci'); $f3->route('POST /user/send-phone', 'API->send_phone'); $f3->route('POST /user/verify-phone', 'API->verify_phone'); $f3->route('POST /user/request-email-verification', 'API->request_email_verification'); $f3->route('POST /user/verify-email', 'API->verify_email'); $f3->route('POST /user/images', 'API->user_images'); $f3->route('POST /user/ratings', 'API->get_user_ratings'); $f3->route('POST /user/rating/reply', 'API->reply_rating'); $f3->route('GET /admin/login', 'API->admin_login'); $f3->route('GET /admin/users', 'API->admin_get_users');
function __construct() { parent::__construct(); self::checkRequest(); }
function UpFile($InputName, $UpPath, $FileType, $Size = 2, $mark, $Back = '') { set_time_limit(0); /* $userupimgfile = 表单名 $upimgpath = 文件路径 $filetype = 文件上传类型 $size = 文件大小限止(K) $back = 返回类型,1为返回上页,0为停止执行。 */ $UID = $_SESSION['uid']; //1 为严格检查上传文件类型,2 判断文件后缀。 $UpFileType = 2; // if ($FileType == 'jpg,gif,png') { $UpFileType = 1; } //文件大小 $File_Size = $_FILES[$InputName]['size']; //文件类型 $File_Type = $_FILES[$InputName]['type']; //文件本地名称 $File_Name = $_FILES[$InputName]['name']; //成生文字类型数组 $FileType = explode(',', $FileType); //限文件大小,按字节 $UpFileSize = $Size * 1024 * 1024; //文件判断类型 if ($UpFileType == 1) { //严格判断 switch ($File_Type) { // OFFICE case "application/msword": $Type = 'doc'; break; case "application/vnd.ms-excel": $Type = 'xls'; break; case "application/vnd.ms-powerpoint": $Type = 'ppt'; break; //压缩 //压缩 case "application/octet-stream": $Type = 'rar'; break; //文本 //文本 case "text/plain": $Type = 'txt'; break; //图片 //图片 case "image/pjpeg": $Type = 'jpg'; break; case "image/jpg": $Type = 'jpg'; break; case "image/jpeg": $Type = 'jpg'; break; case "image/gif": $Type = 'gif'; break; case "image/x-png": $Type = 'png'; break; case "image/png": $Type = 'png'; break; case "image/bmp": $Type = 'bmp'; break; //错误类型 //错误类型 default: $Type = 'err'; } } else { //根据扩展名判断 $Type = strtolower(substr(strrchr($File_Name, "."), 1)); } //定义返回 if ($Back == 1) { $Back = "window.location.href=('javascript:history.back()')"; } //判断上传文件类型是否合法 if ($File_Size > 0) { //文件不为空 if (!in_array($Type, $FileType) || $Type == 'err') { echo "<script>alert('暂不支持此文件类型。');top.document.getElementById('submit').disabled=false;top.imgList.location.href=('?" . $_SERVER['QUERY_STRING'] . "');</script>"; exit; } } else { // 文件为空 $Type = 'err'; } //判断大小 if ($File_Size > $UpFileSize) { if ($mark == 'p') { echo "<script>alert('您的上传的文件不能大于" . $Size . "M。');window.location.href=('javascript:history.back()');parent.document.getElementById('submit').disabled=false</script>"; exit; } BASE::js_msg('您的上传的文件不能大于' . $Size . 'M。'); } //类型合法上传文件 if ($Type != 'err') { $FileTime = $UID . date('YmdHis'); @($UpFile = $UpPath . $mark . '_' . $FileTime . "." . $Type); //文件所放的路径 if (is_uploaded_file($_FILES[$InputName]['tmp_name'])) { if (!move_uploaded_file($_FILES[$InputName]['tmp_name'], $UpFile)) { return false; exit; } } else { return false; exit; } $UpFile = $mark . '_' . $FileTime . "." . $Type; //截路径 $File[0] = $UpFile; $File[1] = $File_Name; $File[2] = $File_Size; } else { $File = ''; } return $File; }
<?php /* * load base */ require_once CORE_PATH . '/BASE.php'; $base = new BASE(); /* * check if db is installed or not; if not, then install; */ $base->check_installation(); /* * escape all special charecters in URI */ $URI = explode("/", $_SERVER['REQUEST_URI']); unset($URI[0]); unset($URI[1]); $URI_VAL = ""; foreach ($URI as $k => $v) { if ($v != "" && strlen($v) > 0) { $uri_values[] = htmlspecialchars_decode($v); $URI_VAL .= "/" . htmlspecialchars_decode($v); } } /* * load base MVC */ require_once CORE_PATH . '/MVC.php'; /* * get route file */