本文整理汇总了PHP中encode_idna函数的典型用法代码示例。如果您正苦于以下问题:PHP encode_idna函数的具体用法?PHP encode_idna怎么用?PHP encode_idna使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode_idna函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reseller_checkData
/**
* Check input data
*
* @return void
*/
function reseller_checkData()
{
$cfg = iMSCP_Registry::get('config');
if (!isset($_POST['dmn_name']) || $_POST['dmn_name'] === '') {
set_page_message(tr('Domain name cannot be empty.'), 'error');
return;
}
$dmnName = clean_input($_POST['dmn_name']);
global $dmnNameValidationErrMsg;
if (!isValidDomainName($dmnName)) {
set_page_message($dmnNameValidationErrMsg, 'error');
return;
}
// www is considered as an alias of the domain
while (strpos($dmnName, 'www.') !== false) {
$dmnName = substr($dmnName, 4);
}
$asciiDmnName = encode_idna($dmnName);
if (imscp_domain_exists($asciiDmnName, $_SESSION['user_id']) || $asciiDmnName == $cfg['BASE_SERVER_VHOST']) {
set_page_message(tr('Domain %s is unavailable.', "<strong>{$dmnName}</strong>"), 'error');
return;
}
if ((!isset($_POST['datepicker']) || $_POST['datepicker'] === '') && !isset($_POST['never_expire'])) {
set_page_message(tr('Domain expiration date must be filled.'), 'error');
return;
}
$dmnExpire = isset($_POST['datepicker']) ? @strtotime(clean_input($_POST['datepicker'])) : 0;
if ($dmnExpire === false) {
set_page_message('Invalid expiration date.', 'error');
return;
}
$hpId = isset($_POST['dmn_tpl']) ? clean_input($_POST['dmn_tpl']) : 0;
$customizeHp = $hpId > 0 && isset($_POST['chtpl']) ? $_POST['chtpl'] : '_no_';
if ($hpId == 0 || $customizeHp == '_yes_') {
$_SESSION['dmn_name'] = $asciiDmnName;
$_SESSION['dmn_expire'] = $dmnExpire;
$_SESSION['dmn_tpl'] = $hpId;
$_SESSION['chtpl'] = '_yes_';
$_SESSION['step_one'] = '_yes_';
redirectTo('user_add2.php');
}
if (reseller_limits_check($_SESSION['user_id'], $hpId)) {
$_SESSION['dmn_name'] = $asciiDmnName;
$_SESSION['dmn_expire'] = $dmnExpire;
$_SESSION['dmn_tpl'] = $hpId;
$_SESSION['chtpl'] = $customizeHp;
$_SESSION['step_one'] = '_yes_';
redirectTo('user_add3.php');
}
set_page_message(tr('Hosting plan limits exceed reseller limits.'), 'error');
}
示例2: reseller_sendEmail
/**
* Send email
*
* @param string $senderName Sender name
* @param string $senderEmail Sender email
* @param string $subject Subject
* @param string $body Body
* @param array $rcptToData Recipient data
*/
function reseller_sendEmail($senderName, $senderEmail, $subject, $body, $rcptToData)
{
if ($rcptToData['email'] != '') {
$senderEmail = encode_idna($senderEmail);
if (!empty($rcptToData['fname']) && !empty($rcptToData['lname'])) {
$to = $rcptToData['fname'] . ' ' . $rcptToData['lname'];
} elseif (!empty($rcptToData['fname'])) {
$to = $rcptToData['fname'];
} elseif (!empty($rcptToData['lname'])) {
$to = $rcptToData['lname'];
} else {
$to = $rcptToData['admin_name'];
}
$from = encode_mime_header($senderName) . " <{$senderEmail}>";
$to = encode_mime_header($to) . " <{$rcptToData['email']}>";
$headers = "From: {$from}\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/plain; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "X-Mailer: i-MSCP mailer";
mail($to, encode_mime_header($subject), $body, $headers, "-f {$senderEmail}");
}
}
示例3: login_credentials
/**
* Credentials authentication handler
*
* @param iMSCP_Events_Event $event
* @return iMSCP_Authentication_Result
* @throws iMSCP_Exception_Database
*/
function login_credentials($event)
{
$username = !empty($_POST['uname']) ? encode_idna(clean_input($_POST['uname'])) : '';
$password = !empty($_POST['upass']) ? clean_input($_POST['upass']) : '';
if (empty($username) || empty($password)) {
if (empty($username)) {
$message[] = tr('The username field is empty.');
}
if (empty($password)) {
$message[] = tr('The password field is empty.');
}
}
if (!isset($message)) {
$stmt = exec_query('SELECT admin_id, admin_name, admin_pass, admin_type, email, created_by FROM admin WHERE admin_name = ?', $username);
if (!$stmt->rowCount()) {
$result = new iMSCP_Authentication_Result(iMSCP_Authentication_Result::FAILURE_IDENTITY_NOT_FOUND, null, tr('Unknown username.'));
} else {
$identity = $stmt->fetchRow(PDO::FETCH_OBJ);
$dbPassword = $identity->admin_pass;
if ($dbPassword != md5($password) && crypt($password, $dbPassword) != $dbPassword) {
$result = new iMSCP_Authentication_Result(iMSCP_Authentication_Result::FAILURE_CREDENTIAL_INVALID, null, tr('Bad password.'));
} else {
if (strpos($dbPassword, '$') !== 0) {
# Not a password encrypted with crypt(), then re-encrypt it
exec_query('UPDATE admin SET admin_pass = ? WHERE admin_id = ?', array(cryptPasswordWithSalt($password), $identity->admin_id));
write_log(sprintf('Info: Password for user %s has been re-encrypted using the best available algorithm', $identity->admin_name), E_USER_NOTICE);
}
$result = new iMSCP_Authentication_Result(iMSCP_Authentication_Result::SUCCESS, $identity);
$event->stopPropagation();
}
}
} else {
$result = new iMSCP_Authentication_Result(count($message) == 2 ? iMSCP_Authentication_Result::FAILURE_CREDENTIAL_EMPTY : iMSCP_Authentication_Result::FAILURE_CREDENTIAL_INVALID, null, $message);
}
return $result;
}
示例4: mail_users
$csvDelimiter = ',';
if (($handle = fopen($csvFilePath, 'r')) !== false) {
$db = iMSCP_Database::getRawInstance();
$stmt = $db->prepare('
INSERT INTO mail_users (
mail_acc, mail_pass, mail_forward, domain_id, mail_type, sub_id, status, mail_auto_respond,
mail_auto_respond_text, quota, mail_addr
) VALUES (
:mail_acc, :mail_pass, :mail_forward, :domain_id, :mail_type, :sub_id, :status, :mail_auto_respond,
:mail_auto_respond_text, :quota, :mail_addr
)
');
// Create i-MSCP mail accounts using entries from CSV file
while (($csvEntry = fgetcsv($handle, 1024, $csvDelimiter)) !== false) {
$mailAddr = trim($csvEntry[0]);
$asciiMailAddr = encode_idna($mailAddr);
$mailPassword = trim($csvEntry[1]);
try {
if (!chk_email($asciiMailAddr)) {
throw new iMSCP_Exception(sprintf('%s is not a valid email address.', $mailAddr));
}
if (checkPasswordSyntax($mailPassword)) {
list($mailUser, $mailDomain) = explode('@', $asciiMailAddr);
$mailAccount = array_merge(cli_getMailData($mailDomain), array('mail_acc' => $mailUser, 'mail_pass' => $mailPassword, 'mail_forward' => '_no_', 'status' => 'toadd', 'mail_auto_respond' => '0', 'mail_auto_respond_text' => null, 'quota' => '0', 'mail_addr' => $asciiMailAddr));
try {
$stmt->execute($mailAccount);
printf("The %s mail account has been successfully inserted into the i-MSCP database.\n", $mailAddr);
} catch (PDOException $e) {
if ($e->getCode() == 23000) {
printf("WARN: The %s mail account already exists in the i-MSCP database. Skipping.\n", $mailAddr);
} else {
示例5: getCredentials
/**
* Returns credentials to push in select element
*
* @return array
*/
protected function getCredentials()
{
$credentials = array();
foreach ($this->getConfigParam('user_accounts') as $account) {
if (isset($account['label']) && isset($account['username']) && isset($account['password'])) {
$stmt = exec_query('SELECT admin_pass FROM admin WHERE admin_name = ?', encode_idna($account['username']));
if ($stmt->rowCount()) {
$dbPassword = $stmt->fields['admin_pass'];
if (crypt($account['password'], $dbPassword) == $dbPassword || $dbPassword == md5($account['password'])) {
$credentials[] = array('label' => $account['label'], 'username' => $account['username'], 'password' => $account['password']);
}
}
}
}
return $credentials;
}
示例6: client_editMailAccount
/**
* Edit mail account
*
* @throws iMSCP_Exception
* @return bool TRUE on success, FALSE otherwise
*/
function client_editMailAccount()
{
if (isset($_POST['password']) && isset($_POST['password_rep']) && isset($_POST['quota']) && isset($_POST['forward_list'])) {
$mailData = client_getEmailAccountData(clean_input($_GET['id']));
$mainDmnProps = get_domain_default_props($_SESSION['user_id']);
$password = $forwardList = '_no_';
$mailType = '';
$quota = null;
if (preg_match('/^(.*?)_(?:mail|forward)/', $mailData['mail_type'], $match)) {
$domainType = $match[1];
} else {
throw new iMSCP_Exception('Unable to determine mail type');
}
$mailTypeNormal = isset($_POST['account_type']) && in_array($_POST['account_type'], array('1', '3'));
$mailTypeForward = isset($_POST['account_type']) && in_array($_POST['account_type'], array('2', '3'));
if (!$mailTypeNormal && !$mailTypeForward) {
showBadRequestErrorPage();
}
$mailAddr = $mailData['mail_addr'];
if ($mailTypeNormal) {
// Check for pasword
$password = clean_input($_POST['password']);
$password_rep = clean_input($_POST['password_rep']);
if ($mailData['mail_pass'] == '_no_' || $password != '' || $password_rep != '') {
if ($password == '') {
set_page_message(tr('Password is missing.'), 'error');
return false;
} elseif ($password_rep == '') {
set_page_message(tr('You must confirm your password.'), 'error');
return false;
} elseif ($password !== $password_rep) {
set_page_message(tr("Passwords do not match."), 'error');
return false;
} elseif (!checkPasswordSyntax($password)) {
return false;
}
} else {
$password = $mailData['mail_pass'];
}
// Check for quota
$quota = clean_input($_POST['quota']);
if (is_number($quota)) {
$quota *= 1048576;
// MiB to Bytes
if ($mainDmnProps['mail_quota'] != '0') {
if ($quota == '0') {
set_page_message(tr('Incorrect Email quota.'), 'error');
return false;
}
$stmt = exec_query('SELECT SUM(`quota`) AS `quota` FROM `mail_users` WHERE `domain_id` = ? AND `quota` IS NOT NULL', $mainDmnProps['domain_id']);
$quotaLimit = floor($mainDmnProps['mail_quota'] - ($stmt->fields['quota'] - $mailData['quota']));
if ($quota > $quotaLimit) {
set_page_message(tr('Email quota cannot be bigger than %s', bytesHuman($quotaLimit, 'MiB')), 'error');
return false;
}
}
} else {
set_page_message(tr('Email quota must be a number.'), 'error');
return false;
}
switch ($domainType) {
case 'normal':
$mailType = MT_NORMAL_MAIL;
break;
case 'subdom':
$mailType = MT_SUBDOM_MAIL;
break;
case 'alias':
$mailType = MT_ALIAS_MAIL;
break;
case 'alssub':
$mailType = MT_ALSSUB_MAIL;
}
}
if ($mailTypeForward) {
// Check forward list
$forwardList = clean_input($_POST['forward_list']);
if ($forwardList == '') {
set_page_message(tr('Forward list is empty.'), 'error');
return false;
}
$forwardList = preg_split("/[\n,]+/", $forwardList);
foreach ($forwardList as $key => &$forwardEmailAddr) {
$forwardEmailAddr = encode_idna(trim($forwardEmailAddr));
if ($forwardEmailAddr == '') {
unset($forwardList[$key]);
} elseif (!chk_email($forwardEmailAddr)) {
set_page_message(tr('Wrong mail syntax in forward list.'), 'error');
return false;
} elseif ($forwardEmailAddr == $mailAddr) {
set_page_message(tr('You cannot forward %s on itself.', $mailAddr), 'error');
return false;
}
}
//.........这里部分代码省略.........
示例7: onAfterAddDomainAlias
/**
* onAfterAddDomainAlias event listener
*
* @param iMSCP_Events_Event $event
* @return void
*/
public function onAfterAddDomainAlias(iMSCP_Events_Event $event)
{
// Check that the domain alias is being added and not simply ordered
$stmt = exec_query('SELECT alias_id FROM domain_aliasses WHERE alias_id = ? AND alias_status = ?', array($event->getParam('domainAliasId'), 'toadd'));
if ($stmt->rowCount()) {
// In case OpenDKIM is activated for the parent domain, we must activate it also for the domain alias which
// is being added
$stmt = exec_query('SELECT admin_id FROM opendkim WHERE domain_id = ? AND alias_id IS NULL AND opendkim_status = ?', array($event->getParam('domainId'), 'ok'));
if ($stmt->rowCount()) {
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
exec_query('
INSERT INTO opendkim (
admin_id, domain_id, alias_id, domain_name, opendkim_status
) VALUES (
?, ?, ?, ?, ?
)
', array($row['admin_id'], $event->getParam('domainId'), $event->getParam('domainAliasId'), encode_idna($event->getParam('domainAliasName')), 'toadd'));
}
}
}
示例8: customerHasDomain
/**
* Does the given customer is the owner of the given domain?
*
* @param string $domainName Domain name (dmn,sub,als,alssub)
* @param int $customerId Customer unique identifier
* @return bool TRUE if the given customer is the owner of the given domain, FALSE otherwise
* TODO add admin_id as foreign key in all domain tables too avoid too many jointures
*/
function customerHasDomain($domainName, $customerId)
{
$domainName = encode_idna($domainName);
// Check in domain table
$stmt = exec_query("SELECT 'found' FROM domain WHERE domain_admin_id = ? AND domain_name = ?", array($customerId, $domainName));
if ($stmt->rowCount()) {
return true;
}
// Check in domain_aliasses table
$stmt = exec_query("\n\t\t\tSELECT\n\t\t\t\t'found'\n\t\t\tFROM\n\t\t\t\tdomain AS t1\n\t\t\tINNER JOIN\n\t\t\t\tdomain_aliasses AS t2 ON(t2.domain_id = t1.domain_id)\n\t\t\tWHERE\n\t\t\t\tt1.domain_admin_id = ?\n\t\t\tAND\n\t\t\t\tt2.alias_name = ?\n\t\t", array($customerId, $domainName));
if ($stmt->rowCount()) {
return true;
}
// Check in subdomain table
$stmt = exec_query("\n\t\t\tSELECT\n\t\t\t\t'found'\n\t\t\tFROM\n\t\t\t\tdomain AS t1\n\t\t\tINNER JOIN\n\t\t\t\tsubdomain AS t2 ON (t2.domain_id = t1.domain_id)\n\t\t\tWHERE\n\t\t\t\tt1.domain_admin_id = ?\n\t\t\tAND\n\t\t\t\tCONCAT(t2.subdomain_name, '.', t1.domain_name) = ?\n\t\t", array($customerId, $domainName));
if ($stmt->rowCount()) {
return true;
}
// Check in subdomain_alias table
$stmt = exec_query("\n\t\t\tSELECT\n\t\t\t\t'found'\n\t\t\tFROM\n\t\t\t\tdomain AS t1\n\t\t\tINNER JOIN\n\t\t\t\tdomain_aliasses AS t2 ON(t2.domain_id = t1.domain_id)\n\t\t\tINNER JOIN\n\t\t\t \tsubdomain_alias AS t3 ON(t3.alias_id = t2.alias_id)\n\t\t\tWHERE\n\t\t\t\tt1.domain_admin_id = ?\n\t\t\tAND\n\t\t\t\tCONCAT(t3.subdomain_alias_name, '.', t2.alias_name) = ?\n\t\t", array($customerId, $domainName));
if ($stmt->rowCount()) {
return true;
}
return false;
}
示例9: client_editDomainAlias
/**
* Edit domain alias
*
* @return bool TRUE on success, FALSE on failure
*/
function client_editDomainAlias()
{
if (isset($_GET['id'])) {
$domainAliasId = clean_input($_GET['id']);
if ($domainAliasData = _client_getAliasData($domainAliasId)) {
// Check for URL forwarding option
$forwardUrl = 'no';
if (isset($_POST['url_forwarding']) && $_POST['url_forwarding'] == 'yes') {
// We are safe here
if (isset($_POST['forward_url_scheme']) && isset($_POST['forward_url'])) {
$forwardUrl = clean_input($_POST['forward_url_scheme']) . clean_input($_POST['forward_url']);
try {
try {
$uri = iMSCP_Uri_Redirect::fromString($forwardUrl);
} catch (Zend_Uri_Exception $e) {
throw new iMSCP_Exception(tr('Forward URL %s is not valid.', "<strong>{$forwardUrl}</strong>"));
}
$uri->setHost(encode_idna($uri->getHost()));
if ($uri->getHost() == $domainAliasData['alias_name'] && $uri->getPath() == '/') {
throw new iMSCP_Exception(tr('Forward URL %s is not valid.', "<strong>{$forwardUrl}</strong>") . ' ' . tr('Domain alias %s cannot be forwarded on itself.', "<strong>{$domainAliasData['alias_name_utf8']}</strong>"));
}
$forwardUrl = $uri->getUri();
} catch (Exception $e) {
set_page_message($e->getMessage(), 'error');
return false;
}
} else {
showBadRequestErrorPage();
}
}
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeEditDomainAlias, array('domainAliasId' => $domainAliasId));
exec_query('UPDATE `domain_aliasses` SET `url_forward` = ?, `alias_status` = ? WHERE `alias_id` = ?', array($forwardUrl, 'tochange', $domainAliasId));
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterEditDomainALias, array('domainAliasId' => $domainAliasId));
send_request();
write_log("{$_SESSION['user_logged']}: scheduled update of domain alias: {$domainAliasData['alias_name_utf8']}.", E_USER_NOTICE);
} else {
showBadRequestErrorPage();
}
} else {
showBadRequestErrorPage();
}
return true;
}
示例10: array_encode_idna
/**
* Should be documented
*
* @param $arr
* @param bool $asPath
* @return string
*/
function array_encode_idna($arr, $asPath = false)
{
if ($asPath && !is_array($arr)) {
return implode('/', array_encode_idna(explode('/', $arr)));
}
foreach ($arr as $k => $v) {
if (strpos($v, 'xn--') === 0) {
$arr[$k] = $v;
} else {
$arr[$k] = encode_idna($v);
}
}
return $arr;
}
示例11: encode_idna
// Prevent external login (i.e. check for valid local referer) separated in admin, reseller and client.
// This option allows to use external login scripts
//
// 1: prevent external login, check for referer, more secure
// 0: allow external login, do not check for referer, less security (risky)
$config['PREVENT_EXTERNAL_LOGIN_ADMIN'] = 1;
$config['PREVENT_EXTERNAL_LOGIN_RESELLER'] = 1;
$config['PREVENT_EXTERNAL_LOGIN_CLIENT'] = 1;
// Automatic search for new version
$config['CHECK_FOR_UPDATES'] = 0;
$config['ENABLE_SSL'] = 1;
// Converting some possible IDN to ACE
$config['DEFAULT_ADMIN_ADDRESS'] = encode_idna($config->get('DEFAULT_ADMIN_ADDRESS'));
$config['SERVER_HOSTNAME'] = encode_idna($config->get('SERVER_HOSTNAME'));
$config['BASE_SERVER_VHOST'] = encode_idna($config->get('BASE_SERVER_VHOST'));
$config['DATABASE_HOST'] = encode_idna($config->get('DATABASE_HOST'));
// Server traffic settings
$config['SERVER_TRAFFIC_LIMIT'] = 0;
$config['SERVER_TRAFFIC_WARN'] = 0;
// Paths appended to the default PHP open_basedir directive of customers
$config['PHPINI_OPEN_BASEDIR'] = '';
// Store file last modification time to force reloading of configuration file if needed
$config['__filemtime__'] = filemtime(CONFIG_FILE_PATH);
if (!$config['DEBUG']) {
@file_put_contents(CONFIG_CACHE_FILE_PATH, serialize($config), LOCK_EX);
}
}
// Initialize application
iMSCP_Initializer::run($config);
// Remove useless variable
unset($configFilePath, $cachedConfigFilePath, $config);
示例12: client_saveDnsRecord
/**
* Check and save DNS record
*
* @throws iMSCP_Exception_Database
* @param int $dnsRecordId DNS record unique identifier (0 for new record)
* @return bool TRUE on success, FALSE otherwise
*/
function client_saveDnsRecord($dnsRecordId)
{
$mainDmnProps = get_domain_default_props($_SESSION['user_id']);
$mainDmnId = $mainDmnProps['domain_id'];
$errorString = '';
$dnsRecordName = '';
$dnsRecordClass = client_getPost('class');
$dnsRecordType = client_getPost('type');
if ($dnsRecordClass != 'IN' || !in_array($dnsRecordType, array('A', 'AAAA', 'CNAME', 'SRV', 'TXT'))) {
showBadRequestErrorPage();
}
$dnsRecordData = '';
if (!$dnsRecordId) {
if ($_POST['domain_id'] == 0) {
$domainName = $mainDmnProps['domain_name'];
$domainId = 0;
} else {
$stmt = exec_query('SELECT alias_id, alias_name FROM domain_aliasses WHERE alias_id = ? AND domain_id = ?', array($_POST['domain_id'], $mainDmnId));
if (!$stmt->rowCount()) {
showBadRequestErrorPage();
}
$domainName = $stmt->fields['alias_name'];
$domainId = $stmt->fields['alias_id'];
}
} else {
$stmt = exec_query('
SELECT
t1.*, IFNULL(t3.alias_name, t2.domain_name) domain_name,
IFNULL(t3.alias_status, t2.domain_status) domain_status
FROM
domain_dns AS t1
LEFT JOIN
domain AS t2 USING(domain_id)
LEFT JOIN
domain_aliasses AS t3 USING (alias_id)
WHERE
domain_dns_id = ?
AND
t1.domain_id = ?
', array($dnsRecordId, $mainDmnId));
if (!$stmt->rowCount()) {
showBadRequestErrorPage();
}
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$domainId = $row['alias_id'] ? $row['alias_id'] : $row['domain_id'];
$domainName = $row['domain_name'];
$dnsRecordName = $row['domain_dns'];
}
$nameValidationError = '';
if (in_array($dnsRecordType, array('A', 'AAAA', 'CNAME'))) {
if (!client_validate_NAME(client_getPost('dns_name'), $domainName, $nameValidationError)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $nameValidationError), 'error');
}
}
if (!Zend_Session::namespaceIsset('pageMessages')) {
switch ($dnsRecordType) {
case 'CNAME':
$cname = client_getPost('dns_cname');
$newName = encode_idna(substr(client_getPost('dns_name'), -1) == '.' ? client_getPost('dns_name') : client_getPost('dns_name') . '.' . $domainName);
$oldName = $dnsRecordName != '' ? substr($dnsRecordName, -1) == '.' ? $dnsRecordName : $dnsRecordName . '.' . $domainName : '';
if (!client_validate_CNAME($cname, $domainName, $errorString)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $errorString), 'error');
} elseif ($newName != $oldName && !client_checkConflict($newName, 'CNAME', $errorString)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $errorString), 'error');
} elseif ($newName != $oldName && !client_checkConflict($newName, 'A', $errorString)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $errorString), 'error');
} elseif ($newName != $oldName && !client_checkConflict($newName, 'AAAA', $errorString)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $errorString), 'error');
}
$dnsRecordName = encode_idna(client_getPost('dns_name'));
if ($cname != '@') {
$dnsRecordData = encode_idna($cname);
} else {
$dnsRecordData = $cname;
}
break;
case 'A':
$ip = client_getPost('dns_A_address');
$newName = encode_idna(substr(client_getPost('dns_name'), -1) == '.' ? client_getPost('dns_name') : client_getPost('dns_name') . '.' . $domainName);
if (!client_validate_A($ip, $errorString)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $errorString), 'error');
} elseif (!client_checkConflict($newName, 'CNAME', $errorString)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $errorString), 'error');
} elseif (!client_checkConflict($newName, 'A', $errorString)) {
set_page_message(sprintf(tr("Cannot validate record: %s"), $errorString), 'error');
}
$dnsRecordName = encode_idna(client_getPost('dns_name'));
$dnsRecordData = $ip;
break;
case 'AAAA':
$ip = client_getPost('dns_AAAA_address');
$newName = encode_idna(substr(client_getPost('dns_name'), -1) == '.' ? client_getPost('dns_name') : client_getPost('dns_name') . '.' . $domainName);
if (!client_validate_AAAA(client_getPost('dns_AAAA_address'), $errorString)) {
//.........这里部分代码省略.........
示例13: gen_admin_domain_query
/**
* Generate query for user search form
*
* @param string &$searchQuery
* @param string &$countQuery
* @param int $startIndex
* @param int $rowsPerPage
* @param string $searchFor
* @param string $searchCommon
* @param string $searchStatus
* @return void
*/
function gen_admin_domain_query(&$searchQuery, &$countQuery, $startIndex, $rowsPerPage, $searchFor, $searchCommon, $searchStatus)
{
$condition = '';
$startIndex = intval($startIndex);
$rowsPerPage = intval($rowsPerPage);
if ($searchFor == 'n/a' && $searchCommon == 'n/a' && $searchStatus == 'n/a') {
// We have pure list query;
$countQuery = 'SELECT COUNT(*) AS cnt FROM domain';
$searchQuery = "\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tdomain AS t1\n\t\t\tINNER JOIN\n\t\t\t\tadmin AS t2 ON (t2.admin_id = t1.domain_admin_id)\n\t\t\tORDER BY\n\t\t\t\tt1.domain_name ASC\n\t\t\tLIMIT\n\t\t\t\t{$startIndex}, {$rowsPerPage}\n\t\t";
} else {
/** @var iMSCP_Database $db */
$db = iMSCP_Registry::get('db');
$searchFor = str_replace(array('!', '_', '%'), array('!!', '!_', '!%'), $searchFor);
if ($searchFor == '' && $searchStatus != '') {
if ($searchStatus != 'all') {
$condition = 'WHERE t1.domain_status = ' . $db->quote($searchStatus);
}
$countQuery = "SELECT COUNT(*) AS cnt FROM domain AS t1 {$condition}";
$searchQuery = "\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\tdomain AS t1\n\t\t\t\tINNER JOIN\n\t\t\t\t\tadmin AS t2 ON (t2.admin_id = t1.domain_admin_id)\n\t\t\t\t{$condition}\n\t\t\t\tORDER BY\n\t\t\t\t\tt1.domain_name ASC\n\t\t\t\tLIMIT\n\t\t\t\t\t{$startIndex}, {$rowsPerPage}\n \t";
} elseif ($searchFor != '') {
$searchFor = str_replace(array('!', '_', '%'), array('!!', '!_', '!%'), $searchFor);
if ($searchCommon == 'domain_name') {
$searchFor = $db->quote('%' . encode_idna($searchFor) . '%');
$condition = "WHERE t1.domain_name LIKE {$searchFor} ESCAPE '!'";
} elseif ($searchCommon == 'customer_id') {
$searchFor = $db->quote("%{$searchFor}%");
$condition = "WHERE t2.customer_id LIKE {$searchFor} ESCAPE '!'";
} elseif ($searchCommon == 'lname') {
$searchFor = $db->quote("%{$searchFor}%");
$condition = "WHERE (t2.lname LIKE {$searchFor} ESCAPE '=' OR fname LIKE {$searchFor} ESCAPE '!')";
} elseif ($searchCommon == 'firm') {
$searchFor = $db->quote("%{$searchFor}%");
$condition = "WHERE t2.firm LIKE {$searchFor} ESCAPE '!'";
} elseif ($searchCommon == 'city') {
$searchFor = $db->quote("%{$searchFor}%");
$condition = "WHERE t2.city LIKE {$searchFor} ESCAPE '!'";
} elseif ($searchCommon == 'state') {
$searchFor = $db->quote("%{$searchFor}%");
$condition = "WHERE t2.state LIKE {$searchFor} ESCAPE '!'";
} elseif ($searchCommon == 'country') {
$searchFor = $db->quote("%{$searchFor}%");
$condition = "WHERE t2.country LIKE {$searchFor} ESCAPE '!'";
}
if ($condition != '') {
if ($searchStatus != 'all') {
$condition .= ' AND t1.domain_status = ' . $db->quote($searchStatus);
}
$countQuery = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tCOUNT(*) AS cnt\n\t\t\t\t \tFROM\n\t\t\t\t\t\tdomain AS t1\n\t\t\t\t INNER JOIN\n\t\t\t\t\t\tadmin AS t2 ON(t2.admin_id = t1.domain_admin_id)\n\t\t\t\t\t{$condition}\n\t\t\t ";
$searchQuery = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tt2.admin_id, t2.admin_status, t2.created_by, t1.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tdomain AS t1\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\tadmin AS t2 ON(t2.admin_id = t1.domain_admin_id)\n\t\t\t\t\t{$condition}\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tt1.domain_name ASC\n\t\t\t\t\tLIMIT\n\t\t\t\t\t\t{$startIndex}, {$rowsPerPage}\n\t\t\t\t";
}
}
}
}
示例14: check_fwd_data
/**
* Check input data
* @param EasySCP_TemplateEngine $tpl
* @param EasySCP_Database $sql
* @param int $subdomain_id
* @param string $dmn_type
*/
function check_fwd_data($tpl, $sql, $subdomain_id, $dmn_type, $dmn_id)
{
$forward_url = clean_input($_POST['forward']);
// unset errors
$ed_error = '_off_';
if (isset($_POST['status']) && $_POST['status'] == 1) {
$forward_prefix = clean_input($_POST['forward_prefix']);
$surl = @parse_url($forward_prefix . decode_idna($forward_url));
$domain = $surl['host'];
if (substr_count($domain, '.') <= 2) {
$ret = validates_dname($domain);
} else {
$ret = validates_dname($domain, true);
}
if (!$ret) {
$ed_error = tr('Wrong domain part in forward URL!');
} else {
$forward_url = encode_idna($forward_prefix . $forward_url);
}
$check_en = 'checked="checked"';
$check_dis = '';
$tpl->assign(array('FORWARD' => $forward_url, 'HTTP_YES' => $forward_prefix === 'http://' ? 'selected="selected"' : '', 'HTTPS_YES' => $forward_prefix === 'https://' ? 'selected="selected"' : '', 'FTP_YES' => $forward_prefix === 'ftp://' ? 'selected="selected"' : '', 'CHECK_EN' => $check_en, 'CHECK_DIS' => $check_dis));
} else {
$check_en = '';
$check_dis = 'checked="checked"';
$forward_url = 'no';
$tpl->assign(array('READONLY_FORWARD' => ' readonly', 'DISABLE_FORWARD' => ' disabled="disabled"', 'CHECK_EN' => $check_en, 'CHECK_DIS' => $check_dis));
}
if ($ed_error === '_off_') {
if ($dmn_type === 'dmn') {
$subdomainQuery = '
UPDATE
`subdomain`
SET
`subdomain_url_forward` = ?,
`status` = ?
WHERE
`subdomain_id` = ?
';
$domainQuery = '
UPDATE
domain
SET
status = ?
where
domain_id = ?
';
} else {
$subdomainQuery = '
UPDATE
`subdomain_alias`
SET
`subdomain_alias_url_forward` = ?,
`status` = ?
WHERE
`subdomain_alias_id` = ?
';
$domainQuery = '
UPDATE
domain_aliasses
SET
status = ?
where
alias_id = ?
';
}
exec_query($sql, $subdomainQuery, array($forward_url, EasySCP_Registry::get('Config')->ITEM_CHANGE_STATUS, $subdomain_id));
exec_query($sql, $domainQuery, array(EasySCP_Registry::get('Config')->ITEM_CHANGE_STATUS, $dmn_id));
if ($_POST['dmn_type'] == 'als') {
send_request('110 DOMAIN alias ' . $dmn_id);
} else {
send_request('110 DOMAIN domain ' . $dmn_id);
}
$admin_login = $_SESSION['user_logged'];
write_log("{$admin_login}: change domain alias forward: " . $subdomain_id);
unset($_SESSION['edit_ID']);
$tpl->assign('MESSAGE', '');
return true;
} else {
$tpl->assign('MESSAGE', $ed_error);
return false;
}
}
示例15: update_webdepot_software_list
/**
* Update repository index
*
* @param string $repositoryIndexFile Repository index file URI
* @param string $webRepositoryLastUpdate Web repository last update
*/
function update_webdepot_software_list($repositoryIndexFile, $webRepositoryLastUpdate)
{
$options = array('http' => array('user_agent' => 'PHP libxml agent'));
$context = stream_context_create($options);
libxml_set_streams_context($context);
$webRepositoryIndexFile = new DOMDocument('1.0', 'UTF-8');
$webRepositoryIndexFile->load($repositoryIndexFile);
$webRepositoryIndexFile = simplexml_import_dom($webRepositoryIndexFile);
if (utf8_decode($webRepositoryIndexFile->LAST_UPDATE->DATE) != $webRepositoryLastUpdate) {
$truncatequery = 'TRUNCATE TABLE `web_software_depot`';
exec_query($truncatequery);
$badSoftwarePackageDefinition = 0;
foreach ($webRepositoryIndexFile->PACKAGE as $package) {
if (!empty($package->INSTALL_TYPE) && !empty($package->TITLE) && !empty($package->VERSION) && !empty($package->LANGUAGE) && !empty($package->TYPE) && !empty($package->DESCRIPTION) && !empty($package->VENDOR_HP) && !empty($package->DOWNLOAD_LINK) && !empty($package->SIGNATURE_LINK)) {
$query = '
INSERT INTO
`web_software_depot` (
`package_install_type`, `package_title`, `package_version`, `package_language`,
`package_type`, `package_description`, `package_vendor_hp`, `package_download_link`,
`package_signature_link`
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?
)
';
exec_query($query, array(clean_input($package->INSTALL_TYPE), clean_input($package->TITLE), clean_input($package->VERSION), clean_input($package->LANGUAGE), clean_input($package->TYPE), clean_input($package->DESCRIPTION), encode_idna(strtolower(clean_input($package->VENDOR_HP))), encode_idna(strtolower(clean_input($package->DOWNLOAD_LINK))), encode_idna(strtolower(clean_input($package->SIGNATURE_LINK)))));
} else {
$badSoftwarePackageDefinition++;
break;
}
}
if (!$badSoftwarePackageDefinition) {
exec_query('UPDATE `web_software_options` SET `webdepot_last_update` = ?', array($webRepositoryIndexFile->LAST_UPDATE->DATE));
set_page_message(tr('Web software repository index been successfully updated.'), 'success');
} else {
set_page_message(tr('Update of Web software repository index has been aborted. Missing or empty fields.'), 'error');
}
} else {
set_page_message(tr('Web software repository index is already up to date.'), 'info');
}
}