function delete_user($username) { if ($_SESSION['admin'] == 1) { $filecontent = file_get_contents('../private/passwd'); $db = unserialize($filecontent); if (($n = user_exist($username, $db)) !== FALSE) { unset($db[$n]); file_put_contents('../private/passwd', serialize($db)); } if ($username == $_SESSION['log_on_user']) { header('Location: logout.php'); } } }
function auth($mail, $passwd) { if ($mail && $passwd) { $filecontent = file_get_contents('../private/passwd'); $db = unserialize($filecontent); if (($n = user_exist($mail, $db)) !== FALSE) { if ($db[$n]['passwd'] == hash('whirlpool', $passwd)) { $_SESSION['admin'] = $db[$n]['admin']; return TRUE; } else { return FALSE; } } else { return FALSE; } } else { return FALSE; } }
function connexion() { if (isCo()) { redirect(); } modTitle('Planit | Connexion'); if (!empty($_POST)) { loadModel('user'); if (empty($_POST['pseudo']) || empty($_POST['password'])) { setAlert('Merci de remplir tous les champs', 'danger'); } else { if (user_exist($_POST['pseudo'], $_POST['password'])) { $_SESSION['pseudo'] = $_POST['pseudo']; redirect(); } else { setAlert('Mot de passe ou pseudo incorrect', 'danger'); } } } render('connexion'); }
/** * @param PDO $link * @param array $rd * @param bool $nocaptcha * @return array */ function process_registration_form($link, $rd, $nocaptcha = false) { $use_password_verify = defined('SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION') && (SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION === true || is_string(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION) && (trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === 'on' || trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === 'true' || trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === '1')) ? true : false; $ea = array('err' => false, 'usr' => "", 'pass' => "", 'il' => "", 'capt' => ""); $i = parse($rd['user'], USER_MINLENGTH, USER_MAXLENGTH); switch ($i) { case 0: $ea['usr'] = ""; break; case 1: $ea['usr'] = REG_ERR_USR_1; break; case 2: $ea['usr'] = REG_ERR_USR_2; break; case 3: $ea['usr'] = REG_ERR_USR_3; break; case 4: $ea['usr'] = REG_ERR_USR_4; break; } if ($i !== 0) { $ea['err'] = true; } elseif ($rd['user'] == $rd['pass']) { $ea['pass'] = REG_ERR_PASS_1; $ea['err'] = true; } $i = parse($rd['pass'], PASS_MINLENGTH, PASS_MAXLENGTH, 1); switch ($i) { case 2: $ea['pass'] = REG_ERR_PASS_2; break; case 3: $ea['pass'] = REG_ERR_PASS_3; break; case 4: $ea['pass'] = REG_ERR_PASS_4; break; case 5: $ea['pass'] = REG_ERR_PASS_5; break; } if ($i !== 0) { $ea['err'] = true; } elseif (!($rd['pass'] === $rd['pass2'])) { $ea['pass'] = REG_ERR_PASS_6; $ea['err'] = true; } $found = false; foreach ($_SESSION['interface_languages'] as $lang) { if ($lang['val'] == $rd['ilang']) { $found = true; break; } } if ($rd['ilang'] == "" || !$found) { $ea['il'] = REG_ERR_ILANG; $ea['err'] = true; } if ($ea['err'] == false) { if (!$nocaptcha && !captcha_verify_word()) { $ea['capt'] = REG_ERR_CAPT; $ea['err'] = true; } elseif (user_exist($link, $rd['user'])) { $ea['usr'] = REG_ERR_USR_5; $ea['err'] = true; } } if (!$ea['err']) { if (($stmt = $link->query("SELECT name FROM groups ORDER BY RAND() LIMIT 1")) === false || ($row = $stmt->fetch(PDO::FETCH_ASSOC)) === false) { error_log("Database operation error retrieving user registration group."); die("Database operation error."); } $group = $row['name']; /* adding new user to users table */ $use_password_hash = defined('SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION') && (SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION === true || is_string(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION) && (trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === 'on' || trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === 'true' || trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === '1')) ? true : false; $hashedPassword = $use_password_hash ? password_hash($rd['pass'], SYNAPP_PASSWORD_DEFAULT) : hash("sha256", $rd['pass'] . NORAINBOW_SALT); $sql = "INSERT INTO users (\n user\n , pass \n , recovery\n , firstdate\n , hfirstdate\n , missed_logins\n , last_login\n , hlast_login\n , ip\n , last_update\n , interface_language\n , hinterface_language\n , working_group\n , hworking_group\n , input_language\n , hinput_language\n , hprofile\n , gender\n , hgender\n , birthday\n , hbirthday\n , studies\n , hstudies\n , studies_type\n , hstudies_type\n , studies_level\n , hstudies_level\n , occupation\n , hoccupation\n , email\n , hemail\n , email_confirmation_code\n , confirmed_email\n , avatar\n , nocaptcha\n , hstats\n , ditloid_lock_timestamp\n , ditloid_time_left_when_locked\n , gotestbefore \n , gotestafter\n , timer_ctestb_start\n , timer_ctestb_end\n , timer_utestb_start\n , timer_utestb_end\n , timer_utesta_start\n , timer_utesta_end\n , timer_ctesta_start\n , timer_ctesta_end\n , fbid\n , active\n ) VALUES (\n :user\n , :hashedpass \n , :recovery\n , :firstdate\n , b'0' -- hfirstdate\n , 0 -- missed_logins\n , :lastlogin -- last_login\n , b'0' -- hlast_login\n , 0 -- ip\n , 0 -- last_update\n , :ilang -- interface_language\n , b'0' -- hinterface_language\n , :group -- working_group\n , b'0' -- hworking_group\n , :iolang -- input_language\n , b'0' -- hinput_language\n , b'0' -- hprofile\n , '' -- gender\n , b'0' -- hgender\n , NULL -- birthday\n , b'0' -- hbirthday\n , '' -- studies\n , b'0' -- hstudies\n , '' -- studies_type\n , b'0' -- hstudies_type\n , NULL -- studies_level\n , b'0' -- hstudies_level\n , '' -- occupation\n , b'0' -- hoccupation\n , '' -- email\n , b'0' -- hemail\n , :emailconfirmationcode\n , 1 -- confirmed_email\n , '' -- avatar\n , b'0' -- nocaptcha\n , b'0' -- hstats\n , 0 -- ditloid_lock_timestamp\n , 0 -- ditloid_time_left_when_locked\n , 1 -- gotestbefore \n , 0 -- gotestafter\n , 0 -- timer_ctestb_start\n , 0 -- timer_ctestb_end\n , 0 -- timer_utestb_start\n , 0 -- timer_utestb_end\n , 0 -- timer_utesta_start\n , 0 -- timer_utesta_end\n , 0 -- timer_ctesta_start\n , 0 -- timer_ctesta_end\n , :fbid -- fbid\n , 1 -- active\n )"; $stmt = $link->prepare($sql); $stmt->bindValue(':user', $rd['user'], PDO::PARAM_STR); $stmt->bindValue(':hashedpass', $hashedPassword, PDO::PARAM_STR); $prng = new synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG(); $stmt->bindValue(':recovery', $use_password_verify ? password_hash($prng->rand(), SYNAPP_PASSWORD_DEFAULT) : hash("sha256", $prng->rand()), PDO::PARAM_STR); $stmt->bindValue(':firstdate', time(), PDO::PARAM_INT); $stmt->bindValue(':lastlogin', time(), PDO::PARAM_INT); $stmt->bindValue(':ilang', $_SESSION['if_lang'], PDO::PARAM_STR); $stmt->bindValue(':group', $group, PDO::PARAM_STR); $stmt->bindValue(':iolang', $rd['ilang'], PDO::PARAM_STR); $stmt->bindValue(':fbid', isset($rd['fbid']) ? $rd['fbid'] : null, isset($rd['fbid']) ? PDO::PARAM_STR : PDO::PARAM_NULL); $prng = new synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG(); $stmt->bindValue(':emailconfirmationcode', $use_password_hash ? password_hash($prng->rand(), SYNAPP_PASSWORD_DEFAULT) : hash("sha256", $prng->rand()), PDO::PARAM_STR); if ($stmt->execute() === false) { die('Error: ' . var_export($link->errorInfo(), true) . PHP_EOL . $sql); } } return $ea; }
/** * @param PDO $link * @return bool|string */ function process_facebook_login($link) { require_once dirname(__FILE__) . '/' . SYNAPP_CONFIG_DIRNAME . '/facebook_credentials.php'; $fbLoginRedirectUrl = SYNAPP_FB_LOGIN_REDIRECT_URL . (isset($_GET['location']) ? '?location=' . $_GET['location'] : ''); $fbAppId = SYNAPP_FB_APP_ID; $fbAppSecret = SYNAPP_FB_APP_SECRET; $use_password_verify = defined('SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION') && (SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION === true || is_string(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION) && (trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === 'on' || trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === 'true' || trim(strtolower(SYNAPP_USE_PASSWORD_HASH_AUTHENTICATION)) === '1')) ? true : false; try { if (isset($_SESSION['fb_token'])) { $session = new FacebookSession($_SESSION['fb_token']); } else { FacebookSession::setDefaultApplication($fbAppId, $fbAppSecret); $helper = new FacebookRedirectLoginHelper($fbLoginRedirectUrl); try { $session = $helper->getSessionFromRedirect(); if (isset($session)) { $_SESSION['fb_token'] = $session->getToken(); } else { return $helper->getLoginUrl(array('scope' => 'email')); } } catch (FacebookSDKException $ex) { // When Facebook returns an error return $helper->getLoginUrl(array('scope' => 'email')); } catch (Exception $ex) { // When validation fails or other local issues return $helper->getLoginUrl(array('scope' => 'email')); } } if (isset($session)) { // Logged in $graphObject = (new FacebookRequest($session, 'GET', '/me?fields=id,email,first_name,last_name'))->execute()->getGraphObject(GraphUser::className()); $sql = "SELECT * FROM `users` WHERE fbid = :fbid OR email = :email AND confirmed_email = b'1'"; $stmt = $link->prepare($sql); $stmt->bindValue(':fbid', $graphObject->getProperty('id'), PDO::PARAM_STR); $stmt->bindValue(':email', $graphObject->getProperty('email'), PDO::PARAM_STR); if ($stmt->execute() !== false && $stmt->rowCount() > 0) { $user_array = $stmt->fetch(PDO::FETCH_ASSOC); if ($user_array['active'] == 0) { $_SESSION['login_err'] = 403; return false; } $_SESSION['user_array'] = $user_array; $_SESSION['auth'] = true; $_SESSION['justlogged'] = true; $_SESSION['if_lang'] = $_SESSION['user_array']['interface_language']; $_SESSION['user_count'] = 1; $_SESSION['pass_count'] = 0; $_SESSION['user_array']['missed_logins'] = 0; $time = time(); if (($ip = ip2long($_SERVER['REMOTE_ADDR'])) === false) { $ip = 0; } $sql = "UPDATE users SET recovery = :recovery, missed_logins='0', last_login = :time, ip = :ip WHERE user = :user"; $stmt = $link->prepare($sql); $prng = new synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG(); $stmt->bindValue(':recovery', $use_password_verify ? password_hash($prng->rand(), SYNAPP_PASSWORD_DEFAULT) : hash("sha256", $prng->rand()), PDO::PARAM_STR); $stmt->bindValue(':time', $time, PDO::PARAM_INT); $stmt->bindValue(':ip', $ip, PDO::PARAM_INT); $stmt->bindValue(':user', $_SESSION['user_array']['user'], PDO::PARAM_STR); if ($stmt->execute() === false) { error_log(var_export($link->errorInfo(), true)); die("Error performing database operation."); } return true; } $rd['user'] = substr(preg_replace("/[^a-zA-Z0-9]+/", "", $graphObject->getProperty('first_name') . $graphObject->getProperty('last_name')), 0, USER_MAXLENGTH); $i = 0; while (user_exist($link, $rd['user'])) { $rd['user'] = substr(preg_replace("/[^a-zA-Z0-9]+/", "", $i . $graphObject->getProperty('first_name') . $graphObject->getProperty('last_name')), 0, USER_MAXLENGTH); $i++; } $rd['pass'] = substr(hash("sha256", $_SESSION['fb_token']), 0, PASS_MAXLENGTH); $rd['pass2'] = $rd['pass']; $rd['ilang'] = $_SESSION['if_lang']; $rd['fbid'] = $graphObject->getProperty('id'); $ea = process_registration_form($link, $rd, true); if ($ea['err'] !== true) { $sql = "UPDATE `users` SET fbid = :fbid, email = :email, confirmed_email = b'1' WHERE user = :user"; $stmt = $link->prepare($sql); $stmt->bindValue(':fbid', $graphObject->getProperty('id'), PDO::PARAM_STR); $stmt->bindValue(':email', $graphObject->getProperty('email'), PDO::PARAM_STR); $stmt->bindValue(':user', $rd['user'], PDO::PARAM_STR); return $stmt->execute() !== false; } return $ea['err'] !== true; } else { header('Location: account/logout.php'); die; } } catch (FacebookSDKException $ex) { // When Facebook returns an error error_log("FacebookRequestException: " . $ex->getMessage()); header('Location: account/logout.php'); die; } catch (Exception $ex) { // When validation fails or other local issues error_log("Exception on facebook login: " . $ex->getMessage()); header('Location: account/logout.php'); die; } }
} else { if (user_exist($username) === false) { ?> <div class="container" > <div class="row" style="padding: 15px;"> <div class="col-lg-4"></div> <div class="alert alert-danger alert-dismissible col-lg-4" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close" ><span aria-hidden="true">×</span></button> <strong>Warning!</strong> Your Username is incorrect. </div> <div class="col-lg-4"></div> </div> </div> <?php } else { if (user_exist($username) === true && password_exist($password) === false) { ?> <div class="container" > <div class="row" style="padding: 15px;"> <div class="col-lg-4"></div> <div class="alert alert-danger alert-dismissible col-lg-4" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close" ><span aria-hidden="true">×</span></button> <strong>Warning!</strong> Your Password is incorrect. </div> <div class="col-lg-4"></div> </div> </div> <?php } else { $login = login($username, $password); if ($login === false) {
function user_login_id_03($username, $password) { if (config('salt') === true) { if (user_exist($username)) { $user_id = user_id($username); $username = sanitize($username); $data = mysql_select_single("SELECT `salt`, `id`, `name`, `password` FROM `accounts` WHERE `id`='{$user_id}';"); $salt = $data['salt']; if (!empty($salt)) { $password = sha1($salt . $password); } else { $password = sha1($password); } return $data !== false && $data['name'] == $username && $data['password'] == $password ? $data['id'] : false; } else { return false; } } else { return user_login_id($username, $password); } }
} else { if (strlen($_POST['username']) > 64) { $ret["msg"] = "Username too long!"; } else { $s = convert_str($_POST['username']); for ($i = 0; $i < strlen($s); $i++) { if ($s[$i] >= '0' && $s[$i] <= '9' || $s[$i] >= 'a' && $s[$i] <= 'z' || $s[$i] >= 'A' && $s[$i] <= 'Z' || $s[i] == '-' || $s[i] == '_') { continue; } else { break; } } if ($i != strlen($s)) { $ret["msg"] = "Invalid Username!"; } else { if (user_exist($_POST['username'])) { $ret["msg"] = "Username Already Exists!"; } else { if (strlen($_POST['password']) < 3) { $ret["msg"] = "Password too short!"; } else { if ($_POST['password'] != $_POST['repassword']) { $ret["msg"] = "Password doesn't match!"; } else { $row[0] = $_POST['username']; $row[1] = $_POST['password']; if ($_POST['nickname'] == "") { $row[2] = $_POST['username']; } else { $row[2] = $_POST['nickname']; }
<?php include_once dirname(__FILE__) . "/../functions/users.php"; $name1 = convert_str($_GET['name1']); $name2 = convert_str($_GET['name2']); if (!user_exist($name1) || !user_exist($name2)) { echo "<b>No Such User!</b>"; die; } foreach ((array) $db->get_results("select distinct pid from status where username='******' and result='Accepted' order by pid", ARRAY_N) as $temp) { $mapa1[$temp[0]] = true; } foreach ((array) $db->get_results("select distinct pid from status where username='******' order by pid", ARRAY_N) as $temp) { $mapt1[] = $temp[0]; } foreach ((array) $db->get_results("select distinct pid from status where username='******' and result='Accepted' order by pid", ARRAY_N) as $temp) { $mapa2[$temp[0]] = true; } foreach ((array) $db->get_results("select distinct pid from status where username='******' order by pid", ARRAY_N) as $temp) { $mapt2[] = $temp[0]; } $numt1 = $numt2 = 0; foreach ((array) $mapt1 as $temp) { $pidt1[$numt1++] = $temp; } foreach ((array) $mapt2 as $temp) { $pidt2[$numt2++] = $temp; } $nboth = $nonly1 = $nonly2 = $ntbf1 = $ntbf2 = $natbf = 0; $i = $j = 0; while ($i < $numt1 || $j < $numt2) {
<?php include_once '../functions/users.php'; echo json_encode(user_exist($_POST['username']));
<?php include 'core/init.php'; include 'includes/head.php'; include 'includes/header.php'; ?> <div id="center"> <?php if (isset($_GET['username']) === true && empty($_GET['username']) === false) { $username = $_GET['username']; if (user_exist($username) === true) { $user_id = user_id_from_username($username); $profile_data = user_data($user_id, 'first_name', 'last_name', 'email'); ?> <h1><?php echo $profile_data['first_name']; ?> 's Profile </h1> <div class="profile"> <h2> Hello,<?php echo $user_data['first_name']; ?> !! </h2> <?php if (isset($_FILES['profile']) === true) { if (empty($_FILES['profile']['name']) === true) { echo 'Please Choose a File';
logged_in_redirect(); include 'layout/overall/header.php'; if (empty($_POST) === false) { if ($config['log_ip']) { znote_visitor_insert_detailed_data(5); } $username = $_POST['username']; $password = $_POST['password']; //data_dump($_POST, false, "POST"); if (empty($username) || empty($password)) { $errors[] = 'You need to enter a username and password.'; } else { if (strlen($username) > 32 || strlen($password) > 64) { $errors[] = 'Username or password is too long.'; } else { if (user_exist($username) === false) { $errors[] = 'Failed to authorize your account, are the details correct, have you <a href=\'register.php\'>register</a>ed?'; } else { if (!Token::isValid($_POST['token'])) { Token::debug($_POST['token']); $errors[] = 'Token is invalid.'; } else { // Starting loging if ($config['TFSVersion'] == 'TFS_02' || $config['TFSVersion'] == 'TFS_10') { $login = user_login($username, $password); } else { if ($config['TFSVersion'] == 'TFS_03') { $login = user_login_03($username, $password); } else { $login = false; }
include 'header.php'; function user_exist($mail, $db) { foreach ($db as $l => $m) { if ($m['mail'] == $mail) { return $l; } } return FALSE; } if ($_POST['submit'] == 'OK') { if ($_POST['mail'] && $_POST['newpw'] && $_POST['oldpw']) { $filecontent = file_get_contents('../private/passwd'); $db = unserialize($filecontent); if (($n = user_exist($_POST['mail'], $db)) !== FALSE) { if ($db[$n]['passwd'] == hash('whirlpool', $_POST['oldpw'])) { $db[$n]['passwd'] = hash('whirlpool', $_POST['newpw']); file_put_contents('../private/passwd', serialize($db)); header("Location: index.php"); print "OK\n"; } else { } ?> <div class="error_psw_usr">Wrong username or password, Please try again!</div> <?php } ?> <div class="error_psw_usr">Wrong username or password, Please try again!</div> <?php }
$email = addslashes($_POST['email']); $user = addslashes($_POST['new_user']); $pass = $_POST['password']; $repeat_pass = $_POST['repeat_password']; $teams = $_POST['team']; $admin = isset($_POST['admin']) ? '1' : '0'; $submit_risks = isset($_POST['submit_risks']) ? '1' : '0'; $modify_risks = isset($_POST['modify_risks']) ? '1' : '0'; $plan_mitigations = isset($_POST['plan_mitigations']) ? '1' : '0'; $review_high = isset($_POST['review_high']) ? '1' : '0'; $review_medium = isset($_POST['review_medium']) ? '1' : '0'; $review_low = isset($_POST['review_low']) ? '1' : '0'; // Verify that the two passwords are the same if ("{$pass}" == "{$repeat_pass}") { // Verify that the user does not exist if (!user_exist($user)) { // Generate the salt $salt = generateSalt($user); // Generate the password hash $hash = generateHash($salt, $pass); // Create a boolean for all $all = false; // Create a boolean for none $none = false; // Create the team value foreach ($teams as $value) { // If the selected value is all if ($value == "all") { $all = true; } // If the selected value is none
} } // check errors (= user exist, pass long enough if (empty($errors) === true) { /* Token used for cross site scripting security */ if (!Token::isValid($_POST['token'])) { $errors[] = 'Token is invalid.'; } if ($config['use_captcha']) { include_once 'captcha/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { $errors[] = 'Captcha image verification was submitted wrong.'; } } if (user_exist($_POST['username']) === true) { $errors[] = 'Sorry, that username already exist.'; } // Don't allow "default admin names in config.php" access to register. $isNoob = in_array(strtolower($_POST['username']), $config['page_admin_access']) ? true : false; if ($isNoob) { $errors[] = 'This account name is blocked for registration.'; } if (strtolower($_POST['username']) === true) { $errors[] = 'Sorry, that username already exist.'; } if (preg_match("/^[a-zA-Z0-9]+\$/", $_POST['username']) == false) { $errors[] = 'Your account name can only contain characters a-z, A-Z and 0-9.'; } // name restriction $resname = explode(" ", $_POST['username']);
<?php include_once dirname(__FILE__) . "/../functions/users.php"; $username = convert_str($_POST['username']); $password = hash_password($_POST['password']); $ret = array(); if (!user_exist($username)) { $ret["code"] = 1; $ret["msg"] = "No such user!"; echo json_encode($ret); die; } if (!$current_user->set_user($username, $password)) { $ret["code"] = 1; $ret["msg"] = "Password incorrect!"; } else { $exp = time() + $_POST['cksave'] * 24 * 60 * 60; if ($_POST['cksave'] == 0) { $exp = 0; } set_cookies($username, $password, $exp); $current_user->update_last_login($username); $ret["code"] = 0; $ret["msg"] = "Success..."; } echo json_encode($ret);
function index() { modTitle('Planit | Inscription'); if (!empty($_POST)) { $ok = 1; foreach ($_POST as $k => $v) { if (empty($v)) { setAlert('Merci de remplir tous le champs', 'danger'); $ok = 0; break; } $_POST[$k] = htmlentities($v); } if ($ok) { loadModel('user'); extract($_POST); /* Verification pseudo */ if (!ctype_alnum($pseudo)) { setAlert('Le pseudo doit etre alpha-numeric', 'danger'); $ok = 0; } else { if (user_exist($pseudo)) { setAlert('Le pseudo est deja utilise', 'danger'); $ok = 0; } } //verif sexe if (!in_array($sexe, ['homme', 'femme'])) { setAlert('le sexe n\'est pas valide, tu as essayé d\'escroquer salopard', 'danger'); $ok = 0; } /* Verification nom/prenom */ if (empty($prenom) || empty($nom)) { setAlert('Le nom et le prénom doivent contenir des lettres', 'danger'); $ok = 0; } //Verif date de naissance if ($jour == 1 && $mois == 01 && $annee == 2015 || !checkdate($mois, $jour, $annee) || time() - mktime(0, 0, 0, $mois, $jour, $annee) < 0) { setAlert('Veuillez modifier la date de naissance', 'danger'); $ok = 0; } /* Verif email */ if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { setAlert('Email non valide', 'danger'); $ok = 0; } else { if (mail_exist($mail)) { setAlert('Adresse mail existe déjà', 'danger'); $ok = 0; } } //verification que les mots de passe correspondent if ($mdp !== $cmdp) { setAlert('Les mots de passe ne correspondent pas', 'danger'); $ok = 0; } if ($mdp <= "4" && $cmdp <= "4") { setAlert('Le mot de passe doit faire 4 caractère minimum.', 'danger'); $ok = 0; } if ($ok) { //Requete sql $mdp = md5($mdp); if (!add_user($sexe, $nom, $prenom, $pseudo, $mail, $mdp, $annee . '-' . $mois . '-' . $jour)) { setAlert('Erreur', 'danger'); } else { setAlert('Vous êtes bien inscrit.', 'success'); $_SESSION['pseudo'] = $pseudo; header('Refresh:5; url=home'); } } } } render('inscription', 'user'); }
<?php include_once dirname(__FILE__) . "/../functions/users.php"; $reciever = convert_str($_POST['reciever']); $title = convert_str($_POST['title']); $content = convert_str($_POST['content']); $ret = array(); $ret["code"] = 1; if (!$current_user->is_valid()) { $ret["msg"] = "Please Login!"; } else { if (!user_exist($reciever)) { $ret["msg"] = "No Such Reciever."; } else { if ($title == "") { $title = "No Title"; } $query = "insert into mail set sender='{$nowuser}', reciever='{$reciever}', content='{$content}', title='{$title}', mail_time=now(), status=false"; $res = $db->query($query); $ret["code"] = 0; $ret["msg"] = "Success."; } } echo json_encode($ret);
$sql = "insert into contest_problem (cid ,pid,lable) values ('" . $cid . "','" . $pid[$i] . "','" . $lable[$i] . "')"; } else { $sql = "insert into contest_problem (cid ,pid,lable,type,base,minp,para_a,para_b,para_c,para_d,para_e) values\n ('" . $cid . "','" . $pid[$i] . "','" . $lable[$i] . "','" . $ptype[$i] . "','" . $base[$i] . "','" . $minp[$i] . "','" . $paraa[$i] . "','" . $parab[$i] . "','" . $parac[$i] . "','" . $parad[$i] . "','" . $parae[$i] . "')"; } $db->query($sql); } $cres = $db->query("select problem.title from contest_problem,problem where cid=" . $cid . " and contest_problem.pid=problem.pid"); $str = array(); foreach ((array) $db->get_results(null, ARRAY_N) as $crow) { $str[] = trim(strtolower($crow[0])); } sort($str); $db->query("update contest set allp='" . md5(implode($str, $config["salt_problem_in_contest"])) . "' where cid=" . $cid); $names = preg_split("/[^A-Z0-9a-z_-]+/", $_POST["names"]); foreach ($names as $tmp) { if (!user_exist($tmp)) { $ret["msg"] .= "No such user {$tmp}.<br />"; } else { if (contest_has_user($cid, $tmp)) { $ret["msg"] .= "User {$tmp} already in contest {$cid}.<br />"; } else { $que = "insert into contest_user set cid={$cid}, username='******'"; $db->query($que); } } } } } else { $ret["msg"] = "Please login as root!"; } echo json_encode($ret);