Include $errors global variable into $page

This commit is contained in:
Dmitriy Simushev 2014-01-21 10:03:51 +00:00
parent 6da2a33ce3
commit 7b83f8ca6f
56 changed files with 219 additions and 196 deletions

View File

@ -288,15 +288,15 @@ $dbtables_can_update = array(
function show_install_err($text)
{
global $page, $errors;
global $page;
$page = array(
'version' => MIBEW_VERSION,
'localeLinks' => get_locale_links(MIBEW_WEB_ROOT . "/install/index.php"),
'title' => getlocal("install.err.title"),
'no_right_menu' => true,
'fixedwrap' => true,
'errors' => array($text),
);
$errors = array($text);
$page_style = new \Mibew\Style\PageStyle('default');
$page_style->render('install_err');
exit;

View File

@ -388,6 +388,7 @@ check_status();
$page['title'] = getlocal("install.title");
$page['fixedwrap'] = true;
$page['errors'] = $errors;
$page_style = new \Mibew\Style\PageStyle('default');
$page_style->render('install_index');

View File

@ -45,7 +45,7 @@ class PageStyle extends Style implements StyleInterface {
public function render($template_name, $data = array()) {
// We need to import some variables to make them visible to required
// view.
global $page, $errors;
global $page;
// Add template root value to page variables
$page['stylepath'] = MIBEW_WEB_ROOT . '/' . $this->filesPath();

View File

@ -26,8 +26,9 @@ require_once(MIBEW_FS_ROOT.'/libs/chat.php');
require_once(MIBEW_FS_ROOT.'/libs/groups.php');
require_once(MIBEW_FS_ROOT.'/libs/notify.php');
$errors = array();
$page = array();
$page = array(
'errors' =>array()
);
$token = verifyparam( "token", "/^\d{1,8}$/");
$threadid = verifyparam( "thread", "/^\d{1,8}$/");
@ -44,12 +45,12 @@ $email = getparam('email');
$page['email'] = $email;
$group = is_null($thread->groupId)?NULL:group_by_id($thread->groupId);
if( !$email ) {
$errors[] = no_field("form.field.email");
$page['errors'][] = no_field("form.field.email");
} else if( !is_valid_email($email)) {
$errors[] = wrong_field("form.field.email");
$page['errors'][] = wrong_field("form.field.email");
}
if( count($errors) > 0 ) {
if( count($page['errors']) > 0 ) {
$page['formemail'] = $email;
$page['chat.thread.id'] = $thread->id;
$page['chat.thread.token'] = $thread->lastToken;
@ -58,7 +59,6 @@ if( count($errors) > 0 ) {
$page,
setup_logo($group)
);
$page['errors'] = $errors;
$chat_style->render('mail', $page);
exit;
}
@ -82,7 +82,7 @@ $page = array_merge_recursive(
$page,
setup_logo($group)
);
$page['errors'] = $errors;
$chat_style->render('mailsent', $page);
exit;
?>

View File

@ -44,7 +44,9 @@ if (Settings::get('enablessl') == "1" && Settings::get('forcessl') == "1") {
}
$threadid = verifyparam("thread", "/^\d{1,8}$/");
$page = array();
$page = array(
'errors' => array()
);
// Initialize chat style which is currently used in system
$chat_style = new ChatStyle(ChatStyle::currentStyle());
@ -55,16 +57,14 @@ if (!isset($_GET['token'])) {
$remote_level = get_remote_level($_SERVER['HTTP_USER_AGENT']);
if ($remote_level != "ajaxed") {
$errors = array(getlocal("thread.error.old_browser"));
$page['errors'] = $errors;
$page['errors'][] = getlocal("thread.error.old_browser");
$chat_style->render('error', $page);
exit;
}
$thread = Thread::load($threadid);
if (!$thread || !isset($thread->lastToken)) {
$errors = array(getlocal("thread.error.wrong_thread"));
$page['errors'] = $errors;
$page['errors'][] = getlocal("thread.error.wrong_thread");
$chat_style->render('error', $page);
exit;
}
@ -75,8 +75,7 @@ if (!isset($_GET['token'])) {
if (!$viewonly && $thread->state == Thread::STATE_CHATTING && $operator['operatorid'] != $thread->agentId) {
if (!is_capable(CAN_TAKEOVER, $operator)) {
$errors = array(getlocal("thread.error.cannot_take_over"));
$page['errors'] = $errors;
$page['errors'][] = getlocal("thread.error.cannot_take_over");
$chat_style->render('error', $page);
exit;
}
@ -95,14 +94,12 @@ if (!isset($_GET['token'])) {
if (!$viewonly) {
if(! $thread->take($operator)){
$errors = array(getlocal("thread.error.cannot_take"));
$page['errors'] = $errors;
$page['errors'][] = getlocal("thread.error.cannot_take");
$chat_style->render('error', $page);
exit;
}
} else if (!is_capable(CAN_VIEWTHREADS, $operator)) {
$errors = array(getlocal("thread.error.cannot_view"));
$page['errors'] = $errors;
$page['errors'][] = getlocal("thread.error.cannot_view");
$chat_style->render('error', $page);
exit;
}
@ -120,8 +117,7 @@ if (!$thread) {
}
if ($thread->agentId != $operator['operatorid'] && !is_capable(CAN_VIEWTHREADS, $operator)) {
$errors = array("Cannot view threads");
$page['errors'] = $errors;
$page['errors'][] = "Cannot view threads";
$chat_style->render('error', $page);
exit;
}

View File

@ -28,8 +28,11 @@ $operator = check_login();
csrfchecktoken();
$opId = verifyparam("op", "/^\d{1,9}$/");
$page = array('opid' => $opId, 'avatar' => '');
$errors = array();
$page = array(
'opid' => $opId,
'avatar' => '',
'errors' => array(),
);
$canmodify = ($opId == $operator['operatorid'] && is_capable(CAN_MODIFYPROFILE, $operator))
|| is_capable(CAN_ADMINISTRATE, $operator);
@ -37,13 +40,13 @@ $canmodify = ($opId == $operator['operatorid'] && is_capable(CAN_MODIFYPROFILE,
$op = operator_by_id($opId);
if (!$op) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
} else if (isset($_POST['op'])) {
$avatar = $op['vcavatar'];
if (!$canmodify) {
$errors[] = getlocal('page_agent.cannot_modify');
$page['errors'][] = getlocal('page_agent.cannot_modify');
} else if (isset($_FILES['avatarFile']) && $_FILES['avatarFile']['name']) {
$valid_types = array("gif", "jpg", "png", "tif", "jpeg");
@ -56,9 +59,9 @@ if (!$op) {
$file_size = $_FILES['avatarFile']['size'];
if ($file_size == 0 || $file_size > Settings::get('max_uploaded_file_size')) {
$errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded");
$page['errors'][] = failed_uploading_file($orig_filename, "errors.file.size.exceeded");
} elseif (!in_array($ext, $valid_types)) {
$errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type");
$page['errors'][] = failed_uploading_file($orig_filename, "errors.invalid.file.type");
} else {
$avatar_local_dir = MIBEW_FS_ROOT.'/files/avatar/';
$full_file_path = $avatar_local_dir . $new_file_name;
@ -66,16 +69,16 @@ if (!$op) {
unlink($full_file_path);
}
if (!@move_uploaded_file($_FILES['avatarFile']['tmp_name'], $full_file_path)) {
$errors[] = failed_uploading_file($orig_filename, "errors.file.move.error");
$page['errors'][] = failed_uploading_file($orig_filename, "errors.file.move.error");
} else {
$avatar = MIBEW_WEB_ROOT . "/files/avatar/$new_file_name";
}
}
} else {
$errors[] = "No file selected";
$page['errors'][] = "No file selected";
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
update_operator_avatar($op['operatorid'], $avatar);
if ($opId && $avatar && $_SESSION[SESSION_PREFIX."operator"] && $operator['operatorid'] == $opId) {

View File

@ -32,7 +32,7 @@ $page = array('banId' => '');
$page['saved'] = false;
$page['thread'] = '';
$page['threadid'] = '';
$errors = array();
$page['errors'] = array();
if (isset($_POST['address'])) {
$banId = verifyparam("banId", "/^(\d{1,9})?$/", "");
@ -42,25 +42,25 @@ if (isset($_POST['address'])) {
$threadid = isset($_POST['threadid']) ? getparam('threadid') : "";
if (!$address) {
$errors[] = no_field("form.field.address");
$page['errors'][] = no_field("form.field.address");
}
if (!preg_match("/^\d+$/", $days)) {
$errors[] = wrong_field("form.field.ban_days");
$page['errors'][] = wrong_field("form.field.ban_days");
}
if (!$comment) {
$errors[] = no_field("form.field.ban_comment");
$page['errors'][] = no_field("form.field.ban_comment");
}
$existing_ban = ban_for_addr($address);
if ((!$banId && $existing_ban) ||
($banId && $existing_ban && $banId != $existing_ban['banid'])) {
$errors[] = getlocal2("ban.error.duplicate", array($address, $existing_ban['banid']));
$page['errors'][] = getlocal2("ban.error.duplicate", array($address, $existing_ban['banid']));
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$db = Database::getInstance();
$now = time();
$till_time = $now + $days * 24 * 60 * 60;
@ -117,7 +117,7 @@ if (isset($_POST['address'])) {
$page['formdays'] = topage(round($ban['days'] / 86400));
$page['formcomment'] = topage($ban['comment']);
} else {
$errors[] = "Wrong id";
$page['errors'][] = "Wrong id";
}
} else if (isset($_GET['thread'])) {
$threadid = verifyparam('thread', "/^\d{1,9}$/");

View File

@ -28,8 +28,9 @@ require_once(MIBEW_FS_ROOT.'/libs/pagination.php');
$operator = check_login();
csrfchecktoken();
$page = array();
$errors = array();
$page = array(
'errors' => array(),
);
setlocale(LC_TIME, getstring("time.locale"));
@ -39,10 +40,10 @@ if (isset($_GET['act']) && $_GET['act'] == 'del') {
$banId = isset($_GET['id']) ? $_GET['id'] : "";
if (!preg_match("/^\d+$/", $banId)) {
$errors[] = "Cannot delete: wrong argument";
$page['errors'][] = "Cannot delete: wrong argument";
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$db->query("delete from {chatban} where banid = ?", array($banId));
header("Location: " . MIBEW_WEB_ROOT . "/operator/blocked.php");
exit;

View File

@ -31,8 +31,9 @@ $operator = check_login();
force_password($operator);
csrfchecktoken();
$errors = array();
$page = array();
$page = array(
'errors' => array(),
);
# locales
@ -55,7 +56,7 @@ $groupid = verifyparam("group", "/^\d{0,8}$/", "");
if ($groupid) {
$group = group_by_id($groupid);
if (!$group) {
$errors[] = getlocal("page.group.no_such");
$page['errors'][] = getlocal("page.group.no_such");
$groupid = "";
}
}
@ -77,10 +78,10 @@ if (isset($_GET['act']) && $_GET['act'] == 'delete') {
$key = isset($_GET['key']) ? $_GET['key'] : "";
if (!preg_match("/^\d+$/", $key)) {
$errors[] = "Wrong key";
$page['errors'][] = "Wrong key";
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$db = Database::getInstance();
$db->query("delete from {chatresponses} where id = ?", array($key));
header("Location: " . MIBEW_WEB_ROOT . "/operator/canned.php?lang=" . urlencode($lang) . "&group=" . intval($groupid));

View File

@ -29,15 +29,16 @@ csrfchecktoken();
$stringid = verifyparam("key", "/^\d{0,9}$/", "");
$errors = array();
$page = array();
$page = array(
'errors' => array(),
);
$page_style = new PageStyle(PageStyle::currentStyle());
if ($stringid) {
$canned_message = load_canned_message($stringid);
if (!$canned_message) {
$errors[] = getlocal("cannededit.no_such");
$page['errors'][] = getlocal("cannededit.no_such");
$stringid = "";
}else{
$title = $canned_message['vctitle'];
@ -54,15 +55,15 @@ if ($stringid) {
if (isset($_POST['message']) && isset($_POST['title'])) {
$title = getparam('title');
if (!$title) {
$errors[] = no_field("form.field.title");
$page['errors'][] = no_field("form.field.title");
}
$message = getparam('message');
if (!$message) {
$errors[] = no_field("form.field.message");
$page['errors'][] = no_field("form.field.message");
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
if ($stringid) {
save_canned_message($stringid, $title, $message);
} else {

View File

@ -27,8 +27,10 @@ require_once(MIBEW_FS_ROOT.'/libs/settings.php');
$operator = check_login();
csrfchecktoken();
$page = array('agentId' => '');
$errors = array();
$page = array(
'agentId' => '',
'errors' => array(),
);
$options = array(
'enableban', 'usercanchangename',
@ -57,7 +59,7 @@ if (isset($_POST['sent'])) {
header("Location: " . MIBEW_WEB_ROOT . "/operator/features.php?stored");
exit;
} else {
$errors[] = "Not an administrator";
$page['errors'][] = "Not an administrator";
}
}

View File

@ -30,12 +30,14 @@ require_once(MIBEW_FS_ROOT.'/libs/getcode.php');
$operator = check_login();
force_password($operator);
$errors = array();
$page = array(
'errors' => array(),
);
$imageLocales = get_image_locales_map(MIBEW_FS_ROOT.'/locales');
$image = verifyparam(isset($_GET['image']) ? "image" : "i", "/^\w+$/", "mibew");
if (!isset($imageLocales[$image])) {
$errors[] = "Unknown image: $image";
$page['errors'][] = "Unknown image: $image";
$avail = array_keys($imageLocales);
$image = $avail[0];
}
@ -55,7 +57,7 @@ if ($invitationstyle && !in_array($invitationstyle, $invitationstylelist)) {
$invitationstyle = "";
}
$groupid = verifyparam_groupid("group", $errors);
$groupid = verifyparam_groupid("group", $page['errors']);
$showhost = verifyparam("hostname", "/^on$/", "") == "on";
$forcesecure = verifyparam("secure", "/^on$/", "") == "on";
$modsecurity = verifyparam("modsecurity", "/^on$/", "") == "on";
@ -76,7 +78,6 @@ if ($groupid) {
}
$message = get_image($imagehref, $size[0], $size[1]);
$page = array();
$page['buttonCode'] = generate_button("", $lang, $style, $invitationstyle, $groupid, $message, $showhost, $forcesecure, $modsecurity, $operator_code);
$page['availableImages'] = array_keys($imageLocales);
$page['availableLocales'] = $image_locales;

View File

@ -27,8 +27,11 @@ require_once(MIBEW_FS_ROOT.'/libs/groups.php');
$operator = check_login();
csrfchecktoken();
$page = array('grid' => '');
$errors = array();
$page = array(
'grid' => '',
'errors' => array(),
);
$groupid = '';
function group_by_name($name)
@ -157,13 +160,13 @@ if (isset($_POST['name'])) {
$logo = getparam('logo');
if (!$name)
$errors[] = no_field("form.field.groupname");
$page['errors'][] = no_field("form.field.groupname");
if ($email != '' && !is_valid_email($email))
$errors[] = wrong_field("form.field.mail");
$page['errors'][] = wrong_field("form.field.mail");
if (! preg_match("/^(\d{1,9})?$/", $weight))
$errors[] = wrong_field("form.field.groupweight");
$page['errors'][] = wrong_field("form.field.groupweight");
if ($weight == '')
$weight = 0;
@ -174,9 +177,9 @@ if (isset($_POST['name'])) {
$existing_group = group_by_name($name);
if ((!$groupid && $existing_group) ||
($groupid && $existing_group && $groupid != $existing_group['groupid']))
$errors[] = getlocal("page.group.duplicate_name");
$page['errors'][] = getlocal("page.group.duplicate_name");
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
if (!$groupid) {
$newdep = create_group(array(
'name' => $name,
@ -229,7 +232,7 @@ if (isset($_POST['name'])) {
$group = group_by_id($groupid);
if (!$group) {
$errors[] = getlocal("page.group.no_such");
$page['errors'][] = getlocal("page.group.no_such");
$page['grid'] = topage($groupid);
} else {
$page['formname'] = topage($group['vclocalname']);

View File

@ -63,12 +63,12 @@ function get_operators()
$groupid = verifyparam("gid", "/^\d{1,9}$/");
$page = array('groupid' => $groupid);
$page['operators'] = get_operators();
$errors = array();
$page['errors'] = array();
$group = group_by_id($groupid);
if (!$group) {
$errors[] = getlocal("page.group.no_such");
$page['errors'][] = getlocal("page.group.no_such");
} else if (isset($_POST['gid'])) {

View File

@ -32,14 +32,14 @@ if (isset($_GET['act']) && $_GET['act'] == 'del') {
$groupid = isset($_GET['gid']) ? $_GET['gid'] : "";
if (!preg_match("/^\d+$/", $groupid)) {
$errors[] = getlocal("page.groups.error.cannot_delete");
$page['errors'][] = getlocal("page.groups.error.cannot_delete");
}
if (!is_capable(CAN_ADMINISTRATE, $operator)) {
$errors[] = getlocal("page.groups.error.forbidden_remove");
$page['errors'][] = getlocal("page.groups.error.forbidden_remove");
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$db = Database::getInstance();
$db->query("delete from {chatgroup} where groupid = ?", array($groupid));
$db->query("delete from {chatgroupoperator} where groupid = ?", array($groupid));

View File

@ -22,8 +22,11 @@ use Mibew\Style\PageStyle;
require_once(dirname(dirname(__FILE__)).'/libs/init.php');
require_once(MIBEW_FS_ROOT.'/libs/operator.php');
$errors = array();
$page = array('formisRemember' => true, 'version' => MIBEW_VERSION);
$page = array(
'formisRemember' => true,
'version' => MIBEW_VERSION,
'errors' => array(),
);
if (isset($_POST['login']) && isset($_POST['password'])) {
$login = getparam('login');
@ -44,9 +47,9 @@ if (isset($_POST['login']) && isset($_POST['password'])) {
exit;
} else {
if (operator_is_disabled($operator)) {
$errors[] = getlocal('page_login.operator.disabled');
$page['errors'][] = getlocal('page_login.operator.disabled');
} else {
$errors[] = getlocal("page_login.error");
$page['errors'][] = getlocal("page_login.error");
}
$page['formlogin'] = $login;
}

View File

@ -26,8 +26,11 @@ require_once(MIBEW_FS_ROOT.'/libs/operator_settings.php');
$operator = check_login();
csrfchecktoken();
$page = array('opid' => '');
$errors = array();
$page = array(
'opid' => '',
'errors' => array(),
);
$opId = '';
if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isset($_POST['password'])) {
@ -45,35 +48,35 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
$code = getparam('code');
if (!$localname)
$errors[] = no_field("form.field.agent_name");
$page['errors'][] = no_field("form.field.agent_name");
if (!$commonname)
$errors[] = no_field("form.field.agent_commonname");
$page['errors'][] = no_field("form.field.agent_commonname");
if (!$login) {
$errors[] = no_field("form.field.login");
$page['errors'][] = no_field("form.field.login");
} else if (!preg_match("/^[\w_\.]+$/", $login)) {
$errors[] = getlocal("page_agent.error.wrong_login");
$page['errors'][] = getlocal("page_agent.error.wrong_login");
}
if ($email == '' || !is_valid_email($email)) {
$errors[] = wrong_field("form.field.mail");
$page['errors'][] = wrong_field("form.field.mail");
}
if ($code != '' && (! preg_match("/^[A-z0-9_]+$/", $code))) {
$errors[] = getlocal("page_agent.error.wrong_agent_code");
$page['errors'][] = getlocal("page_agent.error.wrong_agent_code");
}
if (!$opId && !$password)
$errors[] = no_field("form.field.password");
$page['errors'][] = no_field("form.field.password");
if ($password != $passwordConfirm)
$errors[] = getlocal("my_settings.error.password_match");
$page['errors'][] = getlocal("my_settings.error.password_match");
$existing_operator = operator_by_login($login);
if ((!$opId && $existing_operator) ||
($opId && $existing_operator && $opId != $existing_operator['operatorid']))
$errors[] = getlocal("page_agent.error.duplicate_login");
$page['errors'][] = getlocal("page_agent.error.duplicate_login");
// Check if operator with specified email already exists in the database
$existing_operator = operator_by_email($email);
@ -83,16 +86,16 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
// Update operator email to existing one
($opId && $existing_operator && $opId != $existing_operator['operatorid'])
) {
$errors[] = getlocal("page_agent.error.duplicate_email");
$page['errors'][] = getlocal("page_agent.error.duplicate_email");
}
$canmodify = ($opId == $operator['operatorid'] && is_capable(CAN_MODIFYPROFILE, $operator))
|| is_capable(CAN_ADMINISTRATE, $operator);
if (!$canmodify) {
$errors[] = getlocal('page_agent.cannot_modify');
$page['errors'][] = getlocal('page_agent.cannot_modify');
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
if (!$opId) {
$newop = create_operator($login, $email, $password, $localname, $commonname, "", $code);
header("Location: " . MIBEW_WEB_ROOT . "/operator/avatar.php?op=" . intval($newop['operatorid']));
@ -125,13 +128,13 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
$op = operator_by_id($opId);
if (!$op) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
$page['opid'] = topage($opId);
} else {
//show an error if the admin password hasn't been set yet.
if (check_password_hash($operator['vclogin'], '', $operator['vcpassword']) && !isset($_GET['stored']))
{
$errors[] = getlocal("my_settings.error.no_password");
$page['errors'][] = getlocal("my_settings.error.no_password");
}
$page['formlogin'] = topage($op['vclogin']);
@ -144,7 +147,7 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
}
if (!$opId && !is_capable(CAN_ADMINISTRATE, $operator)) {
$errors[] = getlocal("page_agent.error.forbidden_create");
$page['errors'][] = getlocal("page_agent.error.forbidden_create");
}
$canmodify = ($opId == $operator['operatorid'] && is_capable(CAN_MODIFYPROFILE, $operator))

View File

@ -27,33 +27,36 @@ $operator = check_login();
force_password($operator);
csrfchecktoken();
$page = array(
'errors' => array(),
);
if (isset($_GET['act'])) {
$errors = array();
$operatorid = isset($_GET['id']) ? $_GET['id'] : "";
if (!preg_match("/^\d+$/", $operatorid)) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
}
if ($_GET['act'] == 'del') {
if (!is_capable(CAN_ADMINISTRATE, $operator)) {
$errors[] = getlocal("page_agents.error.forbidden_remove");
$page['errors'][] = getlocal("page_agents.error.forbidden_remove");
}
if ($operatorid == $operator['operatorid']) {
$errors[] = getlocal("page_agents.error.cannot_remove_self");
$page['errors'][] = getlocal("page_agents.error.cannot_remove_self");
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$op = operator_by_id($operatorid);
if (!$op) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
} else if ($op['vclogin'] == 'admin') {
$errors[] = getlocal("page_agents.error.cannot_remove_admin");
$page['errors'][] = getlocal("page_agents.error.cannot_remove_admin");
}
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
delete_operator($operatorid);
header("Location: " . MIBEW_WEB_ROOT . "/operator/operators.php");
exit;
@ -62,23 +65,23 @@ if (isset($_GET['act'])) {
if ($_GET['act'] == 'disable' || $_GET['act'] == 'enable') {
$act_disable = ($_GET['act'] == 'disable');
if (!is_capable(CAN_ADMINISTRATE, $operator)) {
$errors[] = $act_disable?getlocal('page_agents.disable.not.allowed'):getlocal('page_agents.enable.not.allowed');
$page['errors'][] = $act_disable?getlocal('page_agents.disable.not.allowed'):getlocal('page_agents.enable.not.allowed');
}
if ($operatorid == $operator['operatorid'] && $act_disable) {
$errors[] = getlocal('page_agents.cannot.disable.self');
$page['errors'][] = getlocal('page_agents.cannot.disable.self');
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$op = operator_by_id($operatorid);
if (!$op) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
} else if ($op['vclogin'] == 'admin' && $act_disable) {
$errors[] = getlocal('page_agents.cannot.disable.admin');
$page['errors'][] = getlocal('page_agents.cannot.disable.admin');
}
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$db = Database::getInstance();
$db->query(
"update {chatoperator} set idisabled = ? where operatorid = ?",
@ -91,7 +94,6 @@ if (isset($_GET['act'])) {
}
}
$page = array();
$sort['by'] = verifyparam("sortby", "/^(login|commonname|localename|lastseen)$/", "login");
$sort['desc'] = (verifyparam("sortdirection", "/^(desc|asc)$/", "desc") == "desc");
$page['formsortby'] = $sort['by'];

View File

@ -48,22 +48,22 @@ $operator_in_isolation = in_isolation($operator);
$opId = verifyparam("op", "/^\d{1,9}$/");
$page = array('opid' => $opId);
$page['groups'] = $operator_in_isolation?get_all_groups_for_operator($operator):get_all_groups();
$errors = array();
$page['errors'] = array();
$canmodify = is_capable(CAN_ADMINISTRATE, $operator);
$op = operator_by_id($opId);
if (!$op) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
} else if (isset($_POST['op'])) {
if (!$canmodify) {
$errors[] = getlocal('page_agent.cannot_modify');
$page['errors'][] = getlocal('page_agent.cannot_modify');
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$new_groups = array();
foreach ($page['groups'] as $group) {
if (verifyparam("group" . $group['groupid'], "/^on$/", "") == "on") {

View File

@ -27,8 +27,10 @@ require_once(MIBEW_FS_ROOT.'/libs/settings.php');
$operator = check_login();
csrfchecktoken();
$page = array('agentId' => '');
$errors = array();
$page = array(
'agentId' => '',
'errors' => array(),
);
$options = array(
'online_timeout', 'updatefrequency_operator', 'updatefrequency_chat',
@ -44,59 +46,59 @@ foreach ($options as $opt) {
if (isset($_POST['onlinetimeout'])) {
$params['online_timeout'] = getparam('onlinetimeout');
if (!is_numeric($params['online_timeout'])) {
$errors[] = wrong_field("settings.onlinetimeout");
$page['errors'][] = wrong_field("settings.onlinetimeout");
}
$params['updatefrequency_operator'] = getparam('frequencyoperator');
if (!is_numeric($params['updatefrequency_operator'])) {
$errors[] = wrong_field("settings.frequencyoperator");
$page['errors'][] = wrong_field("settings.frequencyoperator");
}
$params['updatefrequency_chat'] = getparam('frequencychat');
if (!is_numeric($params['updatefrequency_chat'])) {
$errors[] = wrong_field("settings.frequencychat");
$page['errors'][] = wrong_field("settings.frequencychat");
}
$params['max_connections_from_one_host'] = getparam('onehostconnections');
if (!is_numeric($params['max_connections_from_one_host'])) {
$errors[] = getlocal("settings.wrong.onehostconnections");
$page['errors'][] = getlocal("settings.wrong.onehostconnections");
}
$params['thread_lifetime'] = getparam('threadlifetime');
if (!is_numeric($params['thread_lifetime'])) {
$errors[] = getlocal("settings.wrong.threadlifetime");
$page['errors'][] = getlocal("settings.wrong.threadlifetime");
}
$params['statistics_aggregation_interval'] = getparam('statistics_aggregation_interval');
if (!is_numeric($params['statistics_aggregation_interval'])) {
$errors[] = wrong_field("settings.statistics_aggregation_interval");
$page['errors'][] = wrong_field("settings.statistics_aggregation_interval");
}
if (Settings::get('enabletracking')) {
$params['updatefrequency_tracking'] = getparam('frequencytracking');
if (!is_numeric($params['updatefrequency_tracking'])) {
$errors[] = wrong_field("settings.frequencytracking");
$page['errors'][] = wrong_field("settings.frequencytracking");
}
$params['visitors_limit'] = getparam('visitorslimit');
if (!is_numeric($params['visitors_limit'])) {
$errors[] = wrong_field("settings.visitorslimit");
$page['errors'][] = wrong_field("settings.visitorslimit");
}
$params['invitation_lifetime'] = getparam('invitationlifetime');
if (!is_numeric($params['invitation_lifetime'])) {
$errors[] = wrong_field("settings.invitationlifetime");
$page['errors'][] = wrong_field("settings.invitationlifetime");
}
$params['tracking_lifetime'] = getparam('trackinglifetime');
if (!is_numeric($params['tracking_lifetime'])) {
$errors[] = wrong_field("settings.trackinglifetime");
$page['errors'][] = wrong_field("settings.trackinglifetime");
}
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
foreach ($options as $opt) {
Settings::set($opt,$params[$opt]);
}

View File

@ -27,18 +27,21 @@ $operator = check_login();
csrfchecktoken();
$opId = verifyparam("op", "/^\d{1,9}$/");
$page = array('opid' => $opId, 'canmodify' => is_capable(CAN_ADMINISTRATE, $operator) ? "1" : "");
$errors = array();
$page = array(
'opid' => $opId,
'canmodify' => is_capable(CAN_ADMINISTRATE, $operator) ? "1" : "",
'errors' => array(),
);
$op = operator_by_id($opId);
if (!$op) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
} else if (isset($_POST['op'])) {
if (!is_capable(CAN_ADMINISTRATE, $operator)) {
$errors[] = getlocal('page_agent.cannot_modify');
$page['errors'][] = getlocal('page_agent.cannot_modify');
}
$new_permissions = isset($op['iperm']) ? $op['iperm'] : 0;
@ -51,7 +54,7 @@ if (!$op) {
}
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
update_operator_permissions($op['operatorid'], $new_permissions);
if ($opId && $_SESSION[SESSION_PREFIX."operator"] && $operator['operatorid'] == $opId) {

View File

@ -36,8 +36,9 @@ if (! $thread) {
die("wrong thread");
}
$page = array();
$errors = array();
$page = array(
'errors' => array(),
);
// Initialize chat style which is currently used in system
$chat_style = new ChatStyle(ChatStyle::currentStyle());
@ -65,10 +66,10 @@ if (isset($_GET['nextGroup'])) {
)
);
} else {
$errors[] = getlocal("chat.redirect.cannot");
$page['errors'][] = getlocal("chat.redirect.cannot");
}
} else {
$errors[] = "Unknown group";
$page['errors'][] = "Unknown group";
}
} else {
@ -106,10 +107,10 @@ if (isset($_GET['nextGroup'])) {
)
);
} else {
$errors[] = getlocal("chat.redirect.cannot");
$page['errors'][] = getlocal("chat.redirect.cannot");
}
} else {
$errors[] = "Unknown operator";
$page['errors'][] = "Unknown operator";
}
}
@ -117,10 +118,8 @@ $page = array_merge_recursive(
$page,
setup_logo()
);
$page['errors'] = $errors;
if (count($errors) > 0) {
if (count($page['errors']) > 0) {
$chat_style->render('error', $page);
} else {
$chat_style->render('redirected', $page);

View File

@ -24,7 +24,6 @@ require_once(dirname(dirname(__FILE__)).'/libs/init.php');
require_once(MIBEW_FS_ROOT.'/libs/operator.php');
require_once(MIBEW_FS_ROOT.'/libs/settings.php');
$errors = array();
$page = array(
'version' => MIBEW_VERSION,
'showform' => true,
@ -32,6 +31,7 @@ $page = array(
'headertitle' => getlocal("app.title"),
'show_small_login' => true,
'fixedwrap' => true,
'errors' => array(),
);
$page_style = new PageStyle(PageStyle::currentStyle());
@ -42,24 +42,24 @@ $token = verifyparam("token", "/^[\dabcdef]+$/");
$operator = operator_by_id($opId);
if (!$operator) {
$errors[] = "No such operator";
$page['errors'][] = "No such operator";
$page['showform'] = false;
} else if ($token != $operator['vcrestoretoken']) {
$errors[] = "Wrong token";
$page['errors'][] = "Wrong token";
$page['showform'] = false;
}
if (count($errors) == 0 && isset($_POST['password'])) {
if (count($page['errors']) == 0 && isset($_POST['password'])) {
$password = getparam('password');
$passwordConfirm = getparam('passwordConfirm');
if (!$password)
$errors[] = no_field("form.field.password");
$page['errors'][] = no_field("form.field.password");
if ($password != $passwordConfirm)
$errors[] = getlocal("my_settings.error.password_match");
$page['errors'][] = getlocal("my_settings.error.password_match");
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$page['isdone'] = true;
$db = Database::getInstance();

View File

@ -25,13 +25,13 @@ require_once(MIBEW_FS_ROOT.'/libs/operator.php');
require_once(MIBEW_FS_ROOT.'/libs/settings.php');
require_once(MIBEW_FS_ROOT.'/libs/notify.php');
$errors = array();
$page = array(
'version' => MIBEW_VERSION,
'title' => getlocal("restore.title"),
'headertitle' => getlocal("app.title"),
'show_small_login' => true,
'fixedwrap' => true,
'errors' => array(),
);
$loginoremail = "";
@ -43,15 +43,15 @@ if (isset($_POST['loginoremail'])) {
$torestore = is_valid_email($loginoremail) ? operator_by_email($loginoremail) : operator_by_login($loginoremail);
if (!$torestore) {
$errors[] = getlocal("no_such_operator");
$page['errors'][] = getlocal("no_such_operator");
}
$email = $torestore['vcemail'];
if (count($errors) == 0 && !is_valid_email($email)) {
$errors[] = "Operator hasn't set his e-mail";
if (count($page['errors']) == 0 && !is_valid_email($email)) {
$page['errors'][] = "Operator hasn't set his e-mail";
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
$token = sha1($torestore['vclogin'] . (function_exists('openssl_random_pseudo_bytes') ? openssl_random_pseudo_bytes(32) : (time() + microtime()) . mt_rand(0, 99999999)));
$db = Database::getInstance();

View File

@ -31,8 +31,10 @@ $operator = check_login();
force_password($operator);
csrfchecktoken();
$page = array('agentId' => '');
$errors = array();
$page = array(
'agentId' => '',
'errors' => array(),
);
// Load system configs
$options = array(
@ -97,22 +99,22 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) {
}
if ($params['email'] && !is_valid_email($params['email'])) {
$errors[] = getlocal("settings.wrong.email");
$page['errors'][] = getlocal("settings.wrong.email");
}
if ($params['geolinkparams']) {
foreach (preg_split("/,/", $params['geolinkparams']) as $oneparam) {
if (!preg_match("/^\s*(toolbar|scrollbars|location|status|menubar|width|height|resizable)=\d{1,4}$/", $oneparam)) {
$errors[] = "Wrong link parameter: \"$oneparam\", should be one of 'toolbar, scrollbars, location, status, menubar, width, height or resizable'";
$page['errors'][] = "Wrong link parameter: \"$oneparam\", should be one of 'toolbar, scrollbars, location, status, menubar, width, height or resizable'";
}
}
}
if (preg_match("/^[0-9A-z]*$/", $params['cron_key']) == 0) {
$errors[] = getlocal("settings.wrong.cronkey");
$page['errors'][] = getlocal("settings.wrong.cronkey");
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
// Update system settings
foreach ($options as $opt) {
Settings::set($opt,$params[$opt]);

View File

@ -48,7 +48,7 @@ $page['last_cron_run'] = Settings::get('_last_cron_run');
$page['show_invitations_info'] = (bool)Settings::get('enabletracking');
$errors = array();
$page['errors'] = array();
if (isset($_GET['startday'])) {
$startday = verifyparam("startday", "/^\d+$/");
@ -83,7 +83,7 @@ $page = array_merge(
);
if ($start > $end) {
$errors[] = getlocal("statistics.wrong.dates");
$page['errors'][] = getlocal("statistics.wrong.dates");
}
$activetab = 0;
@ -178,7 +178,7 @@ if ($statisticstype == 'bydate') {
);
$activetab = 2;
}
$page['showresults'] = count($errors) == 0;
$page['showresults'] = count($page['errors']) == 0;
$page['title'] = getlocal("statistics.title");
$page['menuid'] = "statistics";

View File

@ -137,12 +137,12 @@ if (!isset($messages[$target])) {
}
$lang2 = $messages[$target];
$errors = array();
$page = array(
'lang1' => $source,
'lang2' => $target,
'title1' => isset($lang1["localeid"]) ? $lang1["localeid"] : $source,
'title2' => isset($lang2["localeid"]) ? $lang2["localeid"] : $target
'title2' => isset($lang2["localeid"]) ? $lang2["localeid"] : $target,
'errors' => array(),
);
$page_style = new PageStyle(PageStyle::currentStyle());
@ -153,10 +153,10 @@ if ($stringid) {
$translation = getparam('translation');
if (!$translation) {
$errors[] = no_field("form.field.translation");
$page['errors'][] = no_field("form.field.translation");
}
if (count($errors) == 0) {
if (count($page['errors']) == 0) {
save_message($target, $stringid, $translation);
$page['saved'] = true;

View File

@ -28,13 +28,13 @@ force_password($operator);
$default_extensions = array('mysql', 'gd', 'iconv');
$errors = array();
$page = array(
'localizations' => get_available_locales(),
'phpVersion' => phpversion(),
'version' => MIBEW_VERSION,
'title' => getlocal("updates.title"),
'menuid' => "updates",
'errors' => array(),
);
foreach ($default_extensions as $ext) {

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php if( $page['opid'] ) { ?>

View File

@ -23,7 +23,7 @@ function tpl_header() { global $page;
<?php
}
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page_agents.intro") ?>

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page_avatar.intro") ?>

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php if( $page['saved'] ) { ?>

View File

@ -23,7 +23,7 @@ function tpl_header() { global $page;
<?php
}
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page_ban.intro") ?>

View File

@ -17,7 +17,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("canned.descr") ?>

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php if( $page['saved'] ) { ?>

View File

@ -25,7 +25,7 @@ function tpl_header() { global $page;
<?php
}
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page_settings.intro") ?>

View File

@ -17,7 +17,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page.gen_button.intro") ?>

View File

@ -25,7 +25,7 @@ function tpl_header() { global $page;
<?php
}
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php if( $page['grid'] ) { ?>

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page.groupmembers.intro") ?>

View File

@ -23,7 +23,7 @@ function tpl_header() { global $page;
<?php
}
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page.groups.intro") ?>

View File

@ -15,12 +15,12 @@
* limitations under the License.
*/
if( isset($errors) && count($errors) > 0 ) { ?>
if( isset($page['errors']) && count($page['errors']) > 0 ) { ?>
<div class="errinfo">
<img src='<?php echo MIBEW_WEB_ROOT ?>/styles/pages/default/images/icon_err.gif' width="40" height="40" border="0" alt="" class="left"/>
<?php
print getlocal("errors.header");
foreach( $errors as $e ) {
foreach( $page['errors'] as $e ) {
print getlocal("errors.prefix");
print $e;
print getlocal("errors.suffix");

View File

@ -22,7 +22,7 @@ function menuloc($id) {
}
return "";
}
function tpl_menu() { global $page, $errors, $current_locale;
function tpl_menu() { global $page, $current_locale;
?>
<li>
<h2><b><?php echo getlocal("lang.choose") ?></b></h2>

View File

@ -23,7 +23,7 @@ function menuli($name) {
return "";
}
function tpl_menu() { global $page, $errors;
function tpl_menu() { global $page;
if(isset($page['isOnline']) && !$page['isOnline']) { ?>
<li id="offwarn">
<img src="<?php echo MIBEW_WEB_ROOT ?>/styles/pages/default/images/dash/warn.gif" alt="" width="24" height="24"/>

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php

View File

@ -40,7 +40,7 @@ function tpl_header() { global $page;
}
}
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("install.message") ?>
<br/>

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<p>Copyright 2005-2013 the original author or authors.</p>

View File

@ -19,7 +19,7 @@ if(isset($page) && isset($page['localeLinks'])) {
require_once(dirname(__FILE__).'/inc_locales.php');
}
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<div id="loginintro">

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("operator.groups.intro") ?>

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page_settings.intro") ?>

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("permissions.intro") ?>

View File

@ -20,7 +20,7 @@ if(isset($page) && isset($page['localeLinks'])) {
}
function tpl_content() {
global $page, $errors;
global $page;
if($page['isdone']) {
?>

View File

@ -20,7 +20,7 @@ if(isset($page) && isset($page['localeLinks'])) {
}
function tpl_content() {
global $page, $errors;
global $page;
if($page['isdone']) {
?>

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_menu.php');
require_once(dirname(__FILE__).'/inc_tabbar.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal("page_settings.intro") ?>

View File

@ -18,7 +18,7 @@
require_once(dirname(__FILE__).'/inc_tabbar.php');
require_once(dirname(__FILE__).'/inc_menu.php');
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php echo getlocal2("statistics.description.full", array(date_to_text($page['last_cron_run']), $page['cron_path'])) ?>

View File

@ -40,7 +40,7 @@ function tpl_header() { global $page; ?>
//--></script>
<?php }
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
$chatthreadinfo = $page['thread_info'];
$chatthread = $page['thread_info']['thread'];
?>

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
function tpl_content() { global $page, $errors;
function tpl_content() { global $page;
?>
<?php if( $page['saved'] ) { ?>