本文整理汇总了PHP中Database::pexecute_first方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::pexecute_first方法的具体用法?PHP Database::pexecute_first怎么用?PHP Database::pexecute_first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::pexecute_first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadSettings
/**
* @FIXME remove when fully migrated to new Settings class
*
* @param array $settings_data
*
* @return array
*/
function loadSettings(&$settings_data)
{
$settings = array();
if (is_array($settings_data) && isset($settings_data['groups']) && is_array($settings_data['groups'])) {
// prepare for use in for-loop
$row_stmt = Database::prepare("\n\t\t\tSELECT `settinggroup`, `varname`, `value`\n\t\t\tFROM `" . TABLE_PANEL_SETTINGS . "`\n\t\t\tWHERE `settinggroup` = :group AND `varname` = :varname\n\t\t");
foreach ($settings_data['groups'] as $settings_part => $settings_part_details) {
if (is_array($settings_part_details) && isset($settings_part_details['fields']) && is_array($settings_part_details['fields'])) {
foreach ($settings_part_details['fields'] as $field_name => $field_details) {
if (isset($field_details['settinggroup']) && isset($field_details['varname']) && isset($field_details['default'])) {
// execute prepared statement
$row = Database::pexecute_first($row_stmt, array('group' => $field_details['settinggroup'], 'varname' => $field_details['varname']));
if (!empty($row)) {
$varvalue = $row['value'];
} else {
$varvalue = $field_details['default'];
}
$settings[$field_details['settinggroup']][$field_details['varname']] = $varvalue;
} else {
$varvalue = false;
}
$settings_data['groups'][$settings_part]['fields'][$field_name]['value'] = $varvalue;
}
}
}
}
return $settings;
}
示例2: getIpPortCombinations
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getIpPortCombinations($ssl = false)
{
global $userinfo;
$additional_conditions_params = array();
$additional_conditions_array = array();
if ($userinfo['ip'] != '-1') {
$admin_ip_stmt = Database::prepare("\n\t\t\tSELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid\n\t\t");
$admin_ip = Database::pexecute_first($admin_ip_stmt, array('ipid' => $userinfo['ip']));
$additional_conditions_array[] = "`ip` = :adminip";
$additional_conditions_params['adminip'] = $admin_ip['ip'];
$admin_ip = null;
}
if ($ssl !== null) {
$additional_conditions_array[] = "`ssl` = :ssl";
$additional_conditions_params['ssl'] = $ssl === true ? '1' : '0';
}
$additional_conditions = '';
if (count($additional_conditions_array) > 0) {
$additional_conditions = " WHERE " . implode(" AND ", $additional_conditions_array) . " ";
}
$result_stmt = Database::prepare("\n\t\tSELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $additional_conditions . " ORDER BY `ip` ASC, `port` ASC\n\t");
Database::pexecute($result_stmt, $additional_conditions_params);
$system_ipaddress_array = array();
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row['ip'] = '[' . $row['ip'] . ']';
}
$system_ipaddress_array[$row['id']] = $row['ip'] . ':' . $row['port'];
}
return $system_ipaddress_array;
}
示例3: getVhostsToCreate
/**
* returns an array with all entries required for all
* webserver-vhost-configs
*
* @return array
*/
public static function getVhostsToCreate()
{
$query = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`,\n\t\t\t\t`d`.`phpsettingid`, `c`.`adminid`, `c`.`guid`, `c`.`email`,\n\t\t\t\t`c`.`documentroot` AS `customerroot`, `c`.`deactivated`,\n\t\t\t\t`c`.`phpenabled` AS `phpenabled`, `d`.`mod_fcgid_starter`,\n\t\t\t\t`d`.`mod_fcgid_maxrequests`\n\t\t\t\tFROM `" . TABLE_PANEL_DOMAINS . "` `d`\n\n\t\t\t\tLEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`)\n\t\t\t\tLEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`)\n\n\t\t\t\tWHERE `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> '1'\n\t\t\t\tORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC;\n\t\t";
$result_domains_stmt = Database::query($query);
$domains = array();
while ($domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
if (!checkDomainIPConfigured($domain['id'])) {
continue;
}
// set whole domain
$domains[$domain['domain']] = $domain;
// set empty-defaults for non-ssl
$domains[$domain['domain']]['ssl'] = '';
$domains[$domain['domain']]['ssl_cert_file'] = '';
$domains[$domain['domain']]['ssl_key_file'] = '';
$domains[$domain['domain']]['ssl_ca_file'] = '';
$domains[$domain['domain']]['ssl_cert_chainfile'] = '';
// now, if the domain has an ssl ip/port assigned, get
// the corresponding information from the db
if (domainHasSslIpPort($domain['id'])) {
$ip_stmt = Database::prepare("\n\t\t\t\t\t\tSELECT `di`.`id_domain` , `p`.`ssl`, `p`.`ssl_cert_file`, `p`.`ssl_key_file`, `p`.`ssl_ca_file`, `p`.`ssl_cert_chainfile`\n\t\t\t\t\t\tFROM `" . TABLE_DOMAINTOIP . "` `di`, `" . TABLE_PANEL_IPSANDPORTS . "` `p`\n\t\t\t\t\t\tWHERE `p`.`id` = `di`.`id_ipandports`\n\t\t\t\t\t\tAND `di`.`id_domain` = :domainid\n\t\t\t\t\t\tAND `p`.`ssl` = '1'\n\t\t\t\t\t\t");
$ssl_ip = Database::pexecute_first($ip_stmt, array('domainid' => $domain['id']));
// set ssl info for domain
$domains[$domain['domain']]['ssl'] = '1';
$domains[$domain['domain']]['ssl_cert_file'] = $ssl_ip['ssl_cert_file'];
$domains[$domain['domain']]['ssl_key_file'] = $ssl_ip['ssl_key_file'];
$domains[$domain['domain']]['ssl_ca_file'] = $ssl_ip['ssl_ca_file'];
$domains[$domain['domain']]['ssl_cert_chainfile'] = $ssl_ip['ssl_cert_chainfile'];
}
}
return $domains;
}
示例4: DatabaseCharset
/**
* check whether the froxlor database and its tables are in utf-8 character-set
*
* @param bool $fix fix db charset/collation if not utf8
*
* @return boolean
*/
public function DatabaseCharset($fix = false)
{
// get characterset
$cs_stmt = Database::prepare('SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = :dbname');
$resp = Database::pexecute_first($cs_stmt, array('dbname' => Database::getDbName()));
$charset = isset($resp['default_character_set_name']) ? $resp['default_character_set_name'] : null;
if (!empty($charset) && strtolower($charset) != 'utf8') {
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "database charset seems to be different from UTF-8, integrity-check can fix that");
if ($fix) {
// fix database
Database::query('ALTER DATABASE `' . Database::getDbName() . '` CHARACTER SET utf8 COLLATE utf8_general_ci');
// fix all tables
$handle = Database::query('SHOW TABLES');
while ($row = $handle->fetch(PDO::FETCH_ASSOC)) {
foreach ($row as $table) {
Database::query('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;');
}
}
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "database charset was different from UTF-8, integrity-check fixed that");
} else {
return false;
}
}
if ($fix) {
return $this->DatabaseCharset();
}
return true;
}
示例5: setDomainSSLFilesArray
/**
* read domain-related (or if empty, parentdomain-related) ssl-certificates from the database
* and (if not empty) set the corresponding array-indices (ssl_cert_file, ssl_key_file,
* ssl_ca_file and ssl_cert_chainfile). Hence the parameter as reference.
*
* @param array $domain domain-array as reference so we can set the corresponding array-indices
*
* @return null
*/
public function setDomainSSLFilesArray(array &$domain = null)
{
// check if the domain itself has a certificate defined
$dom_certs_stmt = Database::prepare("\n\t\t\tSELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domid\n\t\t");
$dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['id']));
if (!is_array($dom_certs) || !isset($dom_certs['ssl_cert_file']) || $dom_certs['ssl_cert_file'] == '') {
// maybe its parent?
if ($domain['parentdomainid'] != null) {
$dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['parentdomainid']));
}
}
// check if it's an array and if the most important field is set
if (is_array($dom_certs) && isset($dom_certs['ssl_cert_file']) && $dom_certs['ssl_cert_file'] != '') {
// get destination path
$sslcertpath = makeCorrectDir(Settings::Get('system.customer_ssl_path'));
// create path if it does not exist
if (!file_exists($sslcertpath)) {
safe_exec('mkdir -p ' . escapeshellarg($sslcertpath));
}
// make correct files for the certificates
$ssl_files = array('ssl_cert_file' => makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '.crt'), 'ssl_key_file' => makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '.key'));
if (Settings::Get('system.webserver') == 'lighttpd') {
// put my.crt and my.key together for lighty.
$dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file']) . "\n" . trim($dom_certs['ssl_key_file']) . "\n";
$ssl_files['ssl_key_file'] = '';
}
// initialize optional files
$ssl_files['ssl_ca_file'] = '';
$ssl_files['ssl_cert_chainfile'] = '';
// set them if they are != empty
if ($dom_certs['ssl_ca_file'] != '') {
$ssl_files['ssl_ca_file'] = makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '_CA.pem');
}
if ($dom_certs['ssl_cert_chainfile'] != '') {
if (Settings::Get('system.webserver') == 'nginx') {
// put ca.crt in my.crt, as nginx does not support a separate chain file.
$dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file']) . "\n" . trim($dom_certs['ssl_cert_chainfile']) . "\n";
} else {
$ssl_files['ssl_cert_chainfile'] = makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '_chain.pem');
}
}
// create them on the filesystem
foreach ($ssl_files as $type => $filename) {
if ($filename != '') {
touch($filename);
$_fh = fopen($filename, 'w');
fwrite($_fh, $dom_certs[$type]);
fclose($_fh);
chmod($filename, 0600);
}
}
// override corresponding array values
$domain['ssl_cert_file'] = $ssl_files['ssl_cert_file'];
$domain['ssl_key_file'] = $ssl_files['ssl_key_file'];
$domain['ssl_ca_file'] = $ssl_files['ssl_ca_file'];
$domain['ssl_cert_chainfile'] = $ssl_files['ssl_cert_chainfile'];
}
return;
}
示例6: isUserProtected
/**
* check whether the directory is protected using panel_htpasswd
*/
public function isUserProtected()
{
$up_stmt = Database::prepare("\n\t\t\tSELECT COUNT(`id`) as `usrprot` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `path` = :dir\n\t\t");
$up_res = Database::pexecute_first($up_stmt, array('dir' => $this->_dir));
if ($up_res != false && isset($up_res['usrprot'])) {
return $up_res['usrprot'] > 0 ? true : false;
}
return false;
}
示例7: domainHasMainSubDomains
/**
* check whether a domain has subdomains added as full-domains
* #329
*
* @param int $id domain-id
*
* @return boolean
*/
function domainHasMainSubDomains($id = 0)
{
$result_stmt = Database::prepare("\n\t\tSELECT COUNT(`id`) as `mainsubs` FROM `" . TABLE_PANEL_DOMAINS . "`\n\t\tWHERE `ismainbutsubto` = :id");
$result = Database::pexecute_first($result_stmt, array('id' => $id));
if (isset($result['mainsubs']) && $result['mainsubs'] > 0) {
return true;
}
return false;
}
示例8: getLoginNameByUid
/**
* returns the loginname of a customer by given uid
*
* @param int $uid uid of customer
*
* @return string customers loginname
*/
function getLoginNameByUid($uid = null)
{
$result_stmt = Database::prepare("\n\t\tSELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `guid` = :guid\n\t");
$result = Database::pexecute_first($result_stmt, array('guid' => $uid));
if (is_array($result) && isset($result['loginname'])) {
return $result['loginname'];
}
return false;
}
示例9: getCustomerDetail
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getCustomerDetail($customerid, $varname)
{
$customer_stmt = Database::prepare("\n\t\tSELECT `" . $varname . "` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :customerid\n\t");
$customer = Database::pexecute_first($customer_stmt, array('customerid' => $customerid));
if (isset($customer[$varname])) {
return $customer[$varname];
} else {
return false;
}
}
示例10: isCustomerStdSubdomain
/**
* returns true or false whether a given domain id
* is the std-subdomain of a customer
*
* @param int domain-id
*
* @return boolean
*/
function isCustomerStdSubdomain($did = 0)
{
if ($did > 0) {
$result_stmt = Database::prepare("\n\t\t\tSELECT `customerid` FROM `" . TABLE_PANEL_CUSTOMERS . "`\n\t\t\tWHERE `standardsubdomain` = :did\n\t\t");
$result = Database::pexecute_first($result_stmt, array('did' => $did));
if (is_array($result) && isset($result['customerid']) && $result['customerid'] > 0) {
return true;
}
}
return false;
}
示例11: getDomainRedirectId
/**
* returns the redirect-id for a given
* domain-id
*
* @param integer $domainid id of the domain
*
* @return integer redirect-code-id
*/
function getDomainRedirectId($domainid = 0)
{
$code = 1;
if ($domainid > 0) {
$result_stmt = Database::prepare("\n\t\t\tSELECT `r`.`id` as `redirect`\n\t\t\tFROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`\n\t\t\tWHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid\n\t\t");
$result = Database::pexecute_first($result_stmt, array('domainid' => $domainid));
if (is_array($result) && isset($result['redirect'])) {
$code = (int) $result['redirect'];
}
}
return $code;
}
示例12: getPhpConfig
/**
* return the php-configuration from the database
*
* @param int $php_config_id id of the php-configuration
*
* @return array
*/
public function getPhpConfig($php_config_id)
{
$php_config_id = intval($php_config_id);
// If domain has no config, we will use the default one.
if ($php_config_id == 0) {
$php_config_id = 1;
}
if (!isset($this->php_configs_cache[$php_config_id])) {
$stmt = Database::prepare("\n\t\t\t\t\tSELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id");
$this->_php_configs_cache[$php_config_id] = Database::pexecute_first($stmt, array('id' => $php_config_id));
}
return $this->_php_configs_cache[$php_config_id];
}
示例13: moveCustomerToAdmin
/**
* Function to move a given customer to a given admin/reseller
* and update all its references accordingly
*
* @param int $id customer-id
* @param int $adminid target-admin-id
*
* @return true on sucess, error-message on failure
*/
function moveCustomerToAdmin($id = 0, $adminid = 0)
{
if ($id <= 0 || $adminid <= 0) {
return "no valid id's given";
}
// get current admin-id
$cAdmin_stmt = Database::prepare("\n\t\tSELECT `adminid` FROM `" . TABLE_PANEL_CUSTOMERS . "`\n\t\tWHERE `customerid` = :cid\n\t");
$cAdmin = Database::pexecute_first($cAdmin_stmt, array('cid' => $id));
// Update customer entry
$updCustomer_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t");
Database::pexecute($updCustomer_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id));
// Update customer-domains
$updDomains_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_DOMAINS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t");
Database::pexecute($updDomains_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id));
// Update customer-tickets
$updTickets_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_TICKETS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t");
Database::pexecute($updTickets_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id));
// now, recalculate the resource-usage for the old and the new admin
updateCounters(false);
return true;
}
示例14: getAllowedDomainEntry
/**
* This file is part of the Froxlor project.
* Copyright (c) 2016 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2016-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getAllowedDomainEntry($domain_id, $area = 'customer', $userinfo, &$idna_convert)
{
$dom_data = array('did' => $domain_id);
$where_clause = '';
if ($area == 'admin') {
if ($userinfo['domains_see_all'] != '1') {
$where_clause = '`adminid` = :uid AND ';
$dom_data['uid'] = $userinfo['userid'];
}
} else {
$where_clause = '`customerid` = :uid AND ';
$dom_data['uid'] = $userinfo['userid'];
}
$dom_stmt = Database::prepare("\n\t\tSELECT domain, isbinddomain\n\t\tFROM `" . TABLE_PANEL_DOMAINS . "`\n\t\tWHERE " . $where_clause . " id = :did\n\t");
$domain = Database::pexecute_first($dom_stmt, $dom_data);
if ($domain) {
if ($domain['isbinddomain'] != '1') {
standard_error('dns_domain_nodns');
}
return $idna_convert->decode($domain['domain']);
}
standard_error('dns_notfoundorallowed');
}
示例15: redirectTo
}
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else {
$customer_add_data = (include_once dirname(__FILE__) . '/lib/formfields/admin/formfield.customer.php');
$customer_add_form = HTMLform2::genHTMLform($customer_add_data);
eval("echo \"" . getTemplate("customers/customers_add") . "\";");
}
}
} elseif ($action == 'edit' && $id != 0) {
$result_data = array('id' => $id);
$result_stmt = Database::prepare("\n\t\t\tSELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`\n\t\t\tWHERE `customerid` = :id" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid"));
if ($userinfo['customers_see_all'] == '0') {
$result_data['adminid'] = $userinfo['adminid'];
}
$result = Database::pexecute_first($result_stmt, $result_data);
/*
* information for moving customer
*/
$available_admins_stmt = Database::prepare("\n SELECT * FROM `" . TABLE_PANEL_ADMINS . "`\n WHERE (`customers` = '-1' OR `customers` > `customers_used`)");
Database::pexecute($available_admins_stmt);
$admin_select = makeoption("-----", 0, true, true, true);
$admin_select_cnt = 0;
while ($available_admin = $available_admins_stmt->fetch()) {
$admin_select .= makeoption($available_admin['name'] . " (" . $available_admin['loginname'] . ")", $available_admin['adminid'], null, true, true);
$admin_select_cnt++;
}
/*
* end of moving customer stuff
*/
if ($result['loginname'] != '') {