public function CheckOption($option, $value, $type) { if ($value == '') { return trans('Empty option value is not allowed!'); } switch ($type) { case CONFIG_TYPE_POSITIVE_INTEGER: if (!preg_match('/^[1-9][0-9]*$/', $value)) { return trans('Value of option "$a" must be a number grater than zero!', $option); } break; case CONFIG_TYPE_BOOLEAN: if (!isboolean($value)) { return trans('Incorrect value! Valid values are: 1|t|true|y|yes|on and 0|n|no|off|false'); } break; case CONFIG_TYPE_RELOADTYPE: if ($value != 'sql' && $value != 'exec') { return trans('Incorrect reload type. Valid types are: sql, exec!'); } break; case CONFIG_TYPE_DOCTYPE: if ($value != 'html' && $value != 'pdf') { return trans('Incorrect value! Valid values are: html, pdf!'); } break; case CONFIG_TYPE_EMAIL: if (!check_email($value)) { return trans('Incorrect email address!'); } break; case CONFIG_TYPE_MARGINS: if (!preg_match('/^\\d+,\\d+,\\d+,\\d+$/', $value)) { return trans('Margins should consist of 4 numbers separated by commas!'); } break; case CONFIG_TYPE_MAIL_BACKEND: if ($value != 'pear' && $value != 'phpmailer') { return trans('Incorrect mail backend. Valid types are: pear, phpmailer!'); } break; case CONFIG_TYPE_MAIL_SECURE: if ($value != 'ssl' && $value != 'tls') { return trans('Incorrect mail security protocol. Valid types are: ssl, tls!'); } break; case CONFIG_TYPE_DATE_FORMAT: if (!preg_match('/%[aAdejuw]+/', $value) || !preg_match('/%[bBhm]+/', $value) || !preg_match('/%[CgGyY]+/', $value)) { return trans('Incorrect date format! Enter format for day (%a, %A, %d, %e, %j, %u, %w), month (%b, %B, %h, %m) and year (%C, %g, %G, %y, %Y)'); } break; } return NULL; }
public function CheckOption($var, $value) { switch ($var) { case 'accountlist_pagelimit': case 'ticketlist_pagelimit': case 'balancelist_pagelimit': case 'invoicelist_pagelimit': case 'aliaslist_pagelimit': case 'domainlist_pagelimit': case 'documentlist_pagelimit': case 'timeout': case 'timetable_days_forward': case 'nodepassword_length': case 'check_for_updates_period': case 'print_balance_list_limit': case 'networkhosts_pagelimit': if ($value <= 0) { return trans('Value of option "$a" must be a number grater than zero!', $var); } break; case 'reload_type': if ($value != 'sql' && $value != 'exec') { return trans('Incorrect reload type. Valid types are: sql, exec!'); } break; case 'force_ssl': case 'allow_mac_sharing': case 'smarty_debug': case 'use_current_payday': case 'helpdesk_backend_mode': case 'helpdesk_reply_body': case 'to_words_short_version': case 'newticket_notify': case 'print_balance_list': case 'short_pagescroller': case 'big_networks': case 'ewx_support': case 'helpdesk_stats': case 'helpdesk_customerinfo': if (!isboolean($value)) { return trans('Incorrect value! Valid values are: 1|t|true|y|yes|on and 0|n|no|off|false'); } break; case 'debug_email': if (!check_email($value)) { return trans('Incorrect email address!'); } break; } return NULL; }