<?php $success = array(); $errors = array(); if (isset($_POST['submit'])) { if (isset($_POST['email']) && isset($_POST['password'])) { if (!empty($_POST['email']) && !empty($_POST['password'])) { if (isAccount($_POST['email'], hash("sha256", $_POST['password']))) { $_SESSION['id'] = User::getId($_POST['email']); // DEFINE SESSION - PUT USER ONLINE updateIp($_SERVER['REMOTE_ADDR'], $_POST['email']); // UPDATE LAST IP IN DATABASE $success[] = "Vous êtes bien connecté."; // DEFINE SUCCESS MESSAGE } else { $errors[] = "Cet utilisateur n'existe pas. Veuillez verifier vos identifiants."; } } else { $errors[] = "Tous les champs doivent être remplit."; } } else { $errors[] = "Veuillez verifier que vous avez bien remplit le formulaire."; } }
function removeAccount($account) { if (isAccount($account)) { $account = $account->getName(); } elseif (is_object($account)) { return false; } // What kind of object are you giving me?! $account_key = strtolower($account); if (!array_key_exists($account_key, $this->accounts)) { return false; } unset($this->accounts[$account_key]); return true; }
/** * irc_vsprintf: Identical to vsprintf, except extended to allow the IRC-specific * conversion specifiers documented with irc_sprintf. */ function irc_vsprintf($format, $args) { $std_types = 'bcdeufFosxX'; $custom_types = 'ACHNU'; $len = strlen($format); $arg_index = -1; $pct_count = 0; for ($i = 0; $i < $len - 1; $i++) { $char = $format[$i]; $next = $format[$i + 1]; if ($char == '%') { $pct_count++; } else { $pct_count = 0; } /** * Skip this character if we don't have the start of a spec yet, or * if we do and the following character is a '%', indicating that * vsprintf will simply substitute a percent sign. */ if ($pct_count != 1 || $next == '%') { continue; } // Found a spec; hold its place $spec_start = $i; $spec_end = $i + 1; $type = ''; /** * Loop through the characters immediately following so that we can * attempt to find the type of spec this is. The formatting flags will * be preserved, so we'll ignore them. */ for ($j = $i + 1; $j < $len; $j++) { $tmp_char = $format[$j]; $is_std_type = false !== strpos($std_types, $tmp_char); $is_cust_type = false !== strpos($custom_types, $tmp_char); if ($is_std_type || $is_cust_type) { // Found a valid standard or custom flag, mark its place and stop $type = $tmp_char; $arg_index++; $spec_end = $j; break; } } // If we found a custom type in this spec, process it accordingly if ($is_cust_type) { $arg_obj = $args[$arg_index]; $cust_text = ''; switch ($type) { /** * %A: Flat array to string conversion */ case 'A': $cust_text = implode(' ', $arg_obj); break; /** * %H: Human-readable name of given object */ /** * %H: Human-readable name of given object */ case 'C': case 'H': if (isUser($arg_obj)) { $cust_text = $arg_obj->getNick(); } elseif (isChannel($arg_obj) || isServer($arg_obj)) { $cust_text = $arg_obj->getName(); } elseif (isGline($arg_obj)) { $cust_text = $arg_obj->getMask(); } break; /** * %N: ircu P10 numeric of given object */ /** * %N: ircu P10 numeric of given object */ case 'N': if (isUser($arg_obj) || isServer($arg_obj)) { $cust_text = $arg_obj->getNumeric(); } break; /** * %U: Account name of user or account object */ /** * %U: Account name of user or account object */ case 'U': if (isUser($arg_obj)) { $cust_text = $arg_obj->getAccountName(); } elseif (isAccount($arg_obj)) { $cust_text = $arg_obj->getName(); } break; /** * I'm sorry, Dave, I'm afraid I can't do that. * Will pass this unknown spec to vsprintf as-is. */ /** * I'm sorry, Dave, I'm afraid I can't do that. * Will pass this unknown spec to vsprintf as-is. */ default: continue; } /** * Change the custom flag to an 's' (string) and replace the argument * with whatever string we determined was most appropriate for it. */ $format[$spec_end] = 's'; $args[$arg_index] = $cust_text; /** * No need to look at this entire spec anymore, so advance to the next * char after the end of the spec. */ $i = $spec_end + 1; } } // vsprintf takes care of the standard flags. return vsprintf($format, $args); }
function getChannelAccessAccount($chan_name, $account_obj) { $chan_key = strtolower($chan_name); if (!($chan = $this->getChannelReg($chan_key))) { return false; } if (!isAccount($account_obj)) { return false; } $levels = $chan->getLevels(); if (!array_key_exists($account_obj->getId(), $levels)) { return false; } return $levels[$account_obj->getId()]; }
function getUserLevel($user_obj) { if (!is_object($user_obj)) { return 0; } if (!isAccount($user_obj) && (!isUser($user_obj) || !$user_obj->isLoggedIn())) { return 0; } if (!isAccount($user_obj)) { $account = $this->getAccount($user_obj->getAccountName()); } else { $account = $user_obj; } $res = db_query("select `level` from `ns_admins` where user_id = " . $account->getId()); if ($res && mysql_num_rows($res) > 0) { $level = mysql_result($res, 0); mysql_free_result($res); return $level; } return 1; }