예제 #1
0
파일: configedit.php 프로젝트: itav/lms
        $args = array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_UICONF] => $id, 'disabled' => $disabled ? 0 : 1);
        $SYSLOG->AddMessage(SYSLOG_RES_UICONF, SYSLOG_OPER_UPDATE, $args, array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_UICONF]));
    }
    $DB->Execute('UPDATE uiconfig SET disabled = CASE disabled WHEN 0 THEN 1 ELSE 0 END WHERE id = ?', array($id));
    $SESSION->redirect('?m=configlist');
}
$config = $DB->GetRow('SELECT * FROM uiconfig WHERE id = ?', array($id));
$option = $config['section'] . '.' . $config['var'];
$config['type'] = $config['type'] == CONFIG_TYPE_AUTO ? $LMS->GetConfigDefaultType($option) : $config['type'];
if (isset($_POST['config'])) {
    $cfg = $_POST['config'];
    $cfg['id'] = $id;
    foreach ($cfg as $key => $val) {
        $cfg[$key] = trim($val);
    }
    if (!ConfigHelper::checkPrivilege('superuser')) {
        $cfg['type'] = $config['type'];
    }
    if ($cfg['var'] == '') {
        $error['var'] = trans('Option name is required!');
    } elseif (strlen($cfg['var']) > 64) {
        $error['var'] = trans('Option name is too long (max.64 characters)!');
    } elseif (!preg_match('/^[a-z0-9_-]+$/', $cfg['var'])) {
        $error['var'] = trans('Option name contains forbidden characters!');
    }
    if (($cfg['var'] != $config['var'] || $cfg['section'] != $config['section']) && $LMS->GetConfigOptionId($cfg['var'], $cfg['section'])) {
        $error['var'] = trans('Option exists!');
    }
    if (!preg_match('/^[a-z0-9_-]+$/', $cfg['section']) && $cfg['section'] != '') {
        $error['section'] = trans('Section name contains forbidden characters!');
    }
예제 #2
0
 *  it under the terms of the GNU General Public License Version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 *  USA.
 *
 *  $Id$
 */
$permanent = ConfigHelper::checkPrivilege('permanent_customer_removal') && isset($_GET['type']) && $_GET['type'] == 'permanent';
$layout['pagetitle'] = trans($permanent ? 'Permanent Customer Remove: $a' : 'Customer Remove: $a', sprintf("%04d", $_GET['id']));
$SMARTY->assign('customerid', $_GET['id']);
if (!$LMS->CustomerExists($_GET['id'])) {
    $body = '<P>' . trans('Incorrect Customer ID.') . '</P>';
} else {
    if ($_GET['is_sure'] != 1) {
        if ($permanent) {
            $body = '<P>' . trans('Do you want to permanently remove $a customer?', $LMS->GetCustomerName($_GET['id'])) . '</P>';
            $body .= '<P>' . trans('This operation will be irreversible!') . '</P>';
        } else {
            $body = '<P>' . trans('Do you want to remove $a customer?', $LMS->GetCustomerName($_GET['id'])) . '</P>';
            $body .= '<P>' . trans('All customer data and computers bound to this customer will be lost!') . '</P>';
        }
        $body .= '<P><A HREF="?m=customerdel&id=' . $_GET['id'] . ($permanent ? '&type=permanent' : '') . '&is_sure=1">' . trans('Yes, I do.') . '</A></P>';
    } else {
예제 #3
0
파일: configadd.php 프로젝트: prezeskk/lms
     $error['var'] = trans('Option name is required!');
 } elseif (strlen($config['var']) > 64) {
     $error['var'] = trans('Option name is too long (max.64 characters)!');
 } elseif (!preg_match('/^[a-z0-9_-]+$/', $config['var'])) {
     $error['var'] = trans('Option name contains forbidden characters!');
 } elseif ($LMS->GetConfigOptionId($config['var'], $config['section'])) {
     $error['var'] = trans('Option exists!');
 }
 $section = empty($config['section']) ? $config['newsection'] : $config['section'];
 if (empty($section)) {
     $error['newsection'] = trans('Section name can\'t be empty!');
 } elseif (!preg_match('/^[a-z0-9_-]+$/', $section)) {
     $error[empty($config['section']) ? 'newsection' : 'section'] = trans('Section name contains forbidden characters!');
 }
 $option = $config['section'] . '.' . $config['var'];
 if (!ConfigHelper::checkPrivilege('superuser') || $config['type'] == CONFIG_TYPE_AUTO) {
     $config['type'] = $LMS->GetConfigDefaultType($option);
 }
 if ($msg = $LMS->CheckOption($option, $config['value'], $config['type'])) {
     $error['value'] = $msg;
 }
 if (!isset($config['disabled'])) {
     $config['disabled'] = 0;
 }
 if (!$error) {
     $args = array('section' => $section, 'var' => $config['var'], 'value' => $config['value'], 'description' => $config['description'], 'disabled' => $config['disabled'], 'type' => $config['type']);
     $DB->Execute('INSERT INTO uiconfig (section, var, value, description, disabled, type) VALUES (?, ?, ?, ?, ?, ?)', array_values($args));
     if ($SYSLOG) {
         $args[SYSLOG::RES_UICONF] = $DB->GetLastInsertID('uiconfig');
         $SYSLOG->AddMessage(SYSLOG::RES_UICONF, SYSLOG::OPER_ADD, $args);
     }