function activated($key, $hash_email) { $this->db->where("BINARY(activation_reset_key)", $key); //"BINARY column_name = '$var'" //$sql = "'BINARY user = '******'"; /*$query = $this->db->get_compiled_select("tbl_users"); echo $query; exit;*/ $query = $this->db->get("tbl_users"); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { if ($hash_email === sha1(md5($row['email']))) { $this->db->set('activation_reset_key', genRandomString('42')); $this->db->set('verification_status', 1); $this->db->where('email', $row['email']); if ($this->db->update('tbl_users')) { return $row['email']; } else { return false; } } } return false; } else { //echo "can't find either the key or the email."; exit; return false; } }
function encryptUserInfo($user_id, $mobile) { $output = ""; // 2位随机字母 $output .= genRandomString(2); // 用户id $output .= encryptNumToAlphabet(strval($user_id)); // 分隔符 $output .= 'z'; // 用户手机号,以随机字母间隔 $encryptMobile = encryptNumToAlphabet($mobile); for ($i = 0; $i < strlen($encryptMobile); $i++) { $output .= genRandomString(1); $output .= $encryptMobile[$i]; } // 分隔符 $output .= 'z'; // 年月日时,以随机字母间隔 $time = date("YmdH", time()); $encryptTime = encryptNumToAlphabet($time); for ($i = 0; $i < strlen($encryptTime); $i++) { $output .= genRandomString(1); $output .= $encryptTime[$i]; } // 2位随机字母 $output .= genRandomString(2); return $output; }
public function update_pw($email, $password) { $data = array('pw_reset_key' => genRandomString("42"), 'password' => $password); $this->db->where('email', $this->session->userdata('admin_email')); if ($this->db->update('tbl_admin', $data)) { return true; } else { return false; } }
public function userRegisters($username, $password) { //检查用户名 $encrypt = genRandomString(6); $password = md5($password); $data = array('uname' => $username, "upassword" => $password, 'authkey' => $encrypt); dump($data); $userid = $this->add($data); dump($userid); if ($userid) { return $userid; } $this->error = $this->getError() ?: '注册失败!'; return false; }
/** * 根据标识修改对应用户密码 * @param type $identifier * @param type $password * @return type */ public function ChangePassword($identifier, $password) { if (empty($identifier) || empty($password)) { return false; } $term = array(); if (is_int($identifier)) { $term['id'] = $identifier; } else { $term['username'] = $identifier; } $verify = genRandomString(); $data['verify'] = $verify; $data['password'] = $this->encryption($identifier, $password, $verify); $up = $this->where($term)->save($data); if ($up !== false) { return true; } return false; }
/** * 修改会员信息 * @param $data * @return boolean */ public function editUser($data) { if (empty($data) || !is_array($data) || !isset($data['userid'])) { $this->error = '没有需要修改的数据!'; return false; } $info = $this->where(array('userid' => $data['userid']))->find(); if (empty($info)) { $this->error = '该会员信息不存在!'; return false; } //密码为空,表示不修改密码 if (isset($data['upassword']) && empty($data['upassword'])) { unset($data['upassword']); } if ($this->create($data)) { if ($this->data['upassword']) { $this->authkey = genRandomString(6); $this->upassword = $this->hashPassword($this->upassword, $this->authkey); } if ($info['ifrz'] == false && $data['ifrz'] == true) { $today = date('Y年m月d日', time()); insertSysmsg($info['userid'], '获嘉您升级为烘焙师', '恭喜您于' . $today . '申请认证烘焙师已审核通过,继续努力哦!'); } $status = $this->save(); if (false !== $status) { if ($data['uavatar']) { service("Attachment")->api_update('', 'userid-ua' . $data['userid'], 1); } if ($data['ubackground']) { service("Attachment")->api_update('', 'userid-ua' . $data['userid'], 1); } } return $status !== false ? true : false; } return false; }
/** * Process password reset user form. * * @since 1.0 * @package facileManager * * @param string $user_login Username to authenticate * @return boolean */ function processUserPwdResetForm($user_login = null) { global $fmdb; if (empty($user_login)) { return; } $user_info = getUserInfo(sanitize($user_login), 'user_login'); /** If the user is not found, just return lest we give away valid user accounts */ if ($user_info == false) { return true; } $fm_login = $user_info['user_id']; $uniqhash = genRandomString(mt_rand(30, 50)); $query = "INSERT INTO fm_pwd_resets VALUES ('{$uniqhash}', '{$fm_login}', " . time() . ")"; $fmdb->query($query); if (!$fmdb->rows_affected) { return false; } /** Mail the reset link */ $mail_enable = getOption('mail_enable'); if ($mail_enable) { $result = $this->mailPwdResetLink($fm_login, $uniqhash); if ($result !== true) { $query = "DELETE FROM fm_pwd_resets WHERE pwd_id='{$uniqhash}' AND pwd_login='******'"; $fmdb->query($query); return $result; } } return true; }
/** * 注册会员 * @param type $username 用户名 * @param type $password 明文密码 * @param type $email 邮箱 * @return boolean */ public function userRegister($username, $password) { //检查用户名 $ckname = $this->userCheckUsername($username); if ($ckname !== true) { return false; } $Member = D("User/User"); $encrypt = genRandomString(6); $password = $Member->encryption(0, $password, $encrypt); $data = array("uname" => $username, "upassword" => $password, "authkey" => $encrypt); $userid = $Member->add($data); if ($userid) { return $userid; } else { $this->error = $Member->getError() ?: '注册失败!'; return false; } }
/** * 修改管理员信息 * @param type $data */ public function amendManager($data) { if (empty($data) || !is_array($data) || !isset($data['id'])) { $this->error = '没有需要修改的数据!'; return false; } $info = $this->where(array('id' => $data['id']))->find(); if (empty($info)) { $this->error = '该管理员不存在!'; return false; } //密码为空,表示不修改密码 if (isset($data['password']) && empty($data['password'])) { unset($data['password']); } if ($this->create($data)) { if ($this->data['password']) { $verify = genRandomString(6); $this->verify = $verify; $this->password = $this->hashPassword($this->password, $verify); } $status = $this->save(); return $status !== false ? true : false; } return false; }
<?php //TODO: unexistant user. include_once "../../includes/general.php"; include_once "../../includes/db.include.php"; include_once "../../includes/mail.include.php"; db_connect(); $_SESSION['reset_email'] = mysql_real_escape_string($_POST['email']); if (trim($_POST["email"]) == "") { $_SESSION['ResetMessage'] = "You must input an email address.\n"; $_SESSION['ResetType'] = 3; $_SESSION['ResetDetails'] = $_SESSION['ResetDetails'] . "Input your email address so we can send you your password.<br />"; go("../reset_pass.php"); } $newpassdisplay = genRandomString(); $newpass = mysql_real_escape_string(md5($newpassdisplay)); //update $query = "UPDATE Scientists SET password = '******', loginstep = 1 WHERE email = '" . $_SESSION['reset_email'] . "';"; $result = mysql_query($query); $mail = generatePassMail($_SESSION['reset_email'], "Password Reset", $newpassdisplay, "You will be prompted to change the password as soon as you log in."); $_SESSION['LoginMessage'] = "Password reset successful."; $_SESSION['LoginDetails'] = "An email was sent to " . $_SESSION['reset_email'] . " with a new password. You will be asked to change the password upon your first login."; $_SESSION['LoginType'] = 1; go("../login.php"); ?>
private function keys() { $path = APP_PATH . 'Conf/dataconfig.php'; if (is_writable($path) == false) { exit(serialize(array('error' => -10007, 'status' => 'fail'))); } //读取数据 $config = (include $path); if (empty($config)) { exit(serialize(array('error' => -10018, 'status' => 'fail'))); } //开始更新 $config['AUTHCODE'] = genRandomString(30); if (F('dataconfig', $config, APP_PATH . 'Conf/')) { //删除缓存 $Dir = new Dir(); $Dir->del(RUNTIME_PATH); exit(serialize(array('authcode' => $config['AUTHCODE'], 'status' => 'success'))); } else { exit(serialize(array('error' => -10019, 'status' => 'fail'))); } }
mysql_query("UPDATE `{$dbPrefix}config` SET `value` = '{$seo_description}' WHERE varname='siteinfo'"); mysql_query("UPDATE `{$dbPrefix}config` SET `value` = '{$seo_keywords}' WHERE varname='sitekeywords'"); //读取配置文件,并替换真实配置数据 $strConfig = file_get_contents(SITEDIR . 'install/' . $configFile); $strConfig = str_replace('#DB_HOST#', $dbHost, $strConfig); $strConfig = str_replace('#DB_NAME#', $dbName, $strConfig); $strConfig = str_replace('#DB_USER#', $dbUser, $strConfig); $strConfig = str_replace('#DB_PWD#', $dbPwd, $strConfig); $strConfig = str_replace('#DB_PORT#', $dbPort, $strConfig); $strConfig = str_replace('#DB_PREFIX#', $dbPrefix, $strConfig); $strConfig = str_replace('#AUTHCODE#', genRandomString(18), $strConfig); $strConfig = str_replace('#COOKIE_PREFIX#', genRandomString(6) . "_", $strConfig); @file_put_contents(SITEDIR . '/shuipf/Conf/dataconfig.php', $strConfig); //插入管理员 //生成随机认证码 $verify = genRandomString(6); $time = time(); $ip = get_client_ip(); $password = md5($password . md5($verify)); $query = "INSERT INTO `{$dbPrefix}user` VALUES ('1', '{$username}', '未知', '{$password}', '', '{$time}', '0.0.0.0', '{$verify}', '*****@*****.**', '备注信息', '{$time}', '{$time}', '1', '1', '');"; mysql_query($query); $message = '成功添加管理员<br />成功写入配置文件<br>安装完成.'; $arr = array('n' => 999999, 'msg' => $message); echo json_encode($arr); exit; } include_once "./templates/s4.php"; exit; case '5': include_once "./templates/s5.php"; @touch('./install.lock');
/** * 忘记密码 */ public function forget() { if ($_POST) { if ($this->userid) { $this->error("你已经登录了", '/'); } $post = I('post.'); if (empty($post['uname'])) { $this->error("请输入你的注册邮箱"); } if (!is_email($post['uname'])) { $this->error("请输入正确的邮箱格式"); } $user = M('User')->where(array('uname' => $post['uname']))->field("uemail, userid")->find(); if (!$user['userid']) { $this->error("你输入注册邮箱不存在"); } $is_exist = M('UserRelog')->where(array('userid' => $user['userid']))->count(); if ($is_exist > 0) { $info['vcode'] = genRandomString(6); $info['create_time'] = time(); $id = M('UserRelog')->where(array('userid' => $user['userid']))->save($info); } else { $info['userid'] = $user['userid']; $info['vcode'] = genRandomString(6); $info['create_time'] = time(); $id = M('UserRelog')->add($info); } //SendMail($address, $title, $message); if ($id) { $address = $post['uname']; $title = "修改密码"; $url = "http://" . $_SERVER['HTTP_HOST'] . "/user/login/repwd?userid=" . $user['userid'] . "&vcode=" . $info['vcode']; $message = "欢迎使用烘焙圈,点击<a href='{$url}' target='_blank'>修改密码</a>,链接有效期为3天"; if (SendMail($address, $title, $message)) { $this->success("邮件发送成功,请在3天内修改密码", "/"); } else { $this->error("邮件发送失败"); } } else { $this->error("系统繁忙"); } } else { $this->display(); } }
function exec_ogp_module() { global $db; global $view; echo "<h2>" . get_lang('add_new_game_home') . "</h2>"; echo "<p><a href='?m=user_games'><< " . get_lang('back_to_game_servers') . "</a></p>"; $remote_servers = $db->getRemoteServers(); if ($remote_servers === FALSE) { echo "<p class='note'>" . get_lang('no_remote_servers_configured') . "</p>\n\t\t\t <p><a href='?m=server'>" . get_lang('add_remote_server') . "</a></p>"; return; } $game_cfgs = $db->getGameCfgs(); $users = $db->getUserList(); if ($game_cfgs === FALSE) { echo "<p class='note'>" . get_lang('no_game_configurations_found') . " <a href='?m=config_games'>" . get_lang('game_configurations') . "</a></p>"; return; } echo "<p> <span class='note'>" . get_lang('note') . ":</span> " . get_lang('add_mods_note') . "</p>"; $selections = array("allow_updates" => "u", "allow_file_management" => "f", "allow_parameter_usage" => "p", "allow_extra_params" => "e", "allow_ftp" => "t", "allow_custom_fields" => "c"); if (isset($_REQUEST['add_game_home'])) { $rserver_id = $_POST['rserver_id']; $home_cfg_id = $_POST['home_cfg_id']; $web_user_id = trim($_POST['web_user_id']); $control_password = genRandomString(8); $access_rights = ""; $ftp = FALSE; foreach ($selections as $selection => $flag) { if (isset($_REQUEST[$selection])) { $access_rights .= $flag; if ($flag == "t") { $ftp = TRUE; } } } if (empty($web_user_id)) { print_failure(get_lang('game_path_empty')); } else { foreach ($game_cfgs as $row) { if ($row['home_cfg_id'] == $home_cfg_id) { $server_name = $row['game_name']; } } foreach ($remote_servers as $server) { if ($server['remote_server_id'] == $rserver_id) { $ogp_user = $server['ogp_user']; } } foreach ($users as $user) { if ($user['user_id'] == $web_user_id) { $web_user = $user['users_login']; } } $ftppassword = genRandomString(8); $game_path = "/home/" . $ogp_user . "/OGP_User_Files/"; if (($new_home_id = $db->addGameHome($rserver_id, $web_user_id, $home_cfg_id, clean_path($game_path), $server_name, $control_password, $ftppassword)) !== FALSE) { $db->assignHomeTo("user", $web_user_id, $new_home_id, $access_rights); if ($ftp) { $home_info = $db->getGameHomeWithoutMods($new_home_id); require_once 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']); } $db->changeFtpStatus('enabled', $new_home_id); } print_success(get_lang('game_home_added')); $db->logger(get_lang('game_home_added') . " ({$server_name})"); $view->refresh("?m=user_games&p=edit&home_id={$new_home_id}"); } else { print_failure(get_lang_f("failed_to_add_home_to_db", $db->getError())); } } } // View form to add more servers. if (!isset($_POST['rserver_id'])) { echo "<form action='?m=user_games&p=add' method='post'>"; echo "<table class='center'>"; echo "<tr><td class='right'>" . get_lang('game_server') . "</td><td class='left'><select onchange=" . '"this.form.submit()"' . " name='rserver_id'>\n"; echo "<option>" . get_lang('select_remote_server') . "</option>\n"; foreach ($remote_servers as $server) { echo "<option value='" . $server['remote_server_id'] . "'>" . $server['remote_server_name'] . " (" . $server['agent_ip'] . ")</option>\n"; } echo "</select>\n"; echo "</form>"; echo "</td></tr></table>"; } else { if (isset($_POST['rserver_id'])) { $rhost_id = $_POST['rserver_id']; } $remote_server = $db->getRemoteServer($rhost_id); require_once 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $host_stat = $remote->status_chk(); if ($host_stat === 1) { $os = $remote->what_os(); } else { print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms")); $os = "Unknown OS"; } echo "<form action='?m=user_games&p=add' method='post'>"; echo "<table class='center'>"; echo "<tr><td class='right'>" . get_lang('game_type') . "</td><td class='left'> <select name='home_cfg_id'>\n"; // Linux 64 bits + wine if (preg_match("/Linux/", $os) and preg_match("/64/", $os) and preg_match("/wine/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . ":</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/win/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } elseif (preg_match("/Linux/", $os) and preg_match("/64/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } elseif (preg_match("/Linux/", $os) and preg_match("/wine/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } echo "<option style='background:black;color:white;' value=''>" . get_lang('wine_games') . "</option>\n"; foreach ($game_cfgs as $row) { if (preg_match("/win32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } } elseif (preg_match("/Linux/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/linux32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } } elseif (preg_match("/CYGWIN/", $os) and preg_match("/64/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/win/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; } if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } elseif (preg_match("/CYGWIN/", $os)) { foreach ($game_cfgs as $row) { if (preg_match("/win32/", $row['game_key'])) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name'] . "</option>\n"; } } } elseif ($os == "Unknown OS") { foreach ($game_cfgs as $row) { echo "<option value='" . $row['home_cfg_id'] . "'>" . $row['game_name']; if (preg_match("/64/", $row['game_key'])) { echo " (64 bit)"; } echo "</option>\n"; } } echo "</select>\n</td></tr>"; // Select user echo "<tr><td class='right'>" . get_lang('login') . ":</td>\n\t\t\t<td class='left'><select name='web_user_id'>"; $users = $db->getUserList(); foreach ($users as $user) { // Only users and admins can be assigned homes... not subusers if (is_null($user['users_parent'])) { echo "<option value='" . $user['user_id'] . "'>" . $user['users_login'] . "</option>\n"; } } echo "</select>\n</td></tr>"; // Select permisions echo "<tr><td class='right'>" . get_lang('access_rights') . ":</td>\n\t\t\t<td class='left'>"; foreach ($selections as $selection => $flag) { echo create_selection($selection, $flag); } echo "</td></tr>"; // Assign home echo "<tr><td align='center' colspan='2'>\n\t\t\t <input type='hidden' name='rserver_id' value='" . $rhost_id . "' />" . "<input type='submit' name='add_game_home' value='" . get_lang('add_game_home') . "' /></td></tr></table>"; echo "</form>"; } }
} return $string; } if ($get != $null) { echo "{\n"; if ($get != "/") { $splitted = preg_split("/\\./", $get); foreach ($splitted as $a) { if ($a != "/") { echo "\"" . $a . "\": {\n"; } } } for ($i = 0; $i < rand(1, 7); $i++) { $text = genRandomString(); echo "\n\"randomFromAjax_" . $text . "\":null,"; } $text = genRandomString(); echo "\n\"" . $text . "\":null"; if ($get != "/") { $splitted = preg_split("/\\./", $get); foreach ($splitted as $a) { if ($a != "/") { echo "\n\n}"; } } } echo "\n}"; } else { echo "null"; }
$values = null; $statusmsg = 'updated'; switch($status){ // OPEN case "0": $values .= "serviceTypeID = '$serviceType',equipmentID = '$equipment',meter = '$meter' ,labor = '$labor',miscellaneous = '$misc',parts = '$parts',discount = '$disc',subTotal = '$subTotal',tax = '$tax',totalCost = '$totalCost' ,isWarranty = '$isWarranty',isBackJob = '$isBackJob',remarks = '$remarks' "; $statusmsg = 'updated'; break; // APPROVED case "1": if($isSent == 0){ $sesid = genRandomString(10); $sesid = ",url = '$sesid'"; $values .= "serviceTypeID = '$serviceType',equipmentID = '$equipment',meter = '$meter' ,labor = '$labor',miscellaneous = '$misc',parts = '$parts',discount = '$disc',subTotal = '$subTotal',tax = '$tax',totalCost = '$totalCost' ,isWarranty = '$isWarranty',isBackJob = '$isBackJob',remarks = '$remarks' $sesid ,status = '$status',remarks = '$remarks' "; $statusmsg = 'updated and is waiting for approval'; } break; // FOR APPROVAL case "2": $values .= "labor = '$labor',miscellaneous = '$misc',parts = '$parts',discount = '$disc',tax = '$tax',totalCost = '$totalCost' "; $statusmsg = 'updated and is waiting for repair'; break;
$generatephp = 'cp ' . $htmlpath . '/' . sanitize_file_name($archivo['filename']) . '-o.html ' . $htmlpath . '/' . sanitize_file_name($archivo['filename']) . '-o.php 2>&1'; exec($generatephp, $outphp); $outphp = implode("\n", $outphp); update_post_meta($post_ID, 'output_php', $outphp); update_post_meta($post_ID, 'all2html_php', $uppath . '/' . sanitize_file_name($archivo['filename']) . '-o.php'); $html_plain = file_get_contents($htmlpath . '/' . sanitize_file_name($archivo['filename']) . '-o.php'); $content = preg_replace('/<img class=\\"(.*?)\\" alt=\\"\\" src=\\"(.*?)\\"\\/>/s', '<img class="$1" alt="" src="' . $uppath . '/$2"/>', $html_plain); $filename = $htmlpath . '/' . sanitize_file_name($archivo['filename']) . '-i.php'; $handle = fopen($filename, 'x+'); fwrite($handle, $content); fclose($handle); update_post_meta($post_ID, 'all2html_htmlcontent', $uppath . '/' . sanitize_file_name($archivo['filename']) . '-i.php'); preg_match('/<div id=\\"pf3\\" class\\=\\"pf w0 h0\\" data\\-page\\-no\\=\\"3\\">(.*?)<\\/div>/s', $html_plain, $matches); $excerpt = strip_tags($matches[1]); update_post_meta($post_ID, 'all2html_excerpt', $excerpt); update_post_meta($post_ID, 'all2html_hash', genRandomString($pdfoptpath)); // /<img class=\"(.*?)\" alt=\"\" src=\"(.*?)\"\/>/s } break; case 'cinco': //Se genera el HTML full if (get_post_meta($post_ID, "all2html_ok", true) == 'ok') { $pdfoptpath = get_post_meta($post_ID, "all2html_pdfoptpath", true); $htmlpath = get_post_meta($post_ID, "all2html_path", true); $uppath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $htmlpath); $archivo = get_post_meta($post_ID, "all2html_arch", true); if (wp_mkdir_p($htmlpath . '/fullhtml')) { $full_html = '/usr/local/bin/pdf2htmlEX --fit-width 1240 --embed cfijo --no-drm 1 --optimize-text 1 --dest-dir ' . $htmlpath . '/fullhtml --external-hint-tool=/usr/local/bin/ttfautohint ' . $pdfoptpath . ' 2>&1'; exec($full_html, $outfull); $outfull = implode("\n", $outfull); update_post_meta($post_ID, 'output_full', $outfull);
// if an action is set then lets do it. if ($action == "newPad") { $name = $_GET["name"]; if (!$name) { function genRandomString() { // A funtion to generate a random name if something doesn't already exist $length = 10; $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; $string = ''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } $name = genRandomString(); } $contents = $_GET["contents"]; try { $newPad = $instance->createGroupPad($groupID, $name, $contents); $padID = $newPad->padID; $newlocation = "{$host}/p/{$padID}"; // redirect to the new padID location header("Location: {$newlocation}"); } catch (Exception $e) { echo "\n\ncreateGroupPad Failed with message " . $e->getMessage(); } } if ($action == "deletePad") { $name = $_GET["name"]; try {
/** * @title JoomShaper registration module * @website http://www.joomshaper.com * @Copyright (C) 2010 - 2012 joomshaper.com. All rights reserved. * @license GNU/GPL **/ // no direct access defined('_JEXEC') or die('Restricted access'); JHtml::_('behavior.keepalive'); JHtml::_('behavior.formvalidation'); $utilfile = JPATH_ROOT . '/media/media_chessvn/cvnphp/utils/cvnutils.php'; $configfile = JPATH_ROOT . '/media/media_chessvn/cvnphp/config/cvnconfig.php'; require_once $utilfile; require_once $configfile; $defaultname = $conf['default_email_prefix'] . genRandomString(); $defaultemail = $defaultname . $conf['default_email_domain']; //$document = JFactory::getDocument(); //$mediaPath = JURI::base() . '/media/media_chessvn/'; //$document->addStyleSheet($mediaPath.'css/jquery-ui-1.10.3.custom.min.css'); ?> <script> jQuery(document).ready(function(){ function checkuser(username){ var array = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','-','_']; var check = 0; username = username.toLowerCase(); for(i = 0; i<username.length; i++){ if(array.indexOf(username[i]) == -1){ check++; }else{}
/** * 使用本地账号登陆 (密码为null时不参与验证) * @param type $identifier 用户标识,用户uid或者用户名 * @param type $password 用户密码,未加密,如果为空,不参与验证 * @param type $is_remember_me cookie有效期 * return 返回状态,大于 0:返回用户 ID,表示用户登录成功 * -1:用户不存在,或者被删除 * -2:密码错 * -3会员注册登陆状态失败 */ public function loginLocal($identifier, $password = null, $is_remember_me = 3600) { $db = D("Member"); if ($this->UCenter) { $user = uc_user_login($identifier, $password); if ($user[0] > 0) { $userid = $user[0]; $username = $user[1]; $ucpassword = $user[2]; $ucemail = $user[3]; $map = array(); $map['userid'] = $userid; $map['username'] = $username; //取得本地相应用户 $userinfo = $db->where($map)->find(); //检查是否存在该用户信息 if (!$userinfo) { //UC中有该用户,本地没有时,创建本地会员数据 $data = array(); $data['userid'] = $userid; $data['username'] = $username; $data['nickname'] = $username; $data['encrypt'] = genRandomString(6); //随机密码 $data['password'] = $db->encryption(0, $ucpassword, $data['encrypt']); $data['email'] = $ucemail; $data['regdate'] = time(); $data['regip'] = get_client_ip(); $data['modelid'] = $this->_config['defaultmodelid']; $data['point'] = $this->_config['defualtpoint']; $data['amount'] = $this->_config['defualtamount']; $data['groupid'] = $db->get_usergroup_bypoint($this->_config['defualtpoint']); $data['checked'] = 1; $data['lastdate'] = time(); $data['loginnum'] = 1; $data['lastip'] = get_client_ip(); $db->add($data); $Model_Member = F("Model_Member"); $tablename = $Model_Member[$data['modelid']]['tablename']; M(ucwords($tablename))->add(array("userid" => $userid)); $userinfo = $data; } else { //更新密码 $encrypt = genRandomString(6); //随机密码 $pw = $db->encryption(0, $ucpassword, $encrypt); $db->where(array("userid" => $userid))->save(array("encrypt" => $encrypt, "password" => $pw, "lastdate" => time(), "lastip" => get_client_ip(), 'loginnum' => $userinfo['loginnum'] + 1)); $userinfo['password'] = $pw; $userinfo['encrypt'] = $encrypt; } if ($this->registerLogin($userinfo, $is_remember_me)) { //登陆成功 return $userinfo['userid']; } else { //会员注册登陆状态失败 return -3; } } else { //登陆失败 return $user[0]; } } else { $map = array(); if (is_int($identifier)) { $map['userid'] = $identifier; } else { $map['username'] = $identifier; } $userinfo = $db->where($map)->find(); if (!$userinfo) { //没有该用户 return -1; } $encrypt = $userinfo["encrypt"]; $password = $db->encryption($identifier, $password, $encrypt); if ($password == $userinfo['password']) { if ($this->registerLogin($userinfo, $is_remember_me)) { //修改登陆时间,和登陆IP $db->where($map)->save(array("lastdate" => time(), "lastip" => get_client_ip(), "loginnum" => $userinfo['loginnum'] + 1)); //登陆成功 return $userinfo['userid']; } else { //会员注册登陆状态失败 return -3; } } else { //密码错误 return -2; } } }
//Generate unique signature of the user based on IP address //and the browser then append it to session //This will be used to authenticate the user session //To make sure it belongs to an authorized user and not to anyone else. //generate random salt function genRandomString() { //credits: http://bit.ly/a9rDYd $length = 50; $characters = "0123456789abcdef"; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } $random = genRandomString(); $salt_ip = substr($random, 0, $length_salt); //hash the ip address, user-agent and the salt $useragent = $_SERVER["HTTP_USER_AGENT"]; $hash_user = sha1($salt_ip . $iptocheck . $useragent); //concatenate the salt and the hash to form a signature $signature = $salt_ip . $hash_user; //Regenerate session id prior to setting any session variable //to mitigate session fixation attacks session_regenerate_id(); //Finally store user unique signature in the session //and set logged_in to TRUE as well as start activity time $_SESSION['signature'] = $signature; $_SESSION['logged_in'] = TRUE; $_SESSION['LAST_ACTIVITY'] = time(); $_SESSION['username'] = $_POST['user'];
<?php require_once "vendor/autoload.php"; use lib\ExportDataExcel; $excel = new ExportDataExcel('browser', '/Users/Mike/Downloads/'); $excel->filename = rand(1, 100) . ".xls"; $excel->initialize(); for ($i = 1; $i < 50000; $i++) { $row = array($i, genRandomString(), genRandomString()); $excel->addRow($row); } /*foreach($data as $row) { $excel->addRow($row); }*/ $excel->finalize(); function genRandomString($length = 100) { $characters = "0123456789abcdefghijklmnopqrstuvwxyz _"; $string = ""; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters) - 1)]; } return $string; }
/** * 添加管理员 * @param type $data * @return boolean */ public function addUser($data) { if (empty($data)) { $this->error = '数据不能为空!'; return false; } //检验数据 $data = $this->create($data, 1); if ($data) { //生成随机认证码 $data['verify'] = genRandomString(6); //利用认证码和明文密码加密得到加密后的 $data['password'] = $this->encryption(0, $data['password'], $data['verify']); $id = $this->add($data); if ($id) { return $id; } else { $this->error = '添加用户失败!'; return false; } } else { return false; } }
if (!$con) { die('Could not connect: ' . mysql_error()); } function genRandomString() { $length = 6; $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $string = ""; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } $firstname = ereg_replace("[^A-Za-z0-9]", "", $_POST[firstname]); $lastname = ereg_replace("[^A-Za-z0-9]", "", $_POST[lastname]); $killcode = genRandomString(); $netid = ereg_replace("[^A-Za-z0-9]", "", $_POST[netid]); $phone = str_replace(array("-", "(", ")"), "", $_POST[phone]); $gender = $_POST[gender]; if ($gender != "female") { $gender = "male"; } $year = ereg_replace("[^A-Za-z0-9]", "", $_POST[year]); mysql_select_db("hvz", $con); $sql = "INSERT INTO users (firstname, lastname, killcode, netid, phone, gender, year)\n\tVALUES\n\t('{$firstname}','{$lastname}','{$killcode}','{$netid}','{$phone}','{$gender}','{$year}')"; if (!mysql_query($sql, $con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); } else {
$access[3] = "Guest"; for ($i = 0; $i <= 1000; $i++) { // generate 1,000 random data $rand_access = rand(1, 3); // insert data mysql_query('INSERT INTO employee ( first_name, last_name, phone, job_id, created_on, updated_on, access ) VALUES ( "' . genRandomString(8) . '", "' . genRandomString(10) . '", "' . rand(1111111, 9999999) . '", ' . rand(1, 5) . ', "' . $date_created . '", "' . $date_created . '", "' . $access[$rand_access] . '" )'); } mysql_close($link); // close mysql connection echo '<pre>Done!</pre>'; // fin /* Debug: measure execution time: end time then print */ $time_end = microtime(true); $time = $time_end - $time_start; echo "<pre>Query time: " . round($time, 5) . " s</pre>";
function sendComment() { # Send Comment Process global $separator, $config, $lang, $theme_main, $SHP, $public_data; unset($GLOBALS['$public_data']); $theme_main['content'] = ""; $theme_main['content'] .= "<h3>" . $lang['pageViewComments'] . "</h3>"; $public_data['commentFileName'] = $commentFileName = isset($_POST['sendComment']) ? $_POST['sendComment'] : $_GET['sendComment']; $public_data['author'] = $author = isset($_POST['author']) ? $_POST['author'] : ""; $public_data['commentTitle'] = $commentTitle = $lang['pageCommentsBy'] . ' ' . $author; $public_data['comment'] = $comment = isset($_POST['comment']) ? $_POST['comment'] : ""; $public_data['url'] = $url = isset($_POST['commentUrl']) ? $_POST['commentUrl'] : ""; $public_data['email'] = $email = isset($_POST['commentEmail']) ? $_POST['commentEmail'] : ""; $public_data['code'] = $code = $_POST['code']; $public_data['originalCode'] = $originalCode = $_POST['originalCode']; $do = 1; $triedAsAdmin = 0; if ($config['onlyNumbersOnCAPTCHA'] == 1) { $code1 = substr(rand(0, 999999), 1, $config['CAPTCHALength']); } else { $code1 = genRandomString($config['CAPTCHALength']); } $_POST['code'] = $code1; if (!$SHP->hooks_exist('hook-commentform-replace')) { if (trim($commentTitle) == '' || trim($author) == '' || trim($comment) == '') { $theme_main['content'] .= $lang['errorAllFields'] . '<br>'; $do = 0; } if ($config['commentsSecurityCode'] == 1) { //$code = $_POST['code']; $originalCode = $_POST['originalCode']; if ($code !== $originalCode) { $theme_main['content'] .= $lang['errorSecurityCode'] . '<br>'; $do = 0; } } $hasPosted = 0; $forbiddenAuthors = explode(',', $config['commentsForbiddenAuthors']); foreach ($forbiddenAuthors as $value) { if ($value == $author) { $theme_main['content'] .= $lang['errorCommentUser1'] . " " . $author . " " . $lang['errorCommentUser2']; $do = 0; } } } $public_data['do'] = $do; if ($SHP->hooks_exist('hook-comment-validate')) { $SHP->execute_hooks('hook-comment-validate', $public_data); } $do = $public_data['do']; if ($do == 1) { if (strlen($comment) > $config['commentsMaxLength']) { $theme_main['content'] .= $lang['errorLongComment1'] . ' ' . $config['commentsMaxLength'] . ' ' . $lang['errorLongComment2'] . ' ' . strlen($comment); } else { $commentFullName = $config['commentDir'] . $commentFileName . $config['dbFilesExtension']; $result = sqlite_query($config['db'], "select count(sequence) AS view from comments WHERE postid='{$commentFileName}';"); $commentCount = sqlite_fetch_array($result); $result = sqlite_query($config['db'], "select * from comments WHERE postid = '{$commentFileName}' ORDER BY sequence DESC LIMIT 1;"); while ($row = sqlite_fetch_array($result, SQLITE_ASSOC)) { $maxseq = $row['sequence']; } if ($commentCount['view'] == 0) { $thisCommentSeq = 1; } else { $thisCommentSeq = $maxseq + 1; } $comment = sqlite_escape_string(str_replace("\\", "", str_replace("\n", "", $comment))); $date = date("Y-m-d H:i:s"); $ip = $_SERVER["REMOTE_ADDR"]; if ($config['commentModerate'] == 1) { $status = 'pending'; $message = $lang['msgCommentModerate']; } else { $status = 'approved'; $message = $lang['msgCommentAdded']; } sqlite_query($config['db'], "INSERT INTO comments (postid, sequence, title, author, content, date, ip, url, email, status) VALUES('{$commentFileName}', '{$thisCommentSeq}', '{$commentTitle}', '{$author}', '{$comment}', '{$date}', '{$ip}', '{$url}', '{$email}', '{$status}');"); $_SESSION['message'] = $message; $theme_main['content'] .= $message . ' ' . $author . '!<br />'; # If Comment Send Mail is active if ($config['sendMailWithNewComment'] == 1) { $subject = "PRITLOG: " . $lang['msgMail7']; $message = $lang['msgMail1'] . " " . $author . " " . $lang['msgMail2'] . "\n\n" . $lang['msgMail3'] . ": " . $commentTitle . "\n" . $lang['msgMail4'] . ": " . str_replace("\\", "", $comment) . "\n" . $lang['msgMail5'] . ": " . date("d M Y h:i A") . "\n\n" . $lang['msgMail6'] . "\n\n"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: ' . $config['sendMailWithNewCommentMail'] . "\r\n"; $headers = 'From: Pritlog <' . $config['sendMailWithNewCommentMail'] . '>' . "\r\n"; @mail($config['sendMailWithNewCommentMail'], $subject, $message, $headers); } header('Location: ' . $config['blogPath'] . $config['cleanIndex'] . '/sendCommentSuccess'); } //unset($_POST); if ($SHP->hooks_exist('hook-comment-success')) { $SHP->execute_hooks('hook-comment-success'); } } else { $theme_main['content'] .= $lang['errorPleaseGoBack']; if ($SHP->hooks_exist('hook-comment-fail')) { $SHP->execute_hooks('hook-comment-fail'); } } }
$record = $_REQUEST['record']; $config = Accounting::loadConfigParams(); $global_vars = $_SESSION[base64_decode('dXNlcm5hbWU=')] != $config['fromuser']; if ($mode) { $focus->mode = $mode; } if ($record) { $focus->id = $record; } if ($_REQUEST['assigntype'] == 'U') { $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id']; } elseif ($_REQUEST['assigntype'] == 'T') { $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id']; } if (!$mode) { $focus->column_fields['uniqueid'] = genRandomString() . "_" . time(); } $focus->save_entity($focus, $global_vars); $return_id = $focus->id; $search = $_REQUEST['search_url']; $parenttab = getParentTab(); if ($_REQUEST['return_module'] != '') { $return_module = vtlib_purify($_REQUEST['return_module']); } else { $return_module = "Accounting"; } if ($_REQUEST['return_action'] != '') { $return_action = vtlib_purify($_REQUEST['return_action']); } else { $return_action = "DetailView"; }
function exec_ogp_module() { global $db; $home_id = $_REQUEST['home_id']; $server_row = $db->getGameHomeWithoutMods($home_id); if (empty($server_row)) { print_failure(get_lang('invalid_home_id')); return; } echo "<h2>" . get_lang_f('cloning_home', $server_row['home_name']) . "</h2>"; echo create_back_button('user_games'); include 'includes/lib_remote.php'; $remote = new OGPRemoteLibrary($server_row['agent_ip'], $server_row['agent_port'], $server_row['encryption_key']); if (isset($_REQUEST['clone_home'])) { $server_name = $_POST['new_home_name']; $user_group = $_POST['user_group']; $clone_home_id = $db->addGameHome($server_row['remote_server_id'], $server_row['user_id_main'], $server_row['home_cfg_id'], "/home/" . $server_row['ogp_user'] . "/OGP_User_Files/", $server_name, '', genRandomString(8)); $server_path = "/home/" . $server_row['ogp_user'] . "/OGP_User_Files/" . $clone_home_id; if ($clone_home_id === FALSE) { print_failure(get_lang_f('cloning_of_home_failed', $home_id)); return; } if (isset($_REQUEST['clone_mods'])) { $enabled_mods = $db->getHomeMods($home_id); if (empty($enabled_mods)) { print_failure(get_lang('note') . ": " . get_lang('no_mods_to_clone')); } else { foreach ($enabled_mods as $enabled_rows) { if ($db->addModToGameHome($clone_home_id, $enabled_rows['mod_cfg_id']) === FALSE) { print_failure(get_lang_f('failed_to_add_mod', $enabled_rows['mod_cfg'], $clone_home_id)); return; } if ($db->updateGameModParams($enabled_rows['max_players'], $enabled_rows['extra_params'], $enabled_rows['cpu_affinity'], $enabled_rows['nice'], $clone_home_id, $enabled_rows['mod_cfg_id']) === FALSE) { print_failure(get_lang_f('failed_to_update_mod_settings', $clone_home_id)); return; } } print_success(get_lang_f('successfully_cloned_mods', $clone_home_id)); } } print_success(get_lang('successfully_copied_home_database')); # do the remote copy call here echo "<p>" . get_lang_f('copying_home_remotely', $server_row['home_path'], $server_path) . "</p>"; $db->logger(get_lang_f('copying_home_remotely', $server_row['home_path'], $server_path)); $clone_rc = $remote->clone_home($server_row['home_path'], $server_path, $user_group); if ($clone_rc == -1) { print_success(get_lang('game_server_copy_is_running')); ?> <div class="html5-progress-bar"> <progress id="progressbar" value="0" max="100"></progress> <span class="progress-value">0%</span> </div> <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id=<?php echo $home_id; ?> &bytes", function( orig_data ) { var orig_size = parseInt(orig_data,10); var refreshId = setInterval(function() { $.get( "home.php?m=user_games&type=cleared&p=get_size&home_id=<?php echo $clone_home_id; ?> &bytes", function( dest_data ) { var dest_size = parseInt(dest_data,10); var progress = parseInt(dest_size * 100 / orig_size); $('#progressbar').val(progress); $('.progress-value').html(progress + '%'); if(progress == 100) { clearInterval(refreshId); } }); }, 2000); }); }); </script> <?php } elseif ($clone_rc == 1) { print_success(get_lang('game_server_copy_was_successful')); } else { print_failure(get_lang_f('game_server_copy_failed_with_return_code', $clone_rc)); } echo "<br><a href='home.php?m=user_games'><< " . get_lang('back_to_game_servers') . "</a>"; return; } // Form to edit game path. $avail_mods = $db->getHomeMods($home_id); $read_status = $remote->remote_readfile('/etc/passwd', $passwd_array); if ($read_status === -1) { print_failure(get_lang('agent_offline')); return; } else { if ($read_status == 1) { $passwd_array = preg_split("/\n/", $passwd_array); } } require_once "includes/form_table_class.php"; $ft = new FormTable(); $ft->start_form('?m=user_games&p=clone'); $ft->add_field_hidden('home_id', $home_id); $ft->start_table(); $ft->add_custom_field('agent_ip', $server_row['agent_ip']); $ft->add_custom_field('current_home_path', $server_row['home_path']); $ft->add_field('string', 'new_home_name', $server_row['home_name']); echo "<tr><td class='right'>" . get_lang('clone_mods') . ":</td>\n\t\t<td class='left'><input type='checkbox' name='clone_mods' value='y' /></td></tr>"; echo "<input name='user_group' type='hidden' value='" . get_user_uid_gid_from_passwd($passwd_array, $server_row['ogp_user']) . "' /></tr>"; echo "</table>"; $ft->add_button('submit', 'clone_home', get_lang('clone_home')); echo "<p class='info'>" . get_lang('the_name_of_the_server_to_help_users_to_identify_it') . "</p>"; echo "</form>"; echo "<h3>" . get_lang('ips_and_ports_used_in_this_home') . "</h3>"; echo "<p>" . get_lang('note_ips_and_ports_are_not_cloned') . "</p>"; $assigned = $db->getHomeIpPorts($home_id); if (!empty($assigned)) { foreach ($assigned as $assigned_rows) { echo "<p>" . $assigned_rows['ip'] . ":" . $assigned_rows['port'] . "</p>\n"; } } $enabled_mods = $db->getHomeMods($home_id); echo "<h3>" . get_lang('mods_and_settings_for_this_game_server') . "</h3>"; if (empty($enabled_mods)) { print_failure(get_lang('note') . ": " . get_lang('note_no_mods')); return; } echo "<table class='center'>\n"; echo "<tr><td>" . get_lang('mod_name') . "</td><td>" . get_lang('max_players') . "</td><td>" . get_lang('extra_cmd_line_args') . "</td><td>" . get_lang('cpu_affinity') . "</td><td>" . get_lang('nice_level') . "</td></tr>\n"; foreach ($enabled_mods as $enabled_rows) { echo "<tr>"; echo "<td>" . $enabled_rows['mod_name'] . "</td>"; echo "<td>" . $enabled_rows['max_players'] . "</td>"; echo "<td>" . $enabled_rows['extra_params'] . "</td>"; echo "<td>" . $enabled_rows['cpu_affinity'] . "</td>"; echo "<td>" . $enabled_rows['nice'] . "</td></tr>\n"; } echo "</table>\n"; }
/** * 密码找回 */ public function public_forget_password() { if (IS_POST) { $email = $this->_post("email"); $code = $this->_post("code"); //验证码开始验证 if (!$this->verify($code)) { $this->error("验证码错误,请重新输入!"); } $Member = M("Member"); $info = $Member->where(array("email" => $email))->find(); if ($info) { //发送邮件 $code = urlencode(authcode($info['username'], '', '', 3600)); $url = CONFIG_SITEURL . "index.php?g=member&c=index&a=public_forget_password&code={$code}"; $message = $this->Member_config['forgetpassword']; $message = str_replace(array('{$click}', '{$url}'), array('<a href="' . $url . '">请点击</a>', $url), $message); SendMail($info['email'], "会员密码找回", $message); $this->success("邮件已经发送到你注册邮箱!", U("Index/login")); } else { $this->error("邮箱地址有误!"); } } else { if ($_GET['code']) { //设置密码 $code = $this->_get("code"); $code = authcode($code, 'DECODE'); $password = genRandomString(6); $status = service("Passport")->user_edit($code, "", $password, "", 1); if ($status) { $this->assign("waitSecond", 10000); $this->success("密码初始化成功,新密码:" . $password . ",请尽快修改!", U("Index/login")); exit; } else { $this->error("密码初始失败,请联系管理员!"); } } $this->display("Public:forget_password"); } }
public function update_password($email) { $this->db->where('email', $email); $data = array('password' => $this->helper_model->encrypt_me($this->input->post('password')), 'activation_reset_key' => genRandomString('42')); $this->db->update('tbl_users', $data); if ($this->db->affected_rows()) { return true; } else { return false; } }