public static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new AdminURL();
     }
     return self::$instance;
 }
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #3
0
            $errors[] = Resources::Get("ban.error.duplicate", array($address, $url . '?banid=' . $existingBan['banid']));
        }
    }
    if (empty($errors)) {
        $time = strtotime($till);
        if ($time < 1) {
            $errors[] = Resources::Get("errors.format", Resources::Get("form.field.till"));
        }
        $hashTable = array('till' => date('Y-m-d H:i:s', $time), 'address' => $address, 'comment' => $comment);
        if ($isCreateMode) {
            $hashTable['created'] = null;
        } else {
            $hashTable['banid'] = $banid;
        }
        $banMapper->save($hashTable);
        header("Location: " . AdminURL::getInstance()->getURL('blocked'));
        exit;
    }
    $TML->assign('address', $address);
    $TML->assign('till', $till);
    $TML->assign('comment', $comment);
} elseif (isset($_REQUEST['banid'])) {
    $banid = verify_param('banid', "/^\\d{1,9}\$/");
    $ban = $banMapper->getById($banid);
    $TML->assign('address', $ban['address']);
    $TML->assign('till', date(getDateTimeFormat(), $ban['till']));
    $TML->assign('comment', $ban['comment']);
}
require_once dirname(__FILE__) . '/inc/admin_prolog_after.php';
$TML->assign('errors', $errors);
$TML->display('ban.tpl');
 * 
 * Все права защищены. (c) 2005-2009 ООО "ТОП".
 * Данное программное обеспечение и все сопутствующие материалы
 * предоставляются на условиях лицензии, доступной по адресу
 * http://webim.ru/license.html
 * 
 */
$TITLE_KEY = 'topMenu.admin';
require_once dirname(__FILE__) . '/inc/admin_prolog.php';
require_once '../classes/common.php';
require_once '../classes/functions.php';
require_once '../classes/class.adminurl.php';
require_once '../classes/class.operator.php';
require_once '../classes/class.settings.php';
require_once '../classes/class.smartyclass.php';
$operator = Operator::getInstance()->GetLoggedOperator();
$TML = new SmartyClass($TITLE_KEY);
$count = 0;
foreach (AdminURL::$ADMIN_MENU as $i) {
    if ($i['role'] == 'operator' || $i['role'] == $operator['role']) {
        $prepared[$count] = $i;
        $prepared[$count]['link'] = AdminURL::getInstance()->getURL($i['link_name']);
        $count++;
    }
}
if (sizeof($prepared) % 2 == 1) {
    $prepared[] = array();
}
$TML->assign('items', $prepared);
$TML->display('menu.tpl');
require_once dirname(__FILE__) . '/inc/admin_epilog.php';
function inviteSubmitted()
{
    global $TITLE_KEY;
    $TML = new SmartyClass($TITLE_KEY);
    $isNew = empty($_REQUEST['autoinviteid']);
    $toCheck = array('text' => 'form.field.text');
    foreach ($toCheck as $field => $res) {
        if (empty($_REQUEST[$field])) {
            $errors[] = Resources::Get("errors.required", array(Resources::Get($res)));
        }
    }
    if (!isset($_REQUEST['number_of_pages']) || !empty($_REQUEST['number_of_pages']) && !is_numeric($_REQUEST['number_of_pages'])) {
        $errors[] = Resources::Get("errors.not_numeric.number_of_pages");
    }
    if (!isset($_REQUEST['time_on_site']) || !is_numeric($_REQUEST['time_on_site'])) {
        $errors[] = Resources::Get("errors.not_numeric.time_on_site");
    }
    $visited_pages = array();
    if (isset($_REQUEST['visited_page']) && is_array($_REQUEST['visited_page']) && isset($_REQUEST['visited_page_time']) && is_array($_REQUEST['visited_page_time'])) {
        foreach ($_REQUEST['visited_page'] as $k => $v) {
            if (!empty($v)) {
                if (!isset($_REQUEST['visited_page_time'][$k]) || !is_numeric($_REQUEST['visited_page_time'][$k])) {
                    $errors[] = Resources::Get("errors.not_numeric.visited_page_time");
                } else {
                    array_push($visited_pages, array("url" => $v, "time" => $_REQUEST['visited_page_time'][$k]));
                }
            }
        }
    }
    $hash = array();
    if (empty($errors)) {
        $hash['text'] = $_REQUEST['text'];
        $hash['conditions'] = array();
        if (isset($_REQUEST['came_from']) && !empty($_REQUEST['came_from'])) {
            $hash['conditions']['came_from'] = $_REQUEST['came_from'];
        }
        if (isset($_REQUEST['number_of_pages']) && !empty($_REQUEST['number_of_pages'])) {
            $hash['conditions']['number_of_pages'] = $_REQUEST['number_of_pages'];
        }
        if (isset($_REQUEST['time_on_site']) && !empty($_REQUEST['time_on_site'])) {
            $hash['conditions']['time_on_site'] = $_REQUEST['time_on_site'];
        }
        if (isset($_REQUEST['order_matters']) && !empty($_REQUEST['order_matters'])) {
            $hash['conditions']['order_matters'] = 1;
        }
        if (count($visited_pages) > 0) {
            $hash['conditions']['visited_pages'] = $visited_pages;
        }
        $json = new Json();
        $hash['conditions'] = $json->encode($hash['conditions']);
        if ($isNew) {
            $autoinviteToUpdateId = MapperFactory::getMapper("AutoInvite")->save($hash);
        } else {
            $autoinviteToUpdateId = $_REQUEST['autoinviteid'];
            $hash['autoinviteid'] = $autoinviteToUpdateId;
            MapperFactory::getMapper("AutoInvite")->save($hash);
        }
        header("Location: " . AdminURL::getInstance()->getURL('auto_invites'));
        exit;
    }
    foreach (array('order_matters', 'text', 'came_from', 'visited_page', 'visited_page_time', 'time_on_site', 'number_of_pages') as $f) {
        if (isset($_REQUEST[$f]) && !empty($_REQUEST[$f])) {
            $TML->assign($f, $_REQUEST[$f]);
        }
    }
    $TML->assign('errors', $errors);
    $TML->display('auto_invite.tpl');
}
Exemple #6
0
function operatorSubmitted()
{
    global $TML, $isNew;
    $valid_types = array("gif", "jpg", "png", "jpeg");
    $operator = Operator::getInstance()->GetLoggedOperator(false);
    setOperator();
    $toCheck = array('login' => 'form.field.login', 'fullname' => 'form.field.agent_name', 'email' => 'form.field.agent_email');
    if ($isNew) {
        $toCheck['password'] = '******';
    }
    foreach ($toCheck as $field => $res) {
        if (empty($_REQUEST[$field])) {
            $errors[] = Resources::Get("errors.required", array(Resources::Get($res)));
        }
    }
    if (empty($errors) && !preg_match("/^[\\w_\\.]+\$/", $_REQUEST['login'])) {
        $errors[] = Resources::Get("page_agent.error.wrong_login");
    }
    if ($_REQUEST['password'] != $_REQUEST['password_confirm']) {
        $errors[] = Resources::Get('my_settings.error.password_match');
    }
    if (empty($errors)) {
        $existingOperator = MapperFactory::getMapper("Operator")->getByLogin($_REQUEST['login']);
        $exists = !empty($existingOperator);
        if ($exists) {
            if ($isNew || !$isNew && $_REQUEST['operatorid'] != $existingOperator['operatorid']) {
                $errors[] = Resources::Get('page_agent.error.duplicate_login');
            }
        }
    }
    if (empty($errors) && !is_valid_email($_REQUEST['email'])) {
        $errors[] = Resources::Get('errors.email.format', array(Resources::Get('form.field.agent_email')));
    }
    $departments = array();
    foreach ($_REQUEST as $key => $value) {
        if (!preg_match("/^departments::(.+)\$/", $key, $matches)) {
            continue;
        }
        if (isset($_REQUEST[$key]) && $_REQUEST[$key] == 'on') {
            $departments[] = $matches[1];
        }
    }
    $locales = array();
    foreach ($_REQUEST as $key => $value) {
        if (!preg_match("/^locales::([a-z]{2})\$/", $key, $matches)) {
            continue;
        }
        if (isset($_REQUEST[$key]) && $_REQUEST[$key] == 'on') {
            $locales[] = $matches[1];
        }
    }
    // restore departments on the page
    $operator = Operator::getInstance()->GetLoggedOperator(false);
    $orig = MapperFactory::getMapper("OperatorDepartment")->enumDepartmentsWithOperator($operator['operatorid'], Resources::getCurrentLocale());
    $toAssign = array();
    foreach ($orig as $d) {
        $d['isindepartment'] = in_array($d['departmentid'], $departments);
        $toAssign[] = $d;
    }
    $TML->assign('departments', $toAssign);
    $orig_locales = getAvailableLocalesForChat();
    $to_assign_locales = array();
    foreach ($orig_locales as $d) {
        $d['ishaslocale'] = in_array($d['localeid'], $locales);
        $to_assign_locales[] = $d;
    }
    $TML->assign('locales', $to_assign_locales);
    $hash = array();
    if (empty($errors)) {
        $hash['login'] = $_REQUEST['login'];
        $hash['email'] = $_REQUEST['email'];
        $hash['fullname'] = $_REQUEST['fullname'];
        $hash['role'] = empty($_REQUEST['is_admin']) ? 'operator' : 'admin';
        $op_data_hash['locales'] = implode(",", $locales);
        $op_data_hash['locales'] = empty($op_data_hash['locales']) ? null : $op_data_hash['locales'];
        //Force mapper to set null for column in DB;
        if (!empty($_REQUEST['password'])) {
            $hash['password'] = md5($_REQUEST['password']);
        }
        $operatorToUpdateId = null;
        if ($isNew) {
            $operatorToUpdateId = MapperFactory::getMapper("Operator")->save($hash);
            MapperFactory::getMapper("Operator")->insertOperatorTime($operatorToUpdateId);
        } else {
            $operatorToUpdateId = $_REQUEST['operatorid'];
            $hash['operatorid'] = $operatorToUpdateId;
            MapperFactory::getMapper("Operator")->save($hash);
        }
        $op_data_hash['operatorid'] = $operatorToUpdateId;
        MapperFactory::getMapper("OperatorLastAccess")->save($op_data_hash);
        Operator::getInstance()->setOperatorDepartments($operatorToUpdateId, $departments);
        $requestFile = $_FILES['avatarFile'];
        if (empty($errors) && isset($requestFile) && !empty($requestFile['name']) && $requestFile['size'] > 0 && $requestFile['error'] == 0) {
            $res = Operator::getInstance()->UploadOperatorAvatar($operatorToUpdateId, $requestFile);
            if (!empty($res)) {
                $errors[] = $res;
            }
            if (empty($errors)) {
                $hash = array();
                $hash['avatar'] = Operator::getInstance()->getAvatarURL($operatorToUpdateId, $requestFile['name']);
                Operator::getInstance()->UpdateOperator($operatorToUpdateId, $hash);
            }
        }
        if (empty($errors)) {
            if ($operatorToUpdateId == $operator['operatorid']) {
                Operator::getInstance()->RefreshSessionOperator();
            }
            header("Location: " . AdminURL::getInstance()->getURL('operators'));
            exit;
        }
    }
    foreach (array('login', 'email', 'fullname', 'is_admin') as $f) {
        if (!empty($_REQUEST[$f])) {
            $TML->assign($f, $_REQUEST[$f]);
        }
    }
    $TML->assign('errors', $errors);
    $TML->display('operator.tpl');
    exit;
}
function smarty_function_get_admin_url($params, &$smarty)
{
    return AdminURL::getInstance()->getURL($params['link_name'], NULL, isset($params['is_with_param_postfix']) ? $params['is_with_param_postfix'] == 'true' : false);
}
function deleteDepartment()
{
    Department::getInstance()->deleteDepartment($_REQUEST['id']);
    header("Location: " . AdminURL::getInstance()->getURL('departments'));
    exit;
}