} $shop_id = isset($_REQUEST['shop_id']) && !empty($_REQUEST['shop_id']) ? trim($_REQUEST['shop_id']) : uniqid(); //$shop_id = '182400'; $name = $file['name']; $name_array = explode('.', $name); $file_ext = $name_array[count($name_array) - 1]; //$file_ext = end(explode('.', $name)); if (!in_array(strtolower($file_ext), array('jpg', 'gif', 'png', 'bmp', 'jpeg'))) { return_msg(array('status' => 'error', 'msg' => '上传的文件格式不正确')); } //$name = $shop_id . '_' . uniqid() . '_' . $name; $name = $shop_id . '_' . uniqid() . '_' . time() . '.' . $file_ext; $upload_path = __DIR__ . '/upload/' . date('Ymd') . '/'; if (!is_dir($upload_path)) { @mkdir($upload_path, 0755, true); } $tmp_name = $file['tmp_name']; $full_path = '/upload/' . date('Ymd') . '/' . $name; move_uploaded_file($tmp_name, $upload_path . $name); //echo json_encode(array('status' => 'success', 'msg'=>$file_name, 'phones' => $phones)); $return = array('status' => 'success', 'data' => array('url' => $full_path)); return_msg($return); } else { return_msg(array('status' => 'error', 'msg' => '上传文件大小不能为零!')); } function return_msg($msg = array()) { header('Content-type: text/json;'); echo json_encode($msg); exit; }
function exe($sql) { global $config; $db_prefix = $config['DB_PREFIX']; if (!@mysql_query($sql)) { echo mysql_error(); } if (preg_match('@CREATE TABLE `@', $sql)) { preg_match("@CREATE TABLE `{$db_prefix}(.*?)`@", $sql, $t); return_msg("{$t[1]} 表创建完毕..."); } }