function eqphp_autoload($lib_name) { $server_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $group = explode(',', config('group|info')); $rq_url = explode('/', trim($server_uri, '/')); $dir_first = array('a' => 'action', 'm' => 'model'); $dir_second = array('a' => $rq_url[0] . '/action', 'm' => $rq_url[0] . '/model'); $dir_arr = in_array($rq_url[0], $group) ? $dir_second : $dir_first; $dir_arr = array_merge($dir_arr, array('s' => 'server', 'p' => 'plugin')); $prefix = substr($lib_name, 0, strpos($lib_name, '_')); $dir_name = in_array($prefix, array_keys($dir_arr)) ? $dir_arr[$prefix] : 'class'; $execute_file = $dir_name . '/' . $lib_name . '.php'; if (strtolower($lib_name) == 'smarty') { $execute_file = 'data/smarty/Smarty.class.php'; } if (file_exists($execute_file)) { return include dc_root . $execute_file; } if ($prefix == 'a') { $tpl_file = dc_root . 'view/' . substr($lib_name, 2) . '.html'; if (file_exists($tpl_file)) { exit(include $tpl_file); } if ($execute_file != 'action/a_.php') { http::send(404, 0); http::out('404 Not Found'); } } if (strpos(strtolower($execute_file), 'smarty_internal_') === false) { echo "class [" . $lib_name . "] is error !<br>"; } }
protected static function register($plugins = array(), $smarty = null) { $type = null; foreach ($plugins as $plug) { $type = count($plug) > 2 ? $plug[2] : 'function'; if (count($plug) < 2 || !in_array($type, array('function', 'block', 'modifier'))) { http::out($plug); } self::reg($plug[0], $plug[1], $smarty, $type); } return true; }
static function upload() { $basic_css = '<link rel="stylesheet" type="text/css" href="' . dc_url_style . 'basic.css" />'; http::out($basic_css, true, false); $error = config('error', 'upload'); $user_id = 8; //session::get('id'); if (!$user_id) { http::out($error[301]); } $cf_type = config('self_type', 'upload'); $cf_dir = config('self_dir', 'upload'); $dir = post('up_dir', 'int'); if (!$dir) { http::out($error[302]); } $save_path = dc_file_file . $cf_dir[$dir]; if (!is_dir($save_path)) { http::out($error[304]); } //动态创建上传目录 $auto_create_dir = ''; //date('Y_m').'/' // $save_path.=$auto_create_dir; // if (!file_exists($save_path)) mkdir($save_path); if (!is_writable($save_path)) { http::out($error[305]); } $up_info = self::get('file_name'); if ($up_info === null) { return http::out($error[303]); } if ($up_info === false) { http::out($error[306]); } $max_size = config('max_size|4', 'upload') * 1048576; if ($up_info['size'] > $max_size) { http::out($error[308]); } if ($up_info['error'] == 1) { http::out($error[309]); } if ($up_info['error'] == 2) { http::out($error[307]); } $ext_arr = array('pic' => explode(',', $cf_type['pic']), 'media' => explode(',', $cf_type['media']), 'doc' => explode(',', $cf_type['doc']), 'html' => explode(',', $cf_type['html']), 'zip' => explode(',', $cf_type['zip'])); $type = post('up_type', 'title'); if (!$type || !in_array($type, array_keys($ext_arr))) { http::out($error[304]); } if (!in_array(trim($up_info['type'], '.'), $ext_arr[$type])) { http::out($error[310]); } //$info_id=post('up_id','int'); //信息ID $file_name = $user_id . '_' . date("ymdHi") . '_' . rand(1000, 9999) . $up_info['type']; $file_path = $save_path . $file_name; if (!move_uploaded_file($up_info['name'], $file_path)) { http::out($error[311]); } chmod($file_path, 0644); //处理上传日志或入库逻辑 http::out(dc_url_file . $cf_dir[$dir] . $auto_create_dir . $file_name); }