本文整理汇总了PHP中EasySCP_Registry::get方法的典型用法代码示例。如果您正苦于以下问题:PHP EasySCP_Registry::get方法的具体用法?PHP EasySCP_Registry::get怎么用?PHP EasySCP_Registry::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasySCP_Registry
的用法示例。
在下文中一共展示了EasySCP_Registry::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: system_message
/**
* Generates a page message if something terribly goes wrong.
*
* @todo possible session injection, check $_SESSION['user_theme'] for valid
* value
*
* @param String $msg Message Content
* @param String $type Message Type (notice, warning, error, success)
* @param string $backButtonDestination Destiation where to go on back link
* click
*/
function system_message($msg, $type = 'error', $backButtonDestination = '')
{
$cfg = EasySCP_Registry::get('Config');
$theme_color = isset($_SESSION['user_theme']) ? $_SESSION['user_theme'] : $cfg->USER_INITIAL_THEME;
if (empty($backButtonDestination)) {
$backButtonDestination = "javascript:history.go(-1)";
}
$tpl = EasySCP_TemplateEngine::getInstance();
// If we are on the login page, path will be like this
$template = 'system-message.tpl';
if (!is_file($tpl->get_template_dir() . '/' . $template)) {
// But if we're inside the panel it will be like this
$template = '../system-message.tpl';
}
if (!is_file($tpl->get_template_dir() . '/' . $template)) {
// And if we don't find the template, we'll just displaying error
// message
throw new EasySCP_Exception($msg);
}
// Small workaround to be able to use the system_message() function during
// EasySCP initialization process without i18n support
if (function_exists('tr')) {
$tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP Error'), 'TR_BACK' => tr('Back'), 'TR_ERROR_MESSAGE' => tr('Error Message'), 'MESSAGE' => $msg, 'MSG_TYPE' => $type, 'BACKBUTTONDESTINATION' => $backButtonDestination, 'TR_LOGIN' => tr('Login'), 'TR_USERNAME' => tr('Username'), 'TR_PASSWORD' => tr('Password'), 'TR_LOSTPW' => tr('Lost password'), 'TR_WEBMAIL_SSL_LINK' => 'webmail', 'TR_FTP_SSL_LINK' => 'ftp', 'TR_PMA_SSL_LINK' => 'pma'));
} else {
$tpl->assign(array('TR_PAGE_TITLE' => 'EasySCP Error', 'TR_BACK' => 'Back', 'TR_ERROR_MESSAGE' => 'Error Message', 'MESSAGE' => $msg, 'MSG_TYPE' => $type, 'BACKBUTTONDESTINATION' => $backButtonDestination, 'TR_LOGIN' => 'Login', 'TR_USERNAME' => 'Username', 'TR_PASSWORD' => 'Password', 'TR_LOSTPW' => 'Lost password', 'TR_WEBMAIL_SSL_LINK' => 'webmail', 'TR_FTP_SSL_LINK' => 'ftp', 'TR_PMA_SSL_LINK' => 'pma'));
}
$tpl->display($template);
exit;
}
示例2: generate_page
/**
* @param EasySCP_TemplateEngine $tpl
* @param int $reseller_id
* @param string $reseller_name
*/
function generate_page($tpl, $reseller_id, $reseller_name)
{
global $rid;
$cfg = EasySCP_Registry::get('Config');
$sql = EasySCP_Registry::get('Db');
$start_index = 0;
$rows_per_page = $cfg->DOMAIN_ROWS_PER_PAGE;
if (isset($_GET['psi'])) {
$start_index = $_GET['psi'];
} else {
if (isset($_POST['psi'])) {
$start_index = $_POST['psi'];
}
}
$tpl->assign(array('POST_PREV_PSI' => $start_index));
// count query
$count_query = "\n\t\tSELECT\n\t\t\tCOUNT(`admin_id`) AS cnt\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'user'\n\t\tAND\n\t\t\t`created_by` = ?\n\t";
$query = <<<SQL_QUERY
\t\tSELECT
\t\t\t`admin_id`
\t\tFROM
\t\t\t`admin`
\t\tWHERE
\t\t\t`admin_type` = 'user'
\t\tAND
\t\t\t`created_by` = ?
\t\tORDER BY
\t\t\t`admin_name` DESC
\t\tLIMIT
\t\t\t{$start_index}, {$rows_per_page}
SQL_QUERY;
$rs = exec_query($sql, $count_query, $reseller_id);
$records_count = $rs->fields['cnt'];
$rs = exec_query($sql, $query, $reseller_id);
$tpl->assign(array('RESELLER_NAME' => tohtml($reseller_name), 'RESELLER_ID' => $reseller_id));
if ($rs->rowCount() == 0) {
$tpl->assign(array('DOMAIN_LIST' => '', 'SCROLL_PREV' => '', 'SCROLL_NEXT' => ''));
} else {
$prev_si = $start_index - $rows_per_page;
if ($start_index == 0) {
$tpl->assign('SCROLL_PREV', '');
} else {
$tpl->assign(array('SCROLL_PREV_GRAY' => '', 'PREV_PSI' => $prev_si, 'RID' => $rid));
}
$next_si = $start_index + $rows_per_page;
if ($next_si + 1 > $records_count) {
$tpl->assign('SCROLL_NEXT', '');
} else {
$tpl->assign(array('SCROLL_NEXT_GRAY' => '', 'NEXT_PSI' => $next_si, 'RID' => $rid));
}
$row = 1;
while (!$rs->EOF) {
$admin_id = $rs->fields['admin_id'];
$query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`domain_id`\n\t\t\t\tFROM\n\t\t\t\t\t`domain`\n\t\t\t\tWHERE\n\t\t\t\t\t`domain_admin_id` = ?\n\t\t\t;";
$dres = exec_query($sql, $query, $admin_id);
generate_domain_entry($tpl, $dres->fields['domain_id'], $row++);
$rs->moveNext();
}
}
}
示例3: check_udata
public static function check_udata($id, $pass)
{
$sql = EasySCP_Registry::get('Db');
$query = "\n\t\t\tSELECT\n\t\t\t\t`admin_id`, `admin_pass`\n\t\t\tFROM\n\t\t\t\t`admin`\n\t\t\tWHERE\n\t\t\t\t`admin_id` = ?\n\t\t\tAND\n\t\t\t\t`admin_pass` = ?\n\t\t";
$rs = exec_query($sql, $query, array($id, md5($pass)));
return $rs->recordCount() != 1 ? false : true;
}
示例4: pedit_user
function pedit_user($tpl, $sql, &$dmn_id, &$uuser_id)
{
$cfg = EasySCP_Registry::get('Config');
if (isset($_POST['uaction']) && $_POST['uaction'] == 'modify_user') {
// we have to add the user
if (isset($_POST['pass']) && isset($_POST['pass_rep'])) {
if (!chk_password($_POST['pass'])) {
if ($cfg->PASSWD_STRONG) {
set_page_message(sprintf(tr('The password must be at least %s chars long and contain letters and numbers to be valid.'), $cfg->PASSWD_CHARS), 'warning');
} else {
set_page_message(sprintf(tr('Password data is shorter than %s signs or includes not permitted signs!'), $cfg->PASSWD_CHARS), 'warning');
}
return;
}
if ($_POST['pass'] !== $_POST['pass_rep']) {
set_page_message(tr('Passwords do not match!'), 'warning');
return;
}
$nadmin_password = crypt_user_pass_with_salt($_POST['pass']);
$change_status = $cfg->ITEM_CHANGE_STATUS;
$query = "\n\t\t\t\tUPDATE\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tSET\n\t\t\t\t\t`upass` = ?,\n\t\t\t\t\t`status` = ?\n\t\t\t\tWHERE\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t\tAND\n\t\t\t\t\t`id` = ?\n\t\t\t";
exec_query($sql, $query, array($nadmin_password, $change_status, $dmn_id, $uuser_id));
send_request();
$query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`uname`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tWHERE\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t\tAND\n\t\t\t\t\t`id` = ?\n\t\t\t";
$rs = exec_query($sql, $query, array($dmn_id, $uuser_id));
$uname = $rs->fields['uname'];
$admin_login = $_SESSION['user_logged'];
write_log("{$admin_login}: modify user ID (protected areas): {$uname}");
user_goto('protected_user_manage.php');
}
} else {
return;
}
}
示例5: gen_hp_table
/**
* Extract and show data for hosting plans
* @param EasySCP_TemplateEngine $tpl
* @param int $reseller_id
*/
function gen_hp_table($tpl, $reseller_id)
{
global $external_event;
$sql = EasySCP_Registry::get('Db');
$cfg = EasySCP_Registry::get('Config');
if (isset($cfg->HOSTING_PLANS_LEVEL) && $cfg->HOSTING_PLANS_LEVEL === 'admin') {
$query = "\n\t\t\tSELECT\n\t\t\t\tt1.`id`, t1.`reseller_id`, t1.`name`, t1.`props`, t1.`status`,\n\t\t\t\tt2.`admin_id`, t2.`admin_type`\n\t\t\tFROM\n\t\t\t\t`hosting_plans` AS t1,\n\t\t\t\t`admin` AS t2\n\t\t\tWHERE\n\t\t\t\tt2.`admin_type` = ?\n\t\t\tAND\n\t\t\t\tt1.`reseller_id` = t2.`admin_id`\n\t\t\tAND\n\t\t\t\tt1.`status` = 1\n\t\t\tORDER BY\n\t\t\t\tt1.`name`\n\t\t";
$rs = exec_query($sql, $query, 'admin');
$tr_edit = tr('View details');
$tpl->assign('HP_MENU_ADD', '');
} else {
$query = "\n\t\t\tSELECT\n\t\t\t\t`id`, `name`, `props`, `status`\n\t\t\tFROM\n\t\t\t\t`hosting_plans`\n\t\t\tWHERE\n\t\t\t\t`reseller_id` = ?\n\t\t\tORDER BY\n\t\t\t\t`name`\n\t\t";
$rs = exec_query($sql, $query, $reseller_id);
}
if ($rs->rowCount() == 0) {
set_page_message(tr('Hosting plans not found!'), 'info');
$tpl->assign('HP_TABLE', '');
} else {
// There is data for hosting plans :-)
if ($external_event == '_off_') {
$tpl->assign('HP_MESSAGE', '');
}
$tpl->assign(array('TR_HOSTING_PLANS' => tr('Hosting plans'), 'TR_NOM' => tr('No.'), 'TR_EDIT' => tr('Edit'), 'TR_DELETE' => tr('Delete'), 'PLAN_SHOW' => tr('Show hosting plan'), 'TR_PLAN_NAME' => tr('Name'), 'TR_ACTION' => tr('Actions')));
$coid = isset($cfg->CUSTOM_ORDERPANEL_ID) ? $cfg->CUSTOM_ORDERPANEL_ID : '';
$i = 1;
while ($data = $rs->fetchRow()) {
$status = $data['status'] ? tr('Enabled') : tr('Disabled');
$tpl->append(array('PLAN_NOM' => $i++, 'PLAN_NAME' => tohtml($data['name']), 'PLAN_NAME2' => addslashes(clean_html($data['name'])), 'PURCHASING' => $status, 'CUSTOM_ORDERPANEL_ID' => $coid, 'HP_ID' => $data['id'], 'RESELLER_ID' => $_SESSION['user_id']));
}
}
}
示例6: gen_pgroups
/**
* @param EasySCP_TemplateEngine $tpl
* @param EasySCP_Database $sql
* @param int $dmn_id
*/
function gen_pgroups($tpl, $sql, &$dmn_id)
{
$cfg = EasySCP_Registry::get('Config');
$query = "\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t`htaccess_groups`\n\t\tWHERE\n\t\t\t`dmn_id` = ?\n\t\tORDER BY\n\t\t\t`dmn_id` DESC\n\t";
$rs = exec_query($sql, $query, $dmn_id);
if ($rs->recordCount() == 0) {
$tpl->assign('GROUP_MESSAGE', tr('You have no groups!'));
} else {
while (!$rs->EOF) {
$tpl->append(array('GNAME' => tohtml($rs->fields['ugroup']), 'GSTATUS' => translate_dmn_status($rs->fields['status']), 'GROUP_ID' => $rs->fields['id'], 'GROUP_DELETE' => tr('Delete'), 'GROUP_DELETE_SCRIPT' => $rs->fields['status'] === $cfg->ITEM_OK_STATUS && $rs->fields['ugroup'] != $cfg->AWSTATS_GROUP_AUTH ? "action_delete('protected_group_delete.php?gname=" . $rs->fields['id'] . "', '" . $rs->fields['ugroup'] . "')" : tr('N/A')));
if ($rs->fields['members'] != '') {
$group_members = '';
$members = explode(',', $rs->fields['members']);
$cnt_members = count($members);
for ($i = 0; $i < $cnt_members; $i++) {
$query = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t`uname`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`htaccess_users`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`id` = ?\n\t\t\t\t\t";
$rs_members = exec_query($sql, $query, $members[$i]);
if ($cnt_members == 1 || $cnt_members == $i + 1) {
$group_members .= tohtml($rs_members->fields['uname']);
} else {
$group_members .= tohtml($rs_members->fields['uname']) . ', ';
}
}
$tpl->append('MEMBER', $group_members);
} else {
$tpl->append('MEMBER', '');
}
$rs->moveNext();
}
}
}
示例7: update_server_settings
/**
* @todo What's about the outcommented code?
*/
function update_server_settings()
{
$sql = EasySCP_Registry::get('Db');
if (!isset($_POST['uaction']) && !isset($_POST['uaction'])) {
return;
}
/*global $data;
$match = array();
preg_match("/^(-1|0|[1-9][0-9]*)$/D", $data, $match);*/
$max_traffic = clean_input($_POST['max_traffic']);
$traffic_warning = $_POST['traffic_warning'];
if (!is_numeric($max_traffic) || !is_numeric($traffic_warning)) {
set_page_message(tr('Wrong data input!'), 'warning');
}
if ($traffic_warning > $max_traffic) {
set_page_message(tr('Warning traffic is bigger than max traffic!'), 'warning');
return;
}
if ($max_traffic < 0) {
$max_traffic = 0;
}
if ($traffic_warning < 0) {
$traffic_warning = 0;
}
$query = "\n\t\tUPDATE\n\t\t\t`straff_settings`\n\t\tSET\n\t\t\t`straff_max` = ?,\n\t\t\t`straff_warn` = ?\n\t";
exec_query($sql, $query, array($max_traffic, $traffic_warning));
set_page_message(tr('Server traffic settings updated successfully!'), 'success');
}
示例8: add_ip
/**
* @param EasySCP_TemplateEngine $tpl
*/
function add_ip($tpl)
{
$cfg = EasySCP_Registry::get('Config');
if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_ip') {
if (check_user_data()) {
$sql_param = array(':ip_number' => trim($_POST['ip_number_1']) . '.' . trim($_POST['ip_number_2']) . '.' . trim($_POST['ip_number_3']) . '.' . trim($_POST['ip_number_4']), ':ip_number_v6' => trim($_POST['ipv6']), ':ip_domain' => htmlspecialchars(trim($_POST['domain']), ENT_QUOTES, 'UTF-8'), ':ip_alias' => htmlspecialchars(trim($_POST['alias']), ENT_QUOTES, 'UTF-8'), ':ip_card' => htmlspecialchars(trim($_POST['ip_card']), ENT_QUOTES, 'UTF-8'), ':ip_ssl_domain_id' => NULL, ':ip_status' => $cfg->ITEM_OK_STATUS);
$sql_query = "\n\t\t\t\tINSERT INTO\n\t\t\t\t\tserver_ips (ip_number, ip_number_v6, ip_domain, ip_alias, ip_card, ip_ssl_domain_id, ip_status)\n\t\t\t\tVALUES\n\t\t\t\t\t(:ip_number, :ip_number_v6, :ip_domain, :ip_alias, :ip_card, :ip_ssl_domain_id, :ip_status)\n\t\t\t";
DB::prepare($sql_query);
DB::execute($sql_param)->closeCursor();
// todo Prüfen wie man das zukünftig behandeln soll
// send_request();
set_page_message(tr('New IP was added!'), 'success');
write_log('{' . $_SESSION['user_logged'] . '}: adds new IPv4 address: {' . trim($_POST['ip_number_1']) . '.' . trim($_POST['ip_number_2']) . '.' . trim($_POST['ip_number_3']) . '.' . trim($_POST['ip_number_4']) . '}!');
if (isset($_POST['ipv6']) && $_POST['ipv6'] != '') {
write_log('{' . $_SESSION['user_logged'] . '}: adds new IPv6 address: {' . trim($_POST['ipv6']) . '}!');
}
$sucess = true;
}
}
if (!isset($sucess) && isset($_POST['ip_number_1'])) {
$tpl->assign(array('VALUE_IP1' => tohtml($_POST['ip_number_1']), 'VALUE_IP2' => tohtml($_POST['ip_number_2']), 'VALUE_IP3' => tohtml($_POST['ip_number_3']), 'VALUE_IP4' => tohtml($_POST['ip_number_4']), 'VALUE_IPv6' => tohtml($_POST['ipv6']), 'VALUE_DOMAIN' => clean_input($_POST['domain'], true), 'VALUE_ALIAS' => clean_input($_POST['alias'], true)));
} else {
$tpl->assign(array('VALUE_IP1' => '', 'VALUE_IP2' => '', 'VALUE_IP3' => '', 'VALUE_IP4' => '', 'VALUE_IPv6' => '', 'VALUE_DOMAIN' => '', 'VALUE_ALIAS' => ''));
}
}
示例9: padd_group
function padd_group($tpl, $sql, $dmn_id)
{
$cfg = EasySCP_Registry::get('Config');
if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_group') {
// we have to add the group
if (isset($_POST['groupname'])) {
if (!validates_username($_POST['groupname'])) {
set_page_message(tr('Invalid group name!'), 'warning');
return;
}
$groupname = $_POST['groupname'];
$query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_groups`\n\t\t\t\tWHERE\n\t\t\t\t\t`ugroup` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
$rs = exec_query($sql, $query, array($groupname, $dmn_id));
if ($rs->recordCount() == 0) {
$change_status = $cfg->ITEM_ADD_STATUS;
$query = "\n\t\t\t\t\tINSERT INTO `htaccess_groups`\n\t\t\t\t\t\t(`dmn_id`, `ugroup`, `status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?)\n\t\t\t\t";
exec_query($sql, $query, array($dmn_id, $groupname, $change_status));
send_request();
$admin_login = $_SESSION['user_logged'];
write_log("{$admin_login}: add group (protected areas): {$groupname}");
user_goto('protected_user_manage.php');
} else {
set_page_message(tr('Group already exists!'), 'error');
return;
}
} else {
set_page_message(tr('Invalid group name!'), 'error');
return;
}
} else {
return;
}
}
示例10: gen_admin_personal_data
/**
* @param EasySCP_TemplateEngine $tpl
* @param int $user_id
*/
function gen_admin_personal_data($tpl, $user_id)
{
$cfg = EasySCP_Registry::get('Config');
$sql = EasySCP_Registry::get('Db');
$query = "\n\t\tSELECT\n\t\t\t`fname`,\n\t\t\t`lname`,\n\t\t\t`gender`,\n\t\t\t`firm`,\n\t\t\t`zip`,\n\t\t\t`city`,\n\t\t\t`state`,\n\t\t\t`country`,\n\t\t\t`street1`,\n\t\t\t`street2`,\n\t\t\t`email`,\n\t\t\t`phone`,\n\t\t\t`fax`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_id` = ?\n\t";
$rs = exec_query($sql, $query, $user_id);
$tpl->assign(array('FIRST_NAME' => empty($rs->fields['fname']) ? '' : tohtml($rs->fields['fname']), 'LAST_NAME' => empty($rs->fields['lname']) ? '' : tohtml($rs->fields['lname']), 'FIRM' => empty($rs->fields['firm']) ? '' : tohtml($rs->fields['firm']), 'ZIP' => empty($rs->fields['zip']) ? '' : tohtml($rs->fields['zip']), 'CITY' => empty($rs->fields['city']) ? '' : tohtml($rs->fields['city']), 'STATE' => empty($rs->fields['state']) ? '' : tohtml($rs->fields['state']), 'COUNTRY' => empty($rs->fields['country']) ? '' : tohtml($rs->fields['country']), 'STREET_1' => empty($rs->fields['street1']) ? '' : tohtml($rs->fields['street1']), 'STREET_2' => empty($rs->fields['street2']) ? '' : tohtml($rs->fields['street2']), 'EMAIL' => empty($rs->fields['email']) ? '' : tohtml($rs->fields['email']), 'PHONE' => empty($rs->fields['phone']) ? '' : tohtml($rs->fields['phone']), 'FAX' => empty($rs->fields['fax']) ? '' : tohtml($rs->fields['fax']), 'VL_MALE' => $rs->fields['gender'] == 'M' ? $cfg->HTML_SELECTED : '', 'VL_FEMALE' => $rs->fields['gender'] == 'F' ? $cfg->HTML_SELECTED : '', 'VL_UNKNOWN' => $rs->fields['gender'] == 'U' || empty($rs->fields['gender']) ? $cfg->HTML_SELECTED : ''));
}
示例11: set_email_tpl_data
function set_email_tpl_data($admin_id, $tpl_name, $data)
{
$sql = EasySCP_Registry::get('Db');
$query = "\n\t\tSELECT\n\t\t\t`subject`, `message`\n\t\tFROM\n\t\t\t`email_tpls`\n\t\tWHERE\n\t\t\t`owner_id` = ?\n\t\tAND\n\t\t\t`name` = ?\n\t";
$rs = exec_query($sql, $query, array($admin_id, $tpl_name));
if ($rs->rowCount() == 0) {
$query = "\n\t\t\tINSERT INTO `email_tpls`\n\t\t\t\t(`subject`, `message`, `owner_id`, `name`)\n\t\t\tVALUES\n\t\t\t\t(?, ?, ?, ?)\n\t\t";
} else {
$query = "\n\t\t\tUPDATE\n\t\t\t\t`email_tpls`\n\t\t\tSET\n\t\t\t\t`subject` = ?,\n\t\t\t\t`message` = ?\n\t\t\tWHERE\n\t\t\t\t`owner_id` = ?\n\t\t\tAND\n\t\t\t\t`name` = ?\n\t\t";
}
exec_query($sql, $query, array($data['subject'], $data['message'], $admin_id, $tpl_name));
}
示例12: check_udata
function check_udata($id, $pass)
{
$sql = EasySCP_Registry::get('Db');
$query = "\n\t\tSELECT\n\t\t\t`admin_name`, `admin_pass`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_id` = ?\n\t";
$rs = exec_query($sql, $query, $id);
if ($rs->recordCount() == 1) {
$rs = $rs->fetchRow();
if (crypt($pass, $rs['admin_pass']) == $rs['admin_pass'] || md5($pass) == $rs['admin_pass']) {
return true;
}
}
return false;
}
示例13: gen_purchase_haf
/**
* @todo use template(s) instead of hardcoded XHTML
* @param object $tpl EasySCP_TemplateEngine instance
* @param object $sql EasySCP_Database instance
* @param int $user_id
* @param bool encode
*/
function gen_purchase_haf($tpl, $sql, $user_id, $encode = false)
{
$cfg = EasySCP_Registry::get('Config');
$query = "\n\t\tSELECT\n\t\t\t`header`, `footer`\n\t\tFROM\n\t\t\t`orders_settings`\n\t\tWHERE\n\t\t\t`user_id` = ?\n\t\t;\n\t";
$rs = exec_query($sql, $query, $user_id);
if ($rs->recordCount() == 0) {
$THEME_CHARSET = tr('encoding');
$title = tr("EasySCP - Order Panel");
$THEME_COLOR_PATH = $cfg->LOGIN_TEMPLATE_PATH;
$header = <<<RIC
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en">
<head>
\t<title>{$title}</title>
\t<meta http-equiv='Content-Script-Type' content='text/javascript' />
\t<meta http-equiv='Content-Style-Type' content='text/css' />
\t<meta http-equiv='Content-Type' content='text/html; charset={$THEME_CHARSET}' />
\t<meta name='copyright' content='EasySCP' />
\t<meta name='owner' content='EasySCP' />
\t<meta name='publisher' content='EasySCP' />
\t<meta name='robots' content='nofollow, noindex' />
\t<meta name='title' content='{$title}' />
\t<link href="/{$THEME_COLOR_PATH}/css/easyscp.orderpanel.css" rel="stylesheet" type="text/css" />
</head>
<body>
\t<div style="margin: 20px auto;">
\t\t<table style="height: 95%;width: 100%;">
\t\t\t<tr>
\t\t\t\t<td align="center">
RIC;
$footer = <<<RIC
\t\t\t\t</td>
\t\t\t</tr>
\t\t</table>
\t</div>
</body>
</html>
RIC;
} else {
$header = $rs->fields['header'];
$footer = $rs->fields['footer'];
$header = str_replace('\\', '', $header);
$footer = str_replace('\\', '', $footer);
}
if ($encode) {
$header = htmlentities($header, ENT_COMPAT, 'UTF-8');
$footer = htmlentities($footer, ENT_COMPAT, 'UTF-8');
}
$tpl->assign(array('PURCHASE_HEADER' => $header, 'PURCHASE_FOOTER' => $footer));
}
示例14: gen_directories
/**
* @param EasySCP_TemplateEngine $tpl
*/
function gen_directories($tpl)
{
$sql = EasySCP_Registry::get('Db');
// Initialize variables
$path = isset($_GET['cur_dir']) ? $_GET['cur_dir'] : '';
$domain = $_SESSION['user_logged'];
// Create the virtual file system and open it so it can be used
$vfs = new EasySCP_VirtualFileSystem($domain, $sql);
// Get the directory listing
$list = $vfs->ls($path);
if (!$list) {
set_page_message(tr('Cannot open directory!<br />Please contact your administrator!'), 'error');
return;
}
// Show parent directory link
$parent = explode(DIRECTORY_SEPARATOR, $path);
array_pop($parent);
$parent = implode(DIRECTORY_SEPARATOR, $parent);
$tpl->append(array('ACTION' => '', 'ACTION_LINK' => 'no', 'ICON' => "parent", 'DIR_NAME' => tr('Parent Directory'), 'CHOOSE_IT' => '', 'LINK' => 'ftp_choose_dir.php?cur_dir=' . $parent));
// Show directories only
foreach ($list as $entry) {
// Skip non-directory entries
if ($entry['type'] != EasySCP_VirtualFileSystem::VFS_TYPE_DIR) {
continue;
}
// Skip '.' and '..'
if ($entry['file'] == '.' || $entry['file'] == '..') {
continue;
}
// Check for .htaccess existence to display another icon
$dr = $path . '/' . $entry['file'];
$tfile = $dr . '/.htaccess';
if ($vfs->exists($tfile)) {
$image = "locked";
} else {
$image = "folder";
}
// Check if folder does not contain a folder that can not be protected
// @todo: valid directories (e.g. /htdocs/disabled/) are excluded (false positive)
$forbiddenDirnames = '/backups|disabled|errors|logs|phptmp/i';
$forbidden = preg_match($forbiddenDirnames, $entry['file']);
if ($forbidden === 1) {
$tpl->append('ACTION_LINK', 'no');
} else {
$tpl->append('ACTION_LINK', 'yes');
}
// Create the directory link
$tpl->append(array('PROTECT_IT' => "protected_areas_add.php?file=" . $dr, 'ICON' => $image, 'DIR_NAME' => tohtml($entry['file']), 'CHOOSE_IT' => $dr, 'LINK' => "ftp_choose_dir.php?cur_dir=" . $dr));
}
}
示例15: _getLoginCredentials
/**
* Get ftp login credentials
*
* @author William Lightning <kassah@gmail.com>
* @since 1.1.0
* @access private
* @param string $userid FTP User
* @return array Array that contains login credentials or FALSE on failure
*/
function _getLoginCredentials($userId)
{
/**
* @var $db EasySCP_Database_ResultSet
*/
$db = EasySCP_Registry::get('Db');
// @todo Should be optimized
$query = "\n\t\tSELECT\n\t\t\t`userid`, `net2ftppasswd`\n\t\tFROM\n\t\t\t`ftp_users`, `domain`\n\t\tWHERE\n\t\t\t\t`ftp_users`.`uid` = `domain`.`domain_uid`\n\t\t\tAND\n\t\t\t\t`ftp_users`.`userid` = ?\n\t\t\tAND\n\t\t\t\t`domain`.`domain_admin_id` = ?;\n\t";
$stmt = exec_query($db, $query, array($userId, $_SESSION['user_id']));
if ($stmt->rowCount() == 1) {
return array($stmt->fields['userid'], decrypt_db_password($stmt->fields['net2ftppasswd']));
} else {
return false;
}
}