if (isset($_POST['submit'])) { $password = isset($_POST['password']) ? trim(strip_tags($_POST['password'])) : null; $password_confirm = isset($_POST['password_confirm']) ? trim(strip_tags($_POST['password_confirm'])) : null; // validation if (is_null($password) || strlen($password) < 6) { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Password needs to be more than 6 characters. Please try again', 'zh' => '密码至少需要6位。请重试')))); HTML::forwardBackToReferer(); } else { if ($password != $password_confirm) { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Password and confirmed password don\'t match. Please try again', 'zh' => '密码和确认密码不符。 请重试')))); HTML::forwardBackToReferer(); } } // success $user->putPassword($password); $user->save(); Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Your password has been successfully updated. You may sign in below', 'zh' => '您的密码已经成功更新了。您现在可以登录了')))); HTML::forward('users'); } // override this call if "site" module has the override controller $override_controller = MODULESROOT . '/site/controllers/siteuser/forget_password_reset.php'; if (is_file($override_controller)) { require $override_controller; exit; } // default $html = new HTML(); $html->renderOut('core/backend/single_form_header', array('title' => i18n(array('en' => 'Reset your password', 'zh' => '重置您的密码')))); echo SiteUser::renderPasswordResetForm(); $html->renderOut('core/backend/single_form_footer', array('extra' => '<div style="text-align: center;"><small class="signup"><a href="' . uri('users') . '">' . i18n(array('en' => 'go back to login', 'zh' => '返回登录界面')) . '</a></small></div>')); exit;
<?php Log::truncate(); Message::register(new Message(Message::SUCCESS, 'Log emptied')); HTML::forward('admin/log/list');
<?php $id = isset($vars[1]) ? $vars[1] : null; $object = Client::findById($id); $error_flag = false; if ($object) { if ($object->delete()) { Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Record deleted', 'zh' => '记录删除成功')))); } else { $error_flag = true; } } else { $error_flag = true; } if ($error_flag) { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Record deletion failed', 'zh' => '记录删除失败')))); } HTML::forwardBackToReferer();
<?php $uid = isset($vars[1]) ? $vars[1] : null; $salt = isset($vars[2]) ? $vars[2] : null; $salt = is_null($salt) ? $salt : decrypt($salt); // validation if (is_null($uid) || is_null($salt)) { HTML::forward('core/404'); } $user = SiteUser::findById($uid); if (is_null($user) || $user->getSalt() != $salt) { HTML::forward('core/404'); } // do resend email $user->sendAccountActivationEmail(); Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Account activation email resent successfully. Please check your mail box', 'zh' => '账号激活邮件发送成功,请查看您的邮箱')))); HTML::forwardBackToReferer();
unset($_POST); } } else { Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'User updated successfully', 'zh' => '用户更新成功')))); } // update user-role if (is_backend()) { if (!empty($roles)) { // delete existing relationships for user - role if update if (!empty($uid)) { $urs = SiteUserRole::findByUid($uid); foreach ($urs as $ur) { $ur->delete(); } } // create new relationships for user - role foreach ($roles as $rid => $val) { if ($val) { $ur = new SiteUserRole(); $ur->setRoleId($rid); $ur->setUserId($user->getId()); $ur->save(); } } } } } else { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Sorry, there is a system error when processing your request', 'zh' => '抱歉,系统出错了')))); } } }
<?php $maintenance = Vars::findByName('maintenance'); $maintenance = $maintenance ? $maintenance->getValue() : 0; // handle form submission if (isset($_POST['submit'])) { $switch = isset($_POST['switch']) && $_POST['switch'] == 1 ? 1 : 0; $var = new Vars(); $var->setName('maintenance'); $var->setValue($switch); $var->save(); Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Maintenance mode updated', 'zh' => '系统维护模式已更新')))); HTML::forward('admin/maintenance'); exit; } // presentation $html = new HTML(); $html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Maintenance mode', 'zh' => '系统维护设置'))), true); $html->output('<div id="wrapper">'); $html->renderOut('core/backend/header'); $html->renderOut('core/backend/maintenance', array('maintenance' => $maintenance)); $html->output('</div>'); $html->renderOut('core/backend/html_footer'); exit;
if (empty($email)) { $messages[] = new Message(Message::DANGER, i18n(array('en' => 'Please enter the e-mail address you registered with us', 'zh' => '请填写您注册是使用的电子邮箱'))); } else { $user = SiteUser::findByEmail($email); if (is_null($user)) { $messages[] = new Message(Message::DANGER, i18n(array('en' => 'No record found registered with this e-mail', 'zh' => '未找到使用该邮箱注册的记录'))); } } // if succeed, send email if (sizeof($messages) == 0) { if ($user = SiteUser::findByEmail($email)) { $user->sendPasswordResetEmail(); } Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'We\'ve sent an email to your mail box to reset your password. Please check your mail box.', 'zh' => '我们已向您注册的邮箱发送密码重置链接,请查看您的邮箱并点击链接重置您的密码')))); } else { Message::register($messages); } HTML::forwardBackToReferer(); } // override this call if "site" module has the override controller $override_controller = MODULESROOT . '/site/controllers/siteuser/forget_password.php'; if (is_file($override_controller)) { require $override_controller; exit; } $html = new HTML(); $html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Password reset', 'zh' => '重置密码')))); $html->renderOut('core/backend/single_form_header', array('title' => i18n(array('en' => 'Password reset', 'zh' => '重置密码')))); echo SiteUser::renderForgetPasswordForm(); $html->renderOut('core/backend/single_form_footer', array('extra' => '<div class="login" style="text-align: center;"><small><a href="' . uri('users') . '">' . i18n(array('en' => 'go back to login page', 'zh' => '返回登录页面')) . '</a></small></div>')); $html->renderOut('core/backend/html_footer');
<?php $uid = isset($vars[1]) ? $vars[1] : null; $salt = isset($vars[2]) ? $vars[2] : null; $salt = is_null($salt) ? $salt : decrypt($salt); // validation if (is_null($uid) || is_null($salt)) { HTML::forward('core/404'); } $user = SiteUser::findById($uid); if (is_null($user) || $user->getSalt() != $salt) { Message::register(new Message(Message::INFO, i18n(array('en' => 'This account activate link has expired', 'zh' => '本账号激活链接已失效')) . '<br /><small><a href="' . uri('users') . '">' . i18n(array('en' => 'go to login page', 'zh' => '前往登录页面')) . '</a></small>')); HTML::forward('core/404'); } // mail activate the user $activated = $user->getEmailActivated(); if ($activated == 1) { Message::register(new Message(Message::INFO, i18n(array('en' => 'You\'ve already activated your acount. No need to do it again.', 'zh' => '您的账号已被激活,无需再次激活')) . '<br /><small><a href="' . uri('users') . '">' . i18n(array('en' => 'login now', 'zh' => '马上登录')) . '</a></small>')); } else { $user->setEmailActivated(1); $user->save(); Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Congratulation! Your account has been successfully activated.', 'zh' => '恭喜!您的账号已经被成功激活')) . '<br /><small><a href="' . uri('users') . '">' . i18n(array('en' => 'login now', 'zh' => '马上登录')) . '</a></small>')); } HTML::forward('confirm');
<?php $id = strip_tags($_POST['menu_id']); $menu = Menu::findById($id); if ($menu) { $country_id = strip_tags($_POST['country_id']); $menu->setCountryId($country_id); $menu->save(); Message::register(new Message(Message::SUCCESS, 'Menu updated successfully.')); } else { Message::register(new Message(Message::DANGER, 'Menu update failed.')); } HTML::forwardBackToReferer();
<?php // handle submission if (isset($_POST['submit'])) { SitePermissionRole::truncate(); foreach ($_POST as $key => $val) { if (strstr($key, 'role_')) { $tokens = explode('_', $key); $role_id = (int) $tokens[1]; foreach ($val as $permission_id => $v) { $spr = new SitePermissionRole(); $spr->setRoleId($role_id); $spr->setPermissionId($permission_id); $spr->save(); } } } Message::register(new Message(Message::SUCCESS, 'Permissions updated successfully!')); HTML::forwardBackToReferer(); } $html = new HTML(); $html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Manage permission', 'zh' => '管理权限'))), true); $html->output('<div id="wrapper">'); $html->renderOut('core/backend/header'); $html->renderOut('siteuser/backend/permission/manage', array('permissions' => SitePermission::findAll(), 'roles' => SiteRole::findAll()), true); $html->output('</div>'); $html->renderOut('core/backend/html_footer'); exit;
<?php $uid = $vars[1]; $class = class_exists('MySiteUser') ? 'MySiteUser' : 'SiteUser'; $user = $class::findById($uid, $class); if (empty($user)) { HTML::forward('core/404'); } if ($user->delete()) { Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'User <i>' . $user->getUsername() . '</i> deleted successfully.', 'zh' => '用户 <i>' . $user->getUsername() . '</i> 删除成功')))); } else { Message::register(new Message(Message::DANGER, i18n(array('en' => 'User <i>' . $user->getUsername() . '</i> deleted failed.', 'zh' => '用户 <i>' . $user->getUsername() . '</i> 删除失败')))); } HTML::forwardBackToReferer();
<?php $qid = isset($vars[1]) ? $vars[1] : null; $queue = Queue::findById($qid); if (!$queue) { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Queue record does not exist', 'zh' => '队列项不存在')))); } else { try { $function = $queue->getFunction(); if (!function_exists($function)) { throw new Exception(i18n(array('en' => "Function {$function} does not exist", 'zh' => "函数{$function不存在}"))); } if (Queue::fetchAndProceedByQueueId($qid)) { Message::register(new Message(Message::SUCCESS, 'Queue item run successfully')); } else { Message::register(new Message(Message::DANGER, 'Queue item run failed')); } } catch (Exception $e) { Message::register(new Message(Message::DANGER, $e->getMessage())); } } HTML::forwardBackToReferer();
} if (empty($msg)) { $messages[] = new Message(Message::DANGER, i18n(array('en' => 'Please enter your message', 'zh' => '请填写您的留言'))); } if (!empty($messages)) { Message::register($messages); HTML::forward($_SERVER['HTTP_REFERER'] . '#contact-form'); } // check spam if (module_enabled('form') && !Form::checkSpamToken('global contact form')) { $message = new Message(Message::DANGER, i18n(array('en' => 'Form login session expired. Please try again', 'zh' => '表单提交时限过期,请重新尝试登录'))); Message::register($message); HTML::forward($_SERVER['HTTP_REFERER'] . '#contact-form'); } /** success action **/ Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Thank you for your contact ;) We will get back to you soon.', 'zh' => '感谢您的留言 ;) 我们会及时和您沟通')))); if (module_enabled('mail')) { $message = array(); foreach ($_POST['contact'] as $key => $val) { $message[] = "<p><strong>{$key}</strong>:<br />" . str_replace("\n", "<br />", $val) . "</p><br />"; } $message = implode("\n", $message); sendemailAdmin('Site contact form', $message); } HTML::forward($_SERVER['HTTP_REFERER'] . '#contact-form'); } $html = new HTML(); $html->renderOut('site/components/html_header', array('title' => 'Contact', 'body_class' => 'page page-template page-template-templates page-template-full-width page-template-templatesfull-width-php has-toolbar')); $html->output('<div id="page-container">'); //$html->renderOut('site/components/toptoolbar'); $html->renderOut('site/components/header');
require_permission('管理用户权限'); /** prepare vars **/ $myuser = MySiteUser::getCurrentUser(); /** handle submission **/ if (isset($_POST['submit'])) { SitePermissionRole::truncate(); foreach ($_POST as $key => $val) { if (strstr($key, 'role_')) { $tokens = explode('_', $key); $role_id = (int) $tokens[1]; foreach ($val as $permission_id => $v) { $spr = new SitePermissionRole(); $spr->setRoleId($role_id); $spr->setPermissionId($permission_id); $spr->save(); } } } Message::register(new Message(Message::SUCCESS, '用户权限更新成功!')); HTML::forwardBackToReferer(); } /** presentation **/ $html = new HTML(); $html->renderOut('site/components/html_header', array('title' => '管理用户权限', 'body_class' => 'permission')); $html->renderOut('site/components/mainnav', array('user' => $myuser)); $html->output('<div id="page-wrapper" class="gray-bg">'); $html->renderOut('site/components/topnav', array('user' => $myuser)); $html->renderOut('site/components/page_header', array('title' => '管理用户权限', 'breadcrumb' => array('首页' => uri(''), '客户管理' => '#', '管理用户权限' => '#'))); $html->renderOut('site/siteuser_permission', array('permissions' => SitePermission::findAll(), 'roles' => SiteRole::findAll())); $html->output('</div>'); $html->renderOut('site/components/html_footer');
<?php /** handle submission **/ if (isset($_POST['submit'])) { $content = "<table>"; foreach ($_POST as $key => $val) { $tokens = explode("_", $key); $key = ""; foreach ($tokens as $token) { $key .= ucfirst($token) . " "; } $content .= "<tr><th>{$key}</th><td>{$val}</td></tr>"; } $content .= "</table>"; sendemailAdmin($settings['sitename'] . " - Apply for course", $content); Message::register(new Message(Message::SUCCESS, 'Thank you for your application. We will contact you soon!')); } $html = new HTML(); $html->renderOut('site/components/html_header', array('title' => 'Apply for a course', 'body_class' => 'page page-template page-template-templates page-template-full-width page-template-templatesfull-width-php has-toolbar')); $html->output('<div id="page-container">'); //$html->renderOut('site/components/toptoolbar'); $html->renderOut('site/components/header'); $html->renderOut('site/apply', array('full_page_sidebar_right' => $html->render('site/components/full_page_sidebar_right', array('blocks' => array(Block::findByName('Get in Touch')))))); $html->renderOut('site/components/footer'); $html->output('</div>'); $html->renderOut('site/components/page_footer'); $html->renderOut('site/components/html_footer');
<?php $qid = isset($vars[1]) ? $vars[1] : null; $queue = Queue::findById($qid); if (!$queue) { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Queue record does not exist', 'zh' => '队列项不存在')))); } else { if ($queue->delete()) { Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Queue item deleted successfully', 'zh' => '队列项删除成功')))); } else { Message::register(new Message(Message::DANGER, i18n(array('en' => 'Queue item deleted failed', 'zh' => '队列项删除失败')))); } } HTML::forwardBackToReferer();
} // handle form submission if (isset($_POST['submit'])) { $error_flag = false; /// validation // validation for $name $name = isset($_POST["name"]) ? strip_tags($_POST["name"]) : null; if (empty($name)) { Message::register(new Message(Message::DANGER, i18n(array("en" => "name is required.", "zh" => "请填写name")))); $error_flag = true; } /// proceed submission // proceed for $name $object->setName($name); if ($error_flag == false) { if ($object->save()) { Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功")))); HTML::forwardBackToReferer(); } else { Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败")))); } } } $html = new HTML(); $html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Edit Menu', 'zh' => 'Edit 菜单')))); $html->output('<div id="wrapper">'); $html->renderOut('core/backend/header'); $html->renderOut('menu/backend/menu_edit', array('object' => $object)); $html->output('</div>'); $html->renderOut('core/backend/html_footer'); exit;
<?php $type = isset($_POST['type']) && !empty($_POST['type']) ? strip_tags(trim($_POST['type'])) : null; if (Queue::emptyQueue($type)) { Message::register(new Message(Message::SUCCESS, 'Queue ' . $type . ' emptied')); } else { Message::register(new Message(Message::DANGER, 'Queue ' . $type . ' failed to be emptied')); } HTML::forwardBackToReferer();