本文整理汇总了PHP中iMSCP_Registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP iMSCP_Registry::set方法的具体用法?PHP iMSCP_Registry::set怎么用?PHP iMSCP_Registry::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iMSCP_Registry
的用法示例。
在下文中一共展示了iMSCP_Registry::set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: client_checkIpData
/**
* Checks IP data.
*
* @param string $ipNumber IP number
* @param string $netcard Network card
* @return bool TRUE if data are valid, FALSE otherwise
*/
function client_checkIpData($ipNumber, $netcard)
{
/** @var $networkCardObject iMSCP_NetworkCard */
$networkCardObject = iMSCP_Registry::get('networkCardObject');
$errFieldsStack = array();
$query = "SELECT COUNT(IF(`ip_number` = ?, 1, NULL)) `isRegisteredIp` FROM `server_ips`";
$stmt = exec_query($query, $ipNumber);
if (filter_var($ipNumber, FILTER_VALIDATE_IP) === false) {
set_page_message(tr('Wrong IP address.'), 'error');
$errFieldsStack[] = 'ip_number';
} elseif ($stmt->fields['isRegisteredIp']) {
set_page_message(tr('IP address already under the control of i-MSCP.'), 'error');
$errFieldsStack[] = 'ip_number';
}
if (!in_array($netcard, $networkCardObject->getAvailableInterface())) {
set_page_message(tr('You must select a network interface.'), 'error');
}
if (Zend_Session::namespaceIsset('pageMessages')) {
if (!empty($errFieldsStack)) {
iMSCP_Registry::set('errFieldsStack', $errFieldsStack);
}
return false;
}
return true;
}
示例2: admin_addUpdateServices
/**
* Adds or updates services ports
*
* @throws iMSCP_Exception
* @param string $mode Mode in witch act (add or update)
* @return void
*/
function admin_addUpdateServices($mode = 'add')
{
/** @var $dbConfig iMSCP_Config_Handler_Db */
$dbConfig = iMSCP_Registry::get('dbConfig');
// Create a pool for error fields ids and gets a reference to him
$errorFieldsIds =& iMSCP_Registry::set('errorFieldsIds', array());
if ($mode == 'add') {
// Adds a service port
$port = $_POST['port_new'];
$protocol = $_POST['port_type_new'];
$name = strtoupper($_POST['name_new']);
$show = $_POST['show_val_new'];
$ip = $_POST['ip_new'];
if (admin_validatesService($name, $ip, $port, $protocol, $show)) {
$dbServiceName = "PORT_{$name}";
$dbConfig[$dbServiceName] = "{$port};{$protocol};{$name};{$show};{$ip}";
write_log($_SESSION['user_logged'] . ": Added service port {$name} ({$port})!", E_USER_NOTICE);
}
} elseif ($mode == 'update') {
// Updates one or more services ports
// Reset counter of update queries
$dbConfig->resetQueriesCounter('update');
foreach ($_POST['name'] as $index => $name) {
$port = $_POST['port'][$index];
$protocol = getProtocol($index);
$name = strtoupper($name);
$show = $_POST['show_val'][$index];
$ip = $_POST['ip'][$index];
if (admin_validatesService($name, $ip, $port, $protocol, $show, $index)) {
$dbServiceName = $_POST['var_name'][$index];
$dbConfig[$dbServiceName] = "{$port};{$protocol};{$name};{$show};{$ip}";
}
}
} else {
throw new iMSCP_Exception('admin_addUpdateServices(): Wrong argument for $mode');
}
if (!empty($errorFieldsIds)) {
toSession($mode);
} elseif ($mode == 'add') {
set_page_message(tr('Service port successfully addeds'), 'success');
} else {
$updateCount = $dbConfig->countQueries('update');
if ($updateCount > 0) {
set_page_message(tr('%d Service(s) port successfully updateds', $updateCount), 'success');
} else {
set_page_message(tr('Nothing has been changed.'), 'info');
}
}
}
示例3: iMSCP_Filter_Compress_Gzip
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @category iMSCP
* @package iMSCP_Plugin
* @subpackage OwnDDNS
* @copyright Sascha Bay <info@space2place.de>
* @author Sascha Bay <info@space2place.de>
* @link http://www.i-mscp.net i-MSCP Home Site
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL v2
*/
$filter = iMSCP_Registry::set('bufferFilter', new iMSCP_Filter_Compress_Gzip(iMSCP_Filter_Compress_Gzip::FILTER_BUFFER));
$filter->compressionInformation = false;
ob_start(array($filter, iMSCP_Filter_Compress_Gzip::CALLBACK_NAME));
if (iMSCP_Registry::isRegistered('pluginManager')) {
/** @var iMSCP_Plugin_Manager $pluginManager */
$pluginManager = iMSCP_Registry::get('pluginManager');
} else {
throw new iMSCP_Plugin_Exception('An unexpected error occured');
}
if (($plugin = $pluginManager->loadPlugin('OwnDDNS', false, false)) !== null) {
$pluginConfig = $plugin->getConfig();
} else {
write_log(sprintf('Plugin OwnDDNS => Error while loading configuration for OwnDDNS plugin. IP address: %s', $_SERVER['REMOTE_ADDR']));
exit('Error loading configuration');
}
if (isset($_GET['action']) && isset($_GET['data'])) {
示例4: layout_LoadNavigation
/**
* Load navigation file for current UI level
*
* @return void
*/
function layout_LoadNavigation()
{
if (isset($_SESSION['user_type'])) {
/** @var $cfg iMSCP_Config_Handler_File */
$cfg = iMSCP_Registry::get('config');
$locale = iMSCP_Registry::get('translator')->getLocale();
switch ($_SESSION['user_type']) {
case 'admin':
$userLevel = 'admin';
$filepath = CACHE_PATH . '/translations/navigation/admin_' . $locale . '.php';
break;
case 'reseller':
$userLevel = 'reseller';
$filepath = CACHE_PATH . '/translations/navigation/reseller_' . $locale . '.php';
break;
default:
$userLevel = 'client';
$filepath = CACHE_PATH . '/translations/navigation/client_' . $locale . '.php';
}
if (!file_exists($filepath)) {
layout_createNavigationFile($cfg->ROOT_TEMPLATE_PATH . "/{$userLevel}/navigation.php", $locale, $userLevel);
}
iMSCP_Registry::set('navigation', new Zend_Navigation(include $filepath));
// Set main menu labels visibility for the current environment
iMSCP_Events_Aggregator::getInstance()->registerListener(iMSCP_Events::onBeforeGenerateNavigation, 'layout_setMainMenuLabelsVisibilityEvt');
}
}
示例5: checkInputData
/**
* Check input data
*
* @return bool TRUE if data are valid, FALSE otherwise
*/
function checkInputData()
{
global $name, $description, $sub, $als, $mail, $mailQuota, $ftp, $sqld, $sqlu, $traffic, $diskSpace, $php, $cgi, $dns, $backup, $aps, $extMail, $webFolderProtection, $status;
$name = isset($_POST['name']) ? clean_input($_POST['name']) : $name;
$description = isset($_POST['description']) ? clean_input($_POST['description']) : $description;
$sub = isset($_POST['sub']) ? clean_input($_POST['sub']) : $sub;
$als = isset($_POST['als']) ? clean_input($_POST['als']) : $als;
$mail = isset($_POST['mail']) ? clean_input($_POST['mail']) : $mail;
$mailQuota = isset($_POST['mail_quota']) ? clean_input($_POST['mail_quota']) : $mailQuota;
$ftp = isset($_POST['ftp']) ? clean_input($_POST['ftp']) : $ftp;
$sqld = isset($_POST['sql_db']) ? clean_input($_POST['sql_db']) : $sqld;
$sqlu = isset($_POST['sql_user']) ? clean_input($_POST['sql_user']) : $sqlu;
$traffic = isset($_POST['traff']) ? clean_input($_POST['traff']) : $traffic;
$diskSpace = isset($_POST['disk']) ? clean_input($_POST['disk']) : $diskSpace;
$php = isset($_POST['php']) ? clean_input($_POST['php']) : $php;
$cgi = isset($_POST['cgi']) ? clean_input($_POST['cgi']) : $cgi;
$dns = isset($_POST['dns']) ? clean_input($_POST['dns']) : $dns;
$backup = isset($_POST['backup']) && is_array($_POST['backup']) ? $_POST['backup'] : $backup;
$aps = isset($_POST['softwares_installer']) ? clean_input($_POST['softwares_installer']) : $aps;
$extMail = isset($_POST['external_mail']) ? clean_input($_POST['external_mail']) : $extMail;
$webFolderProtection = isset($_POST['protected_webfolders']) ? clean_input($_POST['protected_webfolders']) : $webFolderProtection;
$status = isset($_POST['status']) ? clean_input($_POST['status']) : $status;
$php = $php === '_yes_' ? '_yes_' : '_no_';
$cgi = $cgi === '_yes_' ? '_yes_' : '_no_';
$dns = resellerHasFeature('custom_dns_records') && $dns === '_yes_' ? '_yes_' : '_no_';
$backup = resellerHasFeature('backup') ? array_intersect($backup, array('_dmn_', '_sql_', '_mail_')) : array();
$aps = resellerHasFeature('aps') && $aps === '_yes_' ? '_yes_' : '_no_';
$extMail = $extMail === '_yes_' ? '_yes_' : '_no_';
$webFolderProtection = $webFolderProtection === '_yes_' ? '_yes_' : '_no_';
$errFieldsStack = array();
if ($aps == '_yes_') {
// Ensure that PHP is enabled when software installer is enabled
$php = '_yes_';
}
if ($name === '') {
set_page_message(tr('Name cannot be empty.'), 'error');
$errFieldsStack[] = 'name';
}
if ($description === '') {
set_page_message(tr('Description cannot be empty.'), 'error');
$errFieldsStack[] = 'description';
}
if (!resellerHasFeature('subdomains')) {
$sub = '-1';
} elseif (!imscp_limit_check($sub, -1)) {
set_page_message(tr('Incorrect subdomain limit.'), 'error');
$errFieldsStack[] = 'sub';
}
if (!resellerHasFeature('domain_aliases')) {
$als = '-1';
} elseif (!imscp_limit_check($als, -1)) {
set_page_message(tr('Incorrect domain alias limit.'), 'error');
$errFieldsStack[] = 'als';
}
if (!resellerHasFeature('mail')) {
$mail = '-1';
} elseif (!imscp_limit_check($mail, -1)) {
set_page_message(tr('Incorrect email account limit.'), 'error');
$errFieldsStack[] = 'mail';
}
if (!resellerHasFeature('ftp')) {
$ftp = '-1';
} elseif (!imscp_limit_check($ftp, -1)) {
set_page_message(tr('Incorrect FTP account limit.'), 'error');
$errFieldsStack[] = 'ftp';
}
if (!resellerHasFeature('sql_db')) {
$sqld = '-1';
} elseif (!imscp_limit_check($sqld, -1)) {
set_page_message(tr('Incorrect SQL database limit.'), 'error');
$errFieldsStack[] = 'sql_db';
} elseif ($sqlu != -1 && $sqld == -1) {
set_page_message(tr('SQL user limit is <i>disabled</i>.'), 'error');
$errFieldsStack[] = 'sql_db';
$errFieldsStack[] = 'sql_user';
}
if (!resellerHasFeature('sql_user')) {
$sqlu = '-1';
} elseif (!imscp_limit_check($sqlu, -1)) {
set_page_message(tr('Incorrect SQL user limit.'), 'error');
$errFieldsStack[] = 'sql_user';
} elseif ($sqlu == -1 && $sqld != -1) {
set_page_message(tr('SQL database limit is not <i>disabled</i>.'), 'error');
$errFieldsStack[] = 'sql_user';
$errFieldsStack[] = 'sql_db';
}
if (!imscp_limit_check($traffic, null)) {
set_page_message(tr('Incorrect monthly traffic limit.'), 'error');
$errFieldsStack[] = 'traff';
}
if (!imscp_limit_check($diskSpace, null)) {
set_page_message(tr('Incorrect disk space limit.'), 'error');
$errFieldsStack[] = 'disk';
}
if (!imscp_limit_check($mailQuota, null)) {
//.........这里部分代码省略.........
示例6: reseller_checkAndUpdateData
/**
* Check and updates domain data
*
* @throws iMSCP_Exception_Database
* @param int $domainId Domain unique identifier
* @return bool TRUE on success, FALSE otherwise
*/
function reseller_checkAndUpdateData($domainId)
{
$db = iMSCP_Database::getInstance();
$errFieldsStack = array();
try {
// Getting domain data
$data =& reseller_getData($domainId, true);
// Check for expires date
if ($data['domain_never_expires'] == 'off') {
if (!preg_match('%^\\d{2}/\\d{2}/\\d{4}$%', $data['domain_expires']) || ($timestamp = strtotime($data['domain_expires'])) === false) {
$data['domain_expires_ok'] = false;
set_page_message(tr('Wrong syntax for new expire date.'), 'error');
$errFieldsStack[] = 'domain_expires';
} elseif ($timestamp != 0 && $timestamp <= time()) {
$data['domain_expires'] = $timestamp;
set_page_message(tr('You cannot set expire date in past.'), 'error');
$errFieldsStack[] = 'domain_expires';
} else {
$data['domain_expires'] = $timestamp;
}
} else {
$data['domain_expires'] = 0;
}
// Check for the subdomains limit
if ($data['fallback_domain_subd_limit'] != -1) {
if (!imscp_limit_check($data['domain_subd_limit'])) {
set_page_message(tr('Wrong syntax for the %s limit.', tr('subdomains')), 'error');
$errFieldsStack[] = 'domain_subd_limit';
} elseif (!_reseller_isValidServiceLimit($data['domain_subd_limit'], $data['nbSubdomains'], $data["fallback_domain_subd_limit"], $data['current_sub_cnt'], $data['max_sub_cnt'], $data['nbSubdomains'] > 1 ? tr('subdomains') : tr('subdomain'))) {
$errFieldsStack[] = 'domain_subd_limit';
}
}
// Check for the domain aliases limit
if ($data['fallback_domain_alias_limit'] != -1) {
if (!imscp_limit_check($data['domain_alias_limit'])) {
set_page_message(tr('Wrong syntax for the %s limit.', tr('domain aliases')), 'error');
$errFieldsStack[] = 'domain_alias_limit';
} elseif (!_reseller_isValidServiceLimit($data['domain_alias_limit'], $data['nbAliasses'], $data["fallback_domain_alias_limit"], $data['current_als_cnt'], $data['max_als_cnt'], $data['nbAliasses'] > 1 ? tr('domain aliases') : tr('domain alias'))) {
$errFieldsStack[] = 'domain_alias_limit';
}
}
// Check for the mail accounts limit
if ($data['fallback_domain_mailacc_limit'] != -1) {
if (!imscp_limit_check($data['domain_mailacc_limit'])) {
set_page_message(tr('Wrong syntax for the %s limit.', tr('email accounts')), 'error');
$errFieldsStack[] = 'domain_mailacc_limit';
} elseif (!_reseller_isValidServiceLimit($data['domain_mailacc_limit'], $data['nbMailAccounts'], $data["fallback_domain_mailacc_limit"], $data['current_mail_cnt'], $data['max_mail_cnt'], $data["nbMailAccounts"] > 1 ? tr('email accounts') : tr('email account'))) {
$errFieldsStack[] = 'domain_mailacc_limit';
}
}
// Check for the Ftp accounts limit
if ($data['fallback_domain_ftpacc_limit'] != -1) {
if (!imscp_limit_check($data['domain_ftpacc_limit'])) {
set_page_message(tr('Wrong syntax for the %s limit.', tr('Ftp accounts')), 'error');
$errFieldsStack[] = 'domain_ftpacc_limit';
} elseif (!_reseller_isValidServiceLimit($data['domain_ftpacc_limit'], $data['nbFtpAccounts'], $data["fallback_domain_ftpacc_limit"], $data['current_ftp_cnt'], $data['max_ftp_cnt'], $data['nbFtpAccounts'] > 1 ? tr('Ftp accounts') : tr('Ftp account'))) {
$errFieldsStack[] = 'domain_ftpacc_limit';
}
}
// Check for the Sql databases limit
if ($data['fallback_domain_sqld_limit'] != -1) {
if (!imscp_limit_check($data['domain_sqld_limit'])) {
set_page_message(tr('Wrong syntax for the %s limit.', tr('SQL databases')), 'error');
$errFieldsStack[] = 'domain_sqld_limit';
} elseif (!_reseller_isValidServiceLimit($data['domain_sqld_limit'], $data['nbSqlDatabases'], $data["fallback_domain_sqld_limit"], $data['current_sql_db_cnt'], $data['max_sql_db_cnt'], $data['nbSqlDatabases'] > 1 ? tr('SQL databases') : tr('SQL database'))) {
$errFieldsStack[] = 'domain_sqld_limit';
} elseif ($data['domain_sqld_limit'] != -1 && $data['domain_sqlu_limit'] == -1) {
set_page_message(tr('SQL user limit is disabled.'), 'error');
$errFieldsStack[] = 'domain_sqld_limit';
$errFieldsStack[] = 'domain_sqlu_limit';
}
}
// Check for the Sql users limit
if ($data['fallback_domain_sqlu_limit'] != -1) {
if (!imscp_limit_check($data['domain_sqlu_limit'])) {
set_page_message(tr('Wrong syntax for the %s limit.', tr('SQL users')), 'error');
$errFieldsStack[] = 'domain_sqlu_limit';
} elseif (!_reseller_isValidServiceLimit($data['domain_sqlu_limit'], $data['nbSqlUsers'], $data["fallback_domain_sqlu_limit"], $data['current_sql_user_cnt'], $data['max_sql_user_cnt'], $data['nbSqlUsers'] > 1 ? tr('SQL users') : tr('SQL user'))) {
$errFieldsStack[] = 'domain_sqlu_limit';
} elseif ($data['domain_sqlu_limit'] != -1 && $data['domain_sqld_limit'] == -1) {
set_page_message(tr('SQL database limit is disabled.'), 'error');
$errFieldsStack[] = 'domain_sqlu_limit';
$errFieldsStack[] = 'domain_sqld_limit';
}
}
// Check for the monthly traffic limit
if (!imscp_limit_check($data['domain_traffic_limit'], null)) {
set_page_message(tr('Wrong syntax for the %s limit.', tr('traffic')), 'error');
$errFieldsStack[] = 'domain_traffic_limit';
} elseif (!_reseller_isValidServiceLimit($data['domain_traffic_limit'], $data['domainTraffic'] / 1048576, $data["fallback_domain_traffic_limit"], $data['current_traff_amnt'], $data['max_traff_amnt'], tr('traffic'))) {
$errFieldsStack[] = 'domain_traffic_limit';
}
// Check for the disk space limit
//.........这里部分代码省略.........
示例7: admin_checkAndCreateResellerAccount
/**
* Create reseller account
*
* @throws Exception
* @throws iMSCP_Exception
* @throws iMSCP_Exception_Database
* @return bool
*/
function admin_checkAndCreateResellerAccount()
{
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeAddUser);
$cfg = iMSCP_Registry::get('config');
$errFieldsStack = array();
$data =& admin_getData();
/** @var $db iMSCP_Database */
$db = iMSCP_Database::getInstance();
try {
$db->beginTransaction();
// Check for reseller name
$stmt = exec_query('SELECT COUNT(`admin_id`) `usernameExist` FROM `admin` WHERE `admin_name` = ? LIMIT 1', $data['admin_name']);
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
if ($row['usernameExist']) {
set_page_message(tr("The username %s is not available.", '<b>' . $data['admin_name'] . '</b>'), 'error');
$errFieldsStack[] = 'admin_name';
} elseif (!validates_username($data['admin_name'])) {
set_page_message(tr('Incorrect username length or syntax.'), 'error');
$errFieldsStack[] = 'admin_name';
}
// check for password
if (empty($data['password'])) {
set_page_message(tr('You must provide a password.'), 'error');
$errFieldsStack[] = 'password';
$errFieldsStack[] = 'password_confirmation';
} elseif ($data['password'] != $data['password_confirmation']) {
set_page_message(tr("Passwords do not match."), 'error');
$errFieldsStack[] = 'password';
$errFieldsStack[] = 'password_confirmation';
} elseif (!checkPasswordSyntax($data['password'])) {
$errFieldsStack[] = 'password';
$errFieldsStack[] = 'password_confirmation';
}
// Check for email address
if (!chk_email($data['email'])) {
set_page_message(tr('Incorrect syntax for email address.'), 'error');
$errFieldsStack[] = 'email';
}
// Check for ip addresses - We are safe here
$resellerIps = array();
foreach ($data['server_ips'] as $serverIpData) {
if (in_array($serverIpData['ip_id'], $data['reseller_ips'])) {
$resellerIps[] = $serverIpData['ip_id'];
}
}
sort($resellerIps);
if (empty($resellerIps)) {
set_page_message(tr('You must assign at least one IP to this reseller.'), 'error');
}
// Check for max domains limit
if (!imscp_limit_check($data['max_dmn_cnt'], null)) {
set_page_message(tr('Incorrect limit for %s.', tr('domain')), 'error');
$errFieldsStack[] = 'max_dmn_cnt';
}
// Check for max subdomains limit
if (!imscp_limit_check($data['max_sub_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('subdomains')), 'error');
$errFieldsStack[] = 'max_sub_cnt';
}
// check for max domain aliases limit
if (!imscp_limit_check($data['max_als_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('domain aliases')), 'error');
$errFieldsStack[] = 'max_als_cnt';
}
// Check for max mail accounts limit
if (!imscp_limit_check($data['max_mail_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('email accounts')), 'error');
$errFieldsStack[] = 'max_mail_cnt';
}
// Check for max ftp accounts limit
if (!imscp_limit_check($data['max_ftp_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('Ftp accounts')), 'error');
$errFieldsStack[] = 'max_ftp_cnt';
}
// Check for max Sql databases limit
if (!imscp_limit_check($data['max_sql_db_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('SQL databases')), 'error');
$errFieldsStack[] = 'max_sql_db_cnt';
} elseif ($_POST['max_sql_db_cnt'] == -1 && $_POST['max_sql_user_cnt'] != -1) {
set_page_message(tr('SQL database limit is disabled but SQL user limit is not.'), 'error');
$errFieldsStack[] = 'max_sql_db_cnt';
}
// Check for max Sql users limit
if (!imscp_limit_check($data['max_sql_user_cnt'])) {
set_page_message(tr('Incorrect limit for %s.', tr('SQL users')), 'error');
$errFieldsStack[] = 'max_sql_user_cnt';
} elseif ($_POST['max_sql_user_cnt'] == -1 && $_POST['max_sql_db_cnt'] != -1) {
set_page_message(tr('SQL user limit is disabled but SQL database limit is not.'), 'error');
$errFieldsStack[] = 'max_sql_user_cnt';
}
// Check for max monthly traffic limit
if (!imscp_limit_check($data['max_traff_amnt'], null)) {
//.........这里部分代码省略.........
示例8: admin_checkAndUpdateData
/**
* Check and updates reseller data
*
* @throws iMSCP_Exception_Database
* @param int $resellerId Reseller unique identifier
* @return bool TRUE on success, FALSE otherwise
*/
function admin_checkAndUpdateData($resellerId)
{
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditUser, array('userId' => $resellerId));
$errFieldsStack = array();
$data =& admin_getData($resellerId, true);
$db = iMSCP_Database::getInstance();
try {
$db->beginTransaction();
// check for password (if needed)
if ($data['password'] !== '' && $data['pasword_confirmation'] !== '') {
if ($data['password'] !== $data['password_confirmation']) {
set_page_message(tr('Passwords do not match.'), 'error');
}
checkPasswordSyntax($data['password']);
if (Zend_Session::namespaceIsset('pageMessages')) {
$errFieldsStack[] = 'password';
$errFieldsStack[] = 'password_confirmation';
}
}
// Check for email address
if (!chk_email($data['email'])) {
set_page_message(tr('Incorrect syntax for email address.'), 'error');
$errFieldsStack[] = 'email';
}
// Check for ip addresses
$resellerIps = array();
foreach ($data['server_ips'] as $serverIpData) {
if (in_array($serverIpData['ip_id'], $data['reseller_ips'], true)) {
$resellerIps[] = $serverIpData['ip_id'];
}
}
$resellerIps = array_unique(array_merge($resellerIps, $data['used_ips']));
sort($resellerIps);
if (empty($resellerIps)) {
set_page_message(tr('You must assign at least one IP to this reseller.'), 'error');
}
// Check for max domains limit
if (imscp_limit_check($data['max_dmn_cnt'], null)) {
$rs = admin_checkResellerLimit($data['max_dmn_cnt'], $data['current_dmn_cnt'], $data['nbDomains'], '0', tr('domains'));
} else {
set_page_message(tr('Incorrect limit for %s.', tr('domain')), 'error');
$rs = false;
}
if (!$rs) {
$errFieldsStack[] = 'max_dmn_cnt';
}
// Check for max subdomains limit
if (imscp_limit_check($data['max_sub_cnt'])) {
$rs = admin_checkResellerLimit($data['max_sub_cnt'], $data['current_sub_cnt'], $data['nbSubdomains'], $data['unlimitedSubdomains'], tr('subdomains'));
} else {
set_page_message(tr('Incorrect limit for %s.', tr('subdomains')), 'error');
$rs = false;
}
if (!$rs) {
$errFieldsStack[] = 'max_sub_cnt';
}
// check for max domain aliases limit
if (imscp_limit_check($data['max_als_cnt'])) {
$rs = admin_checkResellerLimit($data['max_als_cnt'], $data['current_als_cnt'], $data['nbDomainAliases'], $data['unlimitedDomainAliases'], tr('domain aliases'));
} else {
set_page_message(tr('Incorrect limit for %s.', tr('domain aliases')), 'error');
$rs = false;
}
if (!$rs) {
$errFieldsStack[] = 'max_als_cnt';
}
// Check for max mail accounts limit
if (imscp_limit_check($data['max_mail_cnt'])) {
$rs = admin_checkResellerLimit($data['max_mail_cnt'], $data['current_mail_cnt'], $data['nbMailAccounts'], $data['unlimitedMailAccounts'], tr('mail'));
} else {
set_page_message(tr('Incorrect limit for %s.', tr('email accounts')), 'error');
$rs = false;
}
if (!$rs) {
$errFieldsStack[] = 'max_mail_cnt';
}
// Check for max ftp accounts limit
if (imscp_limit_check($data['max_ftp_cnt'])) {
$rs = admin_checkResellerLimit($data['max_ftp_cnt'], $data['current_ftp_cnt'], $data['nbFtpAccounts'], $data['unlimitedFtpAccounts'], tr('Ftp'));
} else {
set_page_message(tr('Incorrect limit for %s.', tr('Ftp accounts')), 'error');
$rs = false;
}
if (!$rs) {
$errFieldsStack[] = 'max_ftp_cnt';
}
// Check for max Sql databases limit
if (!($rs = imscp_limit_check($data['max_sql_db_cnt']))) {
set_page_message(tr('Incorrect limit for %s.', tr('SQL databases')), 'error');
} elseif ($data['max_sql_db_cnt'] == -1 && $data['max_sql_user_cnt'] != -1) {
set_page_message(tr('SQL database limit is disabled but SQL user limit is not.'), 'error');
$rs = false;
} else {
//.........这里部分代码省略.........
示例9: isset
$tpl->assign(array('INDEX' => $index, 'OPTION_VALUE' => $option, 'SELECTED' => $option == $data['priority'][$index] ? $selectedOption : '', 'OPTION_NAME' => $option));
$tpl->parse('PRIORITY_OPTIONS', '.priority_options');
}
$tpl->assign(array('INDEX' => $index, 'HOST' => $data['host'][$index], 'ENTRY_ID' => isset($data['to_update'][$index]) ? $data['to_update'][$index] : ''));
$tpl->parse('ITEM_ENTRIES', '.item_entries');
$tpl->assign('TYPE_OPTIONS', '');
// Reset name options stack for next record
$tpl->assign('PRIORITY_OPTIONS', '');
// Reset priority options stack for next record
}
}
/***********************************************************************************************************************
* Main
*/
// Include core library
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (customerHasFeature('external_mail') && (isset($_REQUEST['item']) && count($item = explode(';', $_REQUEST['item'], 2)) == 2)) {
$tpl = iMSCP_Registry::set('templateEngine', new iMSCP_pTemplate());
$tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'client/mail_external_edit.tpl', 'page_message' => 'layout', 'item_entries' => 'page', 'type_options' => 'item_entries', 'priority_options' => 'page'));
generateNavigation($tpl);
client_editExternalMailServerEntries($item);
generatePageMessage($tpl);
$tpl->parse('LAYOUT_CONTENT', 'page');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptEnd, array('templateEngine' => $tpl));
$tpl->prnt();
unsetMessages();
} else {
showBadRequestErrorPage();
}
示例10: admin_isValidMenu
/**
* Check if menu is valid.
*
* @param string $menuName Menu name
* @param string $menuLink Menu link
* @param string $menuTarget Menu target
* @param string $menuLevel Menu level
* @param int $menuOrder Menu order
* @return bool TRUE if menu data are valid, FALSE otherwise
*/
function admin_isValidMenu($menuName, $menuLink, $menuTarget, $menuLevel, $menuOrder)
{
$errorFieldsStack = array();
if (empty($menuName)) {
set_page_message(tr('Invalid name.'), 'error');
$errorFieldsStack[] = 'menu_name';
}
if (empty($menuLink) || !filter_var($menuLink, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
set_page_message(tr('Invalid URL.'), 'error');
$errorFieldsStack[] = 'menu_link';
}
if (!empty($menuTarget) && !in_array($menuTarget, array('_blank', '_parent', '_self', '_top'))) {
set_page_message(tr('Invalid target.'), 'error');
$errorFieldsStack[] = 'menu_target';
}
if (!in_array($menuLevel, array('A', 'R', 'C', 'AR', 'AC', 'RC', 'ARC'))) {
showBadRequestErrorPage();
}
if (!empty($menuOrder) && !is_numeric($menuOrder)) {
set_page_message(tr('Invalid menu order.'), 'error');
$errorFieldsStack[] = 'menu_order';
}
if (Zend_Session::namespaceIsset('pageMessages')) {
iMSCP_Registry::set('errorFieldsStack', $errorFieldsStack);
return false;
}
return true;
}
示例11: initializePlugins
/**
* Initialize plugins
*
* @throws iMSCP_Exception When a plugin cannot be loaded
* @return void
*/
protected function initializePlugins()
{
/** @var iMSCP_Plugin_Manager $pluginManager */
$pluginManager = iMSCP_Registry::set('pluginManager', new iMSCP_Plugin_Manager(GUI_ROOT_DIR . '/plugins'));
foreach ($pluginManager->pluginGetList() as $pluginName) {
if (!$pluginManager->pluginHasError($pluginName)) {
if (!$pluginManager->pluginLoad($pluginName)) {
throw new iMSCP_Exception(sprintf('Unable to load plugin: %s', $pluginName));
}
}
}
}
示例12: ini_set
ini_set('display_errors', 1);
// Define paths
define('GUI_ROOT_DIR', dirname(__DIR__));
define('LIBRARY_PATH', GUI_ROOT_DIR . '/library');
define('CACHE_PATH', GUI_ROOT_DIR . '/data/cache');
define('PERSISTENT_PATH', GUI_ROOT_DIR . '/data/persistent');
define('CONFIG_FILE_PATH', getenv('IMSCP_CONF') ?: '/etc/imscp/imscp.conf');
define('CONFIG_CACHE_FILE_PATH', CACHE_PATH . '/imscp_config.conf');
define('DBCONFIG_CACHE_FILE_PATH', CACHE_PATH . '/imscp_dbconfig.conf');
// Setup include path
set_include_path(implode(PATH_SEPARATOR, array_unique(array_merge(array(LIBRARY_PATH, LIBRARY_PATH . '/vendor'), explode(PATH_SEPARATOR, get_include_path())))));
// Setup autoloader
require_once LIBRARY_PATH . '/vendor/Zend/Loader/AutoloaderFactory.php';
Zend_Loader_AutoloaderFactory::factory(array('Zend_Loader_StandardAutoloader' => array('autoregister_zf' => true, 'prefixes' => array('iMSCP_' => LIBRARY_PATH . '/iMSCP', 'Crypt_' => LIBRARY_PATH . '/vendor/phpseclib/Crypt', 'File_' => LIBRARY_PATH . '/vendor/phpseclib/File', 'Math_' => LIBRARY_PATH . '/vendor/phpseclib/Math', 'Net_' => LIBRARY_PATH . '/vendor/Net'))));
// Set handler for uncaught exceptions
iMSCP_Registry::set('exceptionHandler', new iMSCP_Exception_Handler());
/**
* Include core functions
*/
require_once LIBRARY_PATH . '/Functions/Admin.php';
require_once LIBRARY_PATH . '/Functions/Client.php';
require_once LIBRARY_PATH . '/Functions/Email.php';
require_once LIBRARY_PATH . '/Functions/Input.php';
require_once LIBRARY_PATH . '/Functions/Intl.php';
require_once LIBRARY_PATH . '/Functions/Layout.php';
require_once LIBRARY_PATH . '/Functions/Login.php';
require_once LIBRARY_PATH . '/Functions/Shared.php';
require_once LIBRARY_PATH . '/Functions/SoftwareInstaller.php';
require_once LIBRARY_PATH . '/Functions/Reseller.php';
require_once LIBRARY_PATH . '/Functions/View.php';
require_once LIBRARY_PATH . '/vendor/idna_convert/idna_convert.class.php';