public function ACTION_register() { iCMS::$config['user']['register']['enable'] or exit(iPHP::lang('user:register:forbidden')); $regip = iS::escapeStr(iPHP::getIp()); $regdate = time(); if (iCMS::$config['user']['register']['interval']) { $ip_regdate = iDB::value("\n SELECT `regdate`\n FROM `#iCMS@__user`\n WHERE `regip`='{$regip}'\n ORDER BY uid DESC"); $ip_regdate - $regdate > iCMS::$config['user']['register']['interval'] && iPHP::code(0, 'user:register:interval', 'username', 'json'); } $username = iS::escapeStr($_POST['username']); $nickname = iS::escapeStr($_POST['nickname']); $gender = $_POST['gender'] == 'girl' ? 0 : 1; $password = md5(trim($_POST['password'])); $rstpassword = md5(trim($_POST['rstpassword'])); $refer = iS::escapeStr($_POST['refer']); $openid = iS::escapeStr($_POST['openid']); $type = iS::escapeStr($_POST['platform']); $avatar = iS::escapeStr($_POST['avatar']); $province = iS::escapeStr($_POST['province']); $city = iS::escapeStr($_POST['city']); $agreement = $_POST['agreement']; $username or iPHP::code(0, 'user:register:username:empty', 'username', 'json'); preg_match("/^[\\w\\-\\.]+@[\\w\\-]+(\\.\\w+)+\$/i", $username) or iPHP::code(0, 'user:register:username:error', 'username', 'json'); user::check($username, 'username') && iPHP::code(0, 'user:register:username:exist', 'username', 'json'); $nickname or iPHP::code(0, 'user:register:nickname:empty', 'nickname', 'json'); (cstrlen($nickname) > 20 || cstrlen($nickname) < 4) && iPHP::code(0, 'user:register:nickname:error', 'nickname', 'json'); user::check($nickname, 'nickname') && iPHP::code(0, 'user:register:nickname:exist', 'nickname', 'json'); trim($_POST['password']) or iPHP::code(0, 'user:password:empty', 'password', 'json'); trim($_POST['rstpassword']) or iPHP::code(0, 'user:password:rst_empty', 'rstpassword', 'json'); $password == $rstpassword or iPHP::code(0, 'user:password:unequal', 'password', 'json'); if (iCMS::$config['user']['register']['seccode']) { $seccode = iS::escapeStr($_POST['seccode']); iPHP::seccode($seccode, true) or iPHP::code(0, 'iCMS:seccode:error', 'seccode', 'json'); } $gid = 0; $pid = 0; $fans = $follow = $article = $comments = $share = $credit = 0; $hits = $hits_today = $hits_yday = $hits_week = $hits_month = 0; $lastloginip = $lastlogintime = ''; $status = 1; $fields = array('gid', 'pid', 'username', 'nickname', 'password', 'gender', 'fans', 'follow', 'article', 'comments', 'share', 'credit', 'regip', 'regdate', 'lastloginip', 'lastlogintime', 'hits', 'hits_today', 'hits_yday', 'hits_week', 'hits_month', 'type', 'status'); $data = compact($fields); $uid = iDB::insert('user', $data); user::set_cookie($username, $password, array('uid' => $uid, 'username' => $username, 'nickname' => $nickname, 'status' => $status)); if ($openid) { $platform = $type; iDB::query("\n INSERT INTO `#iCMS@__user_openid`\n (`uid`, `openid`, `platform`)\n VALUES ('{$uid}', '{$openid}', '{$platform}');\n "); } if ($avatar) { $avatarData = iFS::remote($avatar); if ($avatarData) { $avatarpath = iFS::fp(get_user_pic($uid), '+iPATH'); iFS::mkdir(dirname($avatarpath)); iFS::write($avatarpath, $avatarData); iFS::yun_write($avatarpath); } } //user::set_cache($uid); iPHP::set_cookie('forward', '', -31536000); iPHP::json(array('code' => 1, 'forward' => $this->forward)); }
function do_download() { iFS::$userid = false; $rs = iFS::getFileData('id', $this->id); iFS::$redirect = true; $FileRootPath = iFS::fp($rs->filepath, "+iPATH"); iFS::check_ext($rs->filepath, true) or iPHP::alert('文件类型不合法!'); iFS::$userid = iMember::$userid; $fileresults = iFS::remote($rs->ofilename); if ($fileresults) { iFS::mkdir(dirname($FileRootPath)); iFS::write($FileRootPath, $fileresults); iFS::$watermark = !isset($_GET['unwatermark']); iFS::watermark($rs->ext, $FileRootPath); iFS::yun_write($FileRootPath); $_FileSize = strlen($fileresults); if ($_FileSize != $rs->size) { iDB::query("update `#iCMS@__filedata` SET `size`='{$_FileSize}' WHERE `id` = '{$this->id}'"); } iPHP::success("{$rs->ofilename} <br />重新下载到<br /> {$rs->filepath} <br />完成", 'js:1', 3); } else { iPHP::alert("下载远程文件失败!", 'js:1', 3); } }