if ($user_info = $_AEYNIAS['class']['mysql']->quick_grab('users', '*', $array)) { ///////////// $_SESSION['user_id'] = $user_info['id']; $_SESSION['username'] = $user_info['username']; $_SESSION['password'] = $user_info['password']; $_AEYNIAS['authentication']['user']['logged_in'] = true; if ($user_info['admin'] == 1) { $_AEYNIAS['authentication']['admin']['logged_in'] = true; } else { $_AEYNIAS['authentication']['admin']['logged_in'] = false; } $_AEYNIAS['authentication']['user']['username'] = $user_info['username']; $_AEYNIAS['authentication']['user']['password'] = $user_info['password']; $_AEYNIAS['authentication']['user']['theme'] = $user_info['theme']; //////////// praise("You have been successfully logged in!"); $page_text = '<a href="' . $_AEYNIAS['config']['doc_url'] . '">Back home?</a>'; if (isset($_SESSION['login_redir'])) { header('LOCATION: ' . $_SESSION['login_redir'][0]); unset($_SESSION['login_redir']); } } else { error('It appears that the username and/or password you supplied is invalid.'); $page_text = $form; } } else { $page_text = $form; } } else { error('You are already logged in!'); $page_text = '';
$usernameField = $changeUsernameFormFields['generic']->createNew()->setLabel('Username')->setName('username')->setValue($_SESSION['username'])->makeRequired('You have to give us a new user name so we can update your information!')->addExpressionCheck(array('expression' => 'if($_SESSION[\'username\'] == $_POST[\'username\'])return false;else return true;', 'message' => 'The username you supplied is exactly the same as your current username. Try being a bit more creative?'))->addExpressionCheck(array('expression' => 'if($_AEYNIAS[\'class\'][\'mysql\']->validate(\'users\',array(\'username\'=>$_POST[\'username\'])))return false;else return true;', 'message' => 'The user name you want is currently in use.')); $changeUsernameSubmitButton = $changeUsernameFormFields['submit']->createNew()->setValue('Change Username.'); $changeUsernameForm->addFields(array($usernameField, $changeUsernameSubmitButton)); $usernameisOkay = $changeUsernameFormFields['validator']->setFields($changeUsernameForm)->applyArgumentsToRequiredFields(array('class' => 'required', 'onfocus' => 'this.removeClassName(\'required\');'))->checkForm(); $page_text .= $changeUsernameForm->printForm(); if ($usernameisOkay) { if ($_AEYNIAS['class']['mysql']->update_row('users', array('username' => $_POST['username']), array('id' => $_SESSION['user_id']))) { praise('Your username has been updated successfully!'); $_SESSION['username'] = $_POST['username']; } else { error('Something went wrong, sorry ...'); } } // Change Theme // $page_text .= "<h2>Change Theme</h2>"; $changeThemeForm = new form_creator(); $changeThemeForm->setName('theme'); $changeThemeFormFields = $changeThemeForm->explodeClasses(); $themeField = $changeThemeFormFields['select']->createNew()->setLabel('Theme')->setName('theme')->setValue($_AEYNIAS['authentication']['user']['theme'])->setOptions($_AEYNIAS['class']['theme']->grab_all_themes())->makeRequired('It would be nice if you actually selected a theme before going all trigger happy on that submit button.')->addExpressionCheck(array('expression' => 'if($_AEYNIAS[\'class\'][\'theme\']->check_if_theme_exists($_POST[\'theme\']))return true;else return false;', 'message' => 'I give you some serious props, you have selected a theme that does not exist.')); $changeThemeSubmitButton = $changeThemeFormFields['submit']->createNew()->setValue('Change Theme.'); $changeThemeForm->addFields(array($themeField, $changeThemeSubmitButton)); $themeisOkay = $changeThemeFormFields['validator']->setFields($changeThemeForm)->applyArgumentsToRequiredFields(array('class' => 'required', 'onfocus' => 'this.removeClassName(\'required\');'))->checkForm(); $page_text .= $changeThemeForm->printForm(); if ($themeisOkay) { if ($_AEYNIAS['class']['mysql']->update_row('users', array('theme' => $_POST['theme']), array('id' => $_SESSION['user_id']))) { praise('Your theme has been updated successfully!'); $_AEYNIAS['authentication']['user']['theme'] = $_POST['theme']; } else { error('Something went wrong, sorry ...'); } }
<?php header("Content-type: text/html; charset=utf-8"); session_start(); require_once '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'Config.php'; require_once '..' . DIRECTORY_SEPARATOR . 'includes' . PATH . 'service' . PATH . 'PageService.php'; $ac = $_GET['ac']; switch ($ac) { case 'img_query': imgQuery($_GET); break; case 'praise': praise($_POST); break; } function praise($req) { $pageid = intval($req['pageid']); $praise = $_SESSION['praise']; if (empty($praise)) { //从没赞过的话初始化Session $_SESSION['praise'] = array("{$pageid}"); PageService::updatePraiseNum($pageid); $response['status'] = 1; echo json_encode($response); return; } $praise = $_SESSION['praise']; if (!in_array($pageid, $praise)) { //如果没有赞过则可以赞 $praise[] = $pageid;
function checkForm($message = null) { $this->setFields(); $errorHasBeenSet = false; global $_AEYNIAS; if (count($this->fields) > 0) { if (isset($_POST['_AEYNIASFormName']) && $_POST['_AEYNIASFormName'] == $this->form->getName()) { foreach ($this->fields as $field) { $name = $field->getName(); foreach ($field->getExpressionsToCheck() as $expression) { if (!eval($expression['expression'])) { error($expression['message']); $errorHasBeenSet = true; $field->setAttributes($this->custom_arguments); break; } } if ($errorHasBeenSet && $this->breakWithOneField) { break; } } if (!$errorHasBeenSet) { if ($message != null) { praise($message); } return true; } else { return false; } } } }