本文整理汇总了PHP中Config::GetInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::GetInstance方法的具体用法?PHP Config::GetInstance怎么用?PHP Config::GetInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::GetInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetSqliteFile
public function GetSqliteFile()
{
if (Config::GetInstance()->sdrive) {
return Config::GetInstance()->sdrive['sdrive_account_datastore_path'] . WRITEDB;
}
return '';
}
示例2: __construct
function __construct($cfg_section)
{
parent::__construct($cfg_section);
$sqlite_folder = Config::GetInstance()->GetStorageFolder(2);
$db = Config::GetInstance()->GetConfig('settings', 'data_settings', $cfg_section);
if (!$db) {
writeErrorLog('Failed to get configuration data in ' . __CLASS__ . ' for section: ', $cfg_section);
$this->errors[] = array('err' => _T('Failed to open database.'));
return;
}
// database names longer than 248 chars won't work
// (it seems sqlite has no problem with table names in excess of 450 chars)
if (strlen($db->database) > 200) {
$dbname = substr($db->database, 0, 200) . md5($db->database);
} else {
$dbname = $db->database;
}
try {
try {
$this->db = new PDO('sqlite:' . $sqlite_folder . $dbname);
} catch (PDOException $e) {
if (file_exists($sqlite_folder) || !mkdir($sqlite_folder, 0755, true)) {
throw $e;
}
$this->db = new PDO('sqlite:' . $sqlite_folder . $dbname);
}
} catch (PDOException $e) {
// Something happened and couldn't connect to SQLLite
writeErrorLog('Problems connecting to SQLite ' . $sqlite_folder . $dbname . ': [' . $e->getCode() . ']', $e->getMessage());
$this->errors[] = array('err' => _T('Failed to open database [%s] %s', array($e->getCode(), $e->getMessage())));
}
}
示例3: makeprices
/**
* CoffeeCup Software's Web Form Builder.
*
* Create product definitions from form fields that the SCC cart accepts.
*
*
* @version $Revision: 2456 $
* @author Cees de Gruijter
* @category FB
* @copyright Copyright (c) 2011 CoffeeCup Software, Inc. (http://www.coffeecup.com/)
*/
function makeprices($checkoutctr)
{
$pricer = new FieldPricer();
$pricer->setDecimals(Config::GetInstance()->GetConfig('settings', 'payment_settings', 'decimals'));
// first get the fixed form price
$descr = Config::GetInstance()->GetConfig('settings', 'payment_settings', 'invoicelabel');
$price = Config::GetInstance()->GetConfig('settings', 'payment_settings', 'fixedprice');
if ($price > 0) {
$prd = new Prod();
$prd->productid = 'formid_' . $checkoutctr->GetFormName();
// name and description should be the same unless the descr really adds info
$prd->name = empty($descr) ? $prd->productid : $descr;
$prd->shortdescription = '';
$prd->yourprice = $price;
$prd->quantity = 1;
$pricer->addProduct($prd);
}
$payrules = Config::GetInstance()->GetConfig('payment_rules');
$rules = Config::GetInstance()->GetConfig('rules');
foreach ($checkoutctr->getFormPost() as $name => $value) {
if (isset($payrules->{$name}) && isset($rules->{$name})) {
// create method name like: "field_type"_"payment_type"
$fieldtype = $rules->{$name}->fieldtype . '_' . $payrules->{$name}->type;
if (method_exists('FieldPricer', $fieldtype)) {
$pricer->{$fieldtype}(Config::GetInstance()->GetOriginalPostKey($name), $value, $payrules->{$name});
} else {
writeErrorLog('Missing pricer method:', $fieldtype);
}
}
}
return $pricer->getProducts();
}
示例4: _Connect
private function _Connect()
{
// connect to the database
if ($this->db === false) {
if (Config::GetInstance()->sdrive) {
$this->db = new DataAccessSQLite('save_sqlite');
// attach the transaction database if the form uses payments
if (Config::GetInstance()->UsePayments()) {
$dbfile = TransactionLogger::GetInstance()->GetSqliteFile();
if (empty($dbfile) || !file_exists($dbfile)) {
writeErrorLog('Tried to attach transaction log, but file is not defined or doesn\'t exist:', $dbfile);
} else {
$this->transacts = $this->db->AttachTransActions($dbfile);
}
}
} else {
$this->db = new DataAccessMySQL('save_database');
}
}
}
示例5: index_action
/**
* default action of this controller: proxy media data
*/
public function index_action()
{
$url = Request::get('url');
$media_proxy = new MediaProxy();
$config = Config::GetInstance();
$modified_since = NULL;
if (!Seminar_Session::is_current_session_authenticated() || $config->getValue('LOAD_EXTERNAL_MEDIA') != 'proxy') {
throw new AccessDeniedException();
}
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$modified_since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
}
ini_set('default_socket_timeout', 5);
$this->render_nothing();
//stop output buffering started in Trails_Dispatcher::dispatch()
while (ob_get_level()) {
ob_end_clean();
}
try {
$media_proxy->readURL($url, $modified_since);
} catch (MediaProxyException $ex) {
header($ex->getMessage());
}
}
示例6: MergeFormPost
/**
* CoffeeCup Software's Web Form Builder.
*
* Functions to merge posted data into the HTML form definition.
*
*
* @version $Revision: 2456 $
* @author Cees de Gruijter
* @category FB
* @copyright Copyright (c) 2011 CoffeeCup Software, Inc. (http://www.coffeecup.com/)
*/
function MergeFormPost($post = false)
{
if (!$post) {
$post =& $_POST;
}
$dom = new DOMDocument('1.0', 'UTF-8');
if (!$dom->loadHTML(FormPage::GetInstance()->source)) {
writeErrorLog('Failed to parse HTML form.');
return;
}
$errors = FormPage::GetInstance()->GetErrors(true);
$processed_names = array();
$display_max_error = Config::GetInstance()->GetConfig('special', 'maxnumerrors');
if ($display_max_error === false) {
$display_max_error = 1000;
}
// some ridiculously large number
// get all input nodes with a name
$xpath = new DOMXpath($dom);
foreach ($xpath->query('//input[@name]') as $e) {
$tagname = $e->getAttribute('name');
$tagname_stripped = str_replace('[]', '', $tagname);
// checkboxes have a names like "check1[]", but only "check1" is present in $post
if (isset($post[$tagname]) || isset($post[$tagname_stripped])) {
switch ($e->getAttribute('type')) {
case 'radio':
if ($e->getAttribute('value') == $post[$tagname]) {
$e->setAttributeNode(new DOMAttr('checked', 'checked'));
}
break;
case 'checkbox':
if (isset($post[$tagname_stripped]) && is_array($post[$tagname_stripped]) && in_array($e->getAttribute('value'), $post[$tagname_stripped])) {
$e->setAttributeNode(new DOMAttr('checked', 'checked'));
}
break;
case 'file':
break;
default:
$e->setAttributeNode(new DOMAttr('value', $post[$tagname]));
}
}
if (!empty($tagname_stripped) && !in_array($tagname_stripped, $processed_names)) {
if ($display_max_error > 0) {
InserErrorLabel($dom, $e, $errors);
--$display_max_error;
}
$processed_names[] = $tagname_stripped;
}
}
// get all select nodes with a name
foreach ($xpath->query('//select[@name]') as $e) {
// findout if the name is defined as an array[] or as a scalar
$name = $e->getAttribute('name');
$is_array = false;
if (($p = strpos($name, '[]')) !== false) {
$name = substr($name, 0, -2);
$is_array = true;
}
if (isset($post[$name])) {
foreach ($e->getElementsByTagName('option') as $child) {
// set or unset the selected attribute
if ($is_array) {
if (in_array($child->getAttribute('value'), $post[$name]) && !$child->hasAttribute('selected')) {
$child->setAttributeNode(new DOMAttr('selected', 'selected'));
} else {
if ($child->hasAttribute('selected')) {
$child->removeAttribute('selected');
}
}
} else {
if ($child->getAttribute('value') == $post[$name] && !$child->hasAttribute('selected')) {
$child->setAttributeNode(new DOMAttr('selected', 'selected'));
} else {
if ($child->hasAttribute('selected')) {
$child->removeAttribute('selected');
}
}
}
}
}
if (!empty($name) && !in_array($name, $processed_names)) {
InserErrorLabel($dom, $e, $errors);
$processed_names[] = $name;
}
}
// get all textarea nodes with a name
foreach ($xpath->query('//textarea[@name]') as $e) {
$name = $e->getAttribute('name');
if (isset($post[$name])) {
//.........这里部分代码省略.........
示例7: writeErrorLog
// on S-Drive the cart scripts are taken directly from the resources
$buildnum = Config::GetInstance()->GetConfig('resource_version');
if (!$buildnum) {
writeErrorLog('Parameter missing or empty in form.cfg.dat', 'resource_version');
}
$cartpath = CC_HOSTING_RESOURCES . DIRECTORY_SEPARATOR . 'FB' . DIRECTORY_SEPARATOR . $buildnum . DIRECTORY_SEPARATOR . 'fb';
set_include_path(get_include_path() . PATH_SEPARATOR . $cartpath);
// add this constant to the file names to include instead of adding it to the include path
// as a type of name spacing
define('CARTREVISION', 'cartapp');
} else {
// A version number is added to the folder name for forward compatibility. FB increments this
// number if changes are NOT backward compatible. FB must also create the corrresponding
// folder (leaving the old folder for forms made and uploaded with a previous version).
define('CARTREVISION', 'cartapp_v1');
Config::GetInstance()->LoadConfig();
}
// catch warnings with our own error handler to ignore them as appropriate
set_error_handler('myErrorHandler', E_WARNING);
/*** end of global config ***/
/*********** utility functions ************/
// define our auto-loader for classes
function __autoload($class_name)
{
global $scriptpath;
include $scriptpath . '/fbapp/php/' . strtolower($class_name) . '.cls.php';
}
// shows warning more user-friendly
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
// some fopen() may fail because the files are optional
示例8: addContent
/**
* Adding Stud.IP formatted code to the current page of the pdf.
* Remember to call addPage first.
* @param string $content Stud.IP formatted code
*/
public function addContent($content)
{
preg_match_all("#\\[comment(=.*)?\\](.*)\\[/comment\\]#msU", $content, $matches);
if (count($matches[0])) {
$endnote .= "<br><br>" . _("Kommentare") . "<hr>";
for ($i = 0; $i < count($matches[0]); $i++) {
$endnote .= $i + 1 . ") " . htmlReady(substr($matches[1][$i], 1)) . ": " . htmlReady($matches[2][$i]) . "<br>";
}
}
$content = preg_replace("#\\[comment(=.*)?\\](.*)\\[/comment\\]#emsU", '$this->addEndnote("//1", "//2")', $content);
$content = formatReady($content, true, true, true, null);
$content = str_replace("<table", "<table border=\"1\"", $content);
// Since TCPDF cannot handle missing images at all, the content needs
// to be cleaned from those (see tickets #2957, #3329 and #3688)
$content = preg_replace_callback('/<img[^>]+src="(.*?)"[^>]*>/', function ($match) {
$url = $match[1];
// Detect possible html entities in url and remove them
if (strpos($url, '&') !== false) {
$url = html_entity_decode($url);
}
// Handle optional media proxy
if (Config::GetInstance()->LOAD_EXTERNAL_MEDIA) {
$parsed = parse_url($url);
// Detect media proxy
if (strpos($parsed['path'], 'media_proxy') !== false && strpos($parsed['query'], 'url=') !== false) {
// Remove media proxy
parse_str($parsed['query'], $parameters);
$url = $parameters['url'];
}
}
// Fetch headers from url, handle possible redirects
do {
$headers = get_headers($url, true);
list(, $status) = explode(' ', $headers[0]);
$url = $header['Location'] ?: $header['location'] ?: $url;
} while (in_array($status, array(300, 301, 302, 303, 305, 307)));
$status = $status ?: 404;
// Replace image with link on error (and not internal), otherwise return sainitized
// url
return (!is_internal_url($url) || $status == 404) && $status >= 400 ? sprintf('[<a href="%s">%s</a>]', $url, basename($url)) : str_replace($match[1], $url, $match[0]);
}, $content);
$this->writeHTML($content . $endnote);
}
示例9: required
public function required($name, $rules)
{
if (!isset($rules->required) || !$rules->required) {
return true;
}
$error = false;
if ($rules->fieldtype == 'fileupload') {
$name = Config::GetInstance()->GetOriginalPostKey($name);
$error = !isset($_FILES[$name]) || $_FILES[$name]['size'] == 0 || $_FILES[$name]['error'] == UPLOAD_ERR_NO_FILE;
} else {
$tmp = isset($this->input[$name]) ? $this->input[$name] : '';
if (is_array($tmp)) {
$error = empty($tmp);
} else {
$error = empty($tmp) && strlen($tmp) == 0;
}
}
if ($error) {
$this->_errormsg($name, $rules, _T('"%s" is a required field and cannot be empty.', empty($rules->label) ? $name : $rules->label));
}
return !$error;
}
示例10: runUpdate
/**
* Upgrade the application code to the latest version.
* @throws Exception
* @param bool $verify_updatable Whether or not to verify if installation is updatable, defaults to false
* @return array Backup file information
*/
public function runUpdate($file_path, $verify_updatable = false)
{
$app_dir = preg_replace("/\\/_lib\\/controller/", '', $file_path);
// do we have the disk space we need?
$disk_util = new AppUpgraderDiskUtil($app_dir);
$disk_space_megs = $disk_util->getAvailableDiskSpace();
// do we have the perms to do what we need?
$disk_util->validateUpdatePermissions($app_dir);
// do we need to update?
$update_client = new AppUpgraderClient();
$update_info = $update_client->getLatestVersionInfo();
require dirname(__FILE__) . '/../../install/version.php';
$version = Config::GetInstance()->getvalue('THINKUP_VERSION');
if ($update_info['version'] < $version) {
throw new Exception("You are running the latest version of ThinkUp.");
}
if ($verify_updatable == true) {
return array('latest_version' => $update_info['version']);
}
// download zip...
$update_zip_data = $update_client->getLatestVersionZip($update_info['url']);
$update_zip = $disk_util->writeZip($update_zip_data);
$zip = new ZipArchive();
$open_result = $zip->open($update_zip);
if ($open_result !== true) {
unlink($update_zip);
throw new Exception("Unable to extract " . $update_zip . ". ZipArchive::open failed with error code " . $open_result);
}
$num_files = $zip->numFiles;
if ($num_files < 1) {
unlink($update_zip);
throw new Exception("Unable to extract " . $update_zip . ". ZipArchive->numFiles is " . $num_files);
}
$backup_file_info = array();
$backup_file_info = $disk_util->backupInstall();
$disk_util->deleteOldInstall();
$data_path = FileDataManager::getDataPath();
if ($zip->extractTo($data_path) !== true) {
throw new Exception("Unable to extract new files into {$app_dir}: " . $zip->getStatusString());
} else {
$new_version_dir = $data_path . 'thinkup';
$disk_util->recurseCopy($new_version_dir, $app_dir);
// delete install files
$disk_util->deleteDir($new_version_dir);
unlink($update_zip);
}
//replace config file
copy($backup_file_info['config'], "{$app_dir}/config.inc.php");
return $backup_file_info;
}
示例11: _GooglePay
private function _GooglePay()
{
Config::GetInstance()->InitSession();
$payment = new CheckoutController();
$msg = $payment->DoGoogleCheckout();
if (!empty($msg)) {
FormPage::GetInstance()->SetErrors(array(array('field' => 'Form', 'err' => $msg)));
}
}
示例12: _SubstituteAddress
function _SubstituteAddress($name)
{
$matches = array();
$r = preg_match_all('\'\\[([^\\]]+)\\]\'', $name, $matches, PREG_PATTERN_ORDER);
if ($r === false) {
writeErrorLog('Error in regex parsing:', $name);
}
if (!$r) {
return trim($name);
}
foreach ($matches[1] as $match) {
// check if this is an email field and get its value if it is
$match = strtolower($match);
if ((Config::GetInstance()->GetConfig('rules', $match, 'fieldtype') == 'email' || Config::GetInstance()->GetConfig('rules', $match, 'contactList')) && isset(FormPage::GetInstance()->post[$match])) {
$name = str_ireplace('[' . $match . ']', FormPage::GetInstance()->post[$match], $name);
}
}
return trim($name);
}
示例13: auth_doregister
/**
* @return bool|string
*/
function auth_doregister()
{
global $_language_path;
$this->error_msg = "";
// check for direct link to register2.php
if (!$_SESSION['_language'] || $_SESSION['_language'] == "") {
$_SESSION['_language'] = get_accepted_languages();
}
$_language_path = init_i18n($_SESSION['_language']);
$this->auth["uname"] = Request::username('username');
// This provides access for "crcregister.ihtml"
$validator = new email_validation_class();
// Klasse zum Ueberpruefen der Eingaben
$validator->timeout = 10;
// Wie lange warten wir auf eine Antwort des Mailservers?
if (!Seminar_Session::check_ticket(Request::option('login_ticket'))) {
return false;
}
$username = trim(Request::get('username'));
$Vorname = trim(Request::get('Vorname'));
$Nachname = trim(Request::get('Nachname'));
// accept only registered domains if set
$cfg = Config::GetInstance();
$email_restriction = $cfg->getValue('EMAIL_DOMAIN_RESTRICTION');
if ($email_restriction) {
$Email = trim(Request::get('Email')) . '@' . trim(Request::get('emaildomain'));
} else {
$Email = trim(Request::get('Email'));
}
if (!$validator->ValidateUsername($username)) {
$this->error_msg = $this->error_msg . _("Der gewählte Benutzername ist zu kurz!") . "<br>";
return false;
}
// username syntaktisch falsch oder zu kurz
// auf doppelte Vergabe wird weiter unten getestet.
if (!$validator->ValidatePassword(Request::quoted('password'))) {
$this->error_msg = $this->error_msg . _("Das Passwort ist zu kurz!") . "<br>";
return false;
}
if (!$validator->ValidateName($Vorname)) {
$this->error_msg = $this->error_msg . _("Der Vorname fehlt oder ist unsinnig!") . "<br>";
return false;
}
// Vorname nicht korrekt oder fehlend
if (!$validator->ValidateName($Nachname)) {
$this->error_msg = $this->error_msg . _("Der Nachname fehlt oder ist unsinnig!") . "<br>";
return false;
// Nachname nicht korrekt oder fehlend
}
if (!$validator->ValidateEmailAddress($Email)) {
$this->error_msg = $this->error_msg . _("Die E-Mail-Adresse fehlt oder ist falsch geschrieben!") . "<br>";
return false;
}
// E-Mail syntaktisch nicht korrekt oder fehlend
$REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
$Zeit = date("H:i:s, d.m.Y", time());
if (!$validator->ValidateEmailHost($Email)) {
// Mailserver nicht erreichbar, ablehnen
$this->error_msg = $this->error_msg . _("Der Mailserver ist nicht erreichbar, bitte überprüfen Sie, ob Sie E-Mails mit der angegebenen Adresse verschicken und empfangen können!") . "<br>";
return false;
} else {
// Server ereichbar
if (!$validator->ValidateEmailBox($Email)) {
// aber user unbekannt. Mail an abuse!
StudipMail::sendAbuseMessage("Register", "Emailbox unbekannt\n\nUser: {$username}\nEmail: {$Email}\n\nIP: {$REMOTE_ADDR}\nZeit: {$Zeit}\n");
$this->error_msg = $this->error_msg . _("Die angegebene E-Mail-Adresse ist nicht erreichbar, bitte überprüfen Sie Ihre Angaben!") . "<br>";
return false;
} else {
// Alles paletti, jetzt kommen die Checks gegen die Datenbank...
}
}
$check_uname = StudipAuthAbstract::CheckUsername($username);
if ($check_uname['found']) {
// error_log("username schon vorhanden", 0);
$this->error_msg = $this->error_msg . _("Der gewählte Benutzername ist bereits vorhanden!") . "<br>";
return false;
// username schon vorhanden
}
if (count(User::findBySQL("Email LIKE " . DbManager::get()->quote($Email)))) {
$this->error_msg = $this->error_msg . _("Die angegebene E-Mail-Adresse wird bereits von einem anderen Benutzer verwendet. Sie müssen eine andere E-Mail-Adresse angeben!") . "<br>";
return false;
// Email schon vorhanden
}
// alle Checks ok, Benutzer registrieren...
$hasher = UserManagement::getPwdHasher();
$new_user = new User();
$new_user->username = $username;
$new_user->perms = 'user';
$new_user->password = $hasher->HashPassword(Request::get('password'));
$new_user->vorname = $Vorname;
$new_user->nachname = $Nachname;
$new_user->email = $Email;
$new_user->geschlecht = Request::int('geschlecht');
$new_user->title_front = trim(Request::get('title_front', Request::get('title_front_chooser')));
$new_user->title_rear = trim(Request::get('title_rear', Request::get('title_rear_chooser')));
$new_user->auth_plugin = 'standard';
$new_user->store();
//.........这里部分代码省略.........
示例14: garbageCollect
/**
* Remove old files from the media cache.
*/
public function garbageCollect()
{
$db = DBManager::get();
$config = Config::GetInstance();
$limit = (int) $config->getValue('MEDIA_CACHE_MAX_FILES');
$result = $db->query("SELECT id FROM media_cache ORDER BY expires DESC LIMIT {$limit}, 1000");
if ($ids = $result->fetchAll(PDO::FETCH_COLUMN)) {
$this->removeCacheEntries($ids);
}
}
示例15: _makePublicUrl
private function _makePublicUrl($fieldname, $filename)
{
// ensure the publicly visible folder exists
if (!file_exists(Config::GetInstance()->getStorageFolder(4))) {
mkdir(Config::GetInstance()->getStorageFolder(4));
}
// use the rules to find out where the file is
if (Config::GetInstance()->GetRulePropertyByName($fieldname, 'files') == true) {
if (!copy(Config::GetInstance()->getStorageFolder(1) . $filename, Config::GetInstance()->getStorageFolder(4) . $filename)) {
writeErrorLog('MailChimp plugin couldn\'t copy the uploaded file to a public folder', $filename);
$this->setError(_T('Failed to copy the uploaded file %s to a publicly visible folder.', $filename));
return;
}
} else {
// look for it in the uploads table
if (isset($_FILES[$fieldname]) && file_exists($_FILES[$fieldname]['tmp_name'])) {
$filename = SaveUploadAsFile(Config::GetInstance()->getStorageFolder(4), $_FILES[$fieldname]);
if ($filename == false) {
writeErrorLog('MailChimp plugin couldn\'t move the uploaded file to a public folder', $filename);
$this->setError(_T('Failed to move the uploaded file %s to a publicly visible folder.', $filename));
return;
}
}
}
$servername = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
$path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
$path = substr($path, 0, strrpos($path, '/'));
// encode the folders, not the '/'!
$tmp = explode('/', $path);
for ($i = 0; $i < count($tmp); ++$i) {
$tmp[$i] = rawurlencode($tmp[$i]);
}
$path = implode('/', $tmp);
// windows servers may set [HTTPS] => off, linux server usually don't set [HTTPS] at all
if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$protocol = 'https';
} else {
$protocol = 'http';
}
$url = $protocol . '://' . $servername;
// only add the serverport when it differs from the default
if (strpos($servername, ':') === false && ($_SERVER['SERVER_PORT'] != '80' || $protocol != 'http')) {
$url .= ':' . $_SERVER['SERVER_PORT'];
}
return $url . $path . '/' . FormPage::GetInstance()->GetFormName() . CC_FB_STORAGE_FOLDER . CC_FB_PUBLIC_DIRECTORY . $filename;
}