public static function run() { spl_autoload_register(['Bootstrap', 'autoload']); putenv('LANG=en_US.UTF-8'); setlocale(LC_CTYPE, 'en_US.UTF-8'); date_default_timezone_set(@date_default_timezone_get()); session_start(); $session = new Session($_SESSION); $request = new Request($_REQUEST); $setup = new Setup($request->query_boolean('refresh', false)); $context = new Context($session, $request, $setup); if ($context->is_api_request()) { (new Api($context))->apply(); } else { if ($context->is_info_request()) { $public_href = $setup->get('PUBLIC_HREF'); $x_head_tags = $context->get_x_head_html(); require __DIR__ . '/pages/info.php'; } else { $public_href = $setup->get('PUBLIC_HREF'); $x_head_tags = $context->get_x_head_html(); $fallback_html = (new Fallback($context))->get_html(); require __DIR__ . '/pages/index.php'; } } }
public function __construct(Setup $setup) { $this->setup = $setup; $this->storageMode = 'flat-file'; $metadata_file = $this->setup->dir . '/.metadata'; $update_metadata = false; // Read exist metadata file if one exists if (file_exists($metadata_file)) { $json_metadata = json_decode(file_get_contents($metadata_file), true); $this->setup->metadata = array_merge($this->setup->metadata, $json_metadata); } // Check if comment thread directory exists if ($setup->mode !== 'api') { if (file_exists(dirname($metadata_file)) and is_writable(dirname($metadata_file))) { // Check whether the page and metadata URLs differ if ($this->setup->metadata['title'] !== $setup->pageTitle) { $this->setup->metadata['title'] = $setup->pageTitle; $update_metadata = true; } // Check whether the page and metadata titles differ if ($this->setup->metadata['url'] !== $setup->pageURL) { $this->setup->metadata['url'] = $setup->pageURL; $update_metadata = true; } // Update metadata if the data has changed if ($update_metadata === true) { if ($this->save_metadata($this->setup->metadata, $metadata_file) === false) { exit($setup->escapeOutput('<b>HashOver</b>: Failed to create metadata file.', 'single')); } } } } }
/** * Given a valid servive URI and a valid string of JSON, * this method communcates with the SiCDS and returns a * list of all unique ID's * * @param string $uri * @param string $json * @return string */ public function InterafceWithSiCDS($uri, $json) { include_once Setup::Modules_Directory() . "/SiSW/ServiceWrapper.php"; $service = new \Swiftriver\Core\Modules\SiSW\ServiceWrapper($uri); $jsonFromService = $service->MakePOSTRequest(array("data" => $json), 5); return $jsonFromService; }
private function __construct() { $settings = Setup::getSettings(); $config = \Doctrine\ORM\Tools\Setup::createXMLMetadataConfiguration([__DIR__ . '/../Mapper', 'Bh/Mapper'], $settings['DevMode']); $conn = array('driver' => 'pdo_mysql', 'user' => $settings['DbUser'], 'password' => $settings['DbPass'], 'dbname' => $settings['DbName']); self::$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config); }
protected function setUp() { include_once dirname(__FILE__) . "/../Setup.php"; $config = Setup::Configuration(); include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/Content.php"; include_once dirname(__FILE__) . "/../TextForUrlParser.php"; }
public static function acceptParameters() { global $argv; if (!isset($argv[1])) { die('Please supply path to document root as first parameter' . PHP_EOL); } if (!file_exists($argv[1]) || !is_dir($argv[1])) { die($argv[1] . ' is not a valid directory' . PHP_EOL); } if (!isset($argv[2])) { die('Please (1 or 0) as second parameter to specify if environment is production' . PHP_EOL); } if (!isset($argv[3])) { die('Please supply path to USER_DATA folder as third parameter' . PHP_EOL); } if (isset($argv[4])) { self::$HOST = $argv[4]; } self::$PRODUCTION = (bool) $argv[2]; self::$DOCUMENT_ROOT = realpath($argv[1]); self::$PROJECT_ROOT = implode('/', array_slice(explode('/', __FILE__), 0, -3)); self::$SITE_PATH = str_replace(self::$DOCUMENT_ROOT, '', self::$PROJECT_ROOT); self::$DATA_PATH = $argv[3]; self::$aDirectories[] = self::$DATA_PATH; }
/** * If you made changes to config, you may call this to persist the changes * back to disk */ protected function saveConfig() { if (!isset($this->config)) { return; } Setup::save(); }
protected function setUp() { include_once dirname(__FILE__) . "/../../../Modules/TagTheNetInterface/Setup.php"; $config = Setup::Configuration(); include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/Content.php"; include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/Tag.php"; include_once dirname(__FILE__) . "/../../../Modules/TagTheNetInterface/ContentFromJSONParser.php"; }
protected function setUp() { include_once dirname(__FILE__) . "/../../../Modules/TagTheNetInterface/Setup.php"; $config = Setup::Configuration(); include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/Content.php"; include_once $config["SwiftriverCoreDirectory"] . "/ObjectModel/LanguageSpecificText.php"; include_once dirname(__FILE__) . "/../../../Modules/TagTheNetInterface/TextForUrlParser.php"; }
/** * @param \Saigon\Conpago\IDbConfig $dbConfig * @param \Saigon\Conpago\IDoctrineConfig $doctrineConfig */ public function __construct(IDBConfig $dbConfig, IDoctrineConfig $doctrineConfig) { $this->dbConfig = $dbConfig; $this->doctrineConfig = $doctrineConfig; $paths = array($this->doctrineConfig->getModelPath()); $this->setDbParams(); $config = Setup::createAnnotationMetadataConfiguration($paths, $this->doctrineConfig->getDevMode()); $this->entityManager = EntityManager::create($this->dbParams, $config); }
/** * Check plugin requirements. * * @return bool True is fails requirements. False otherwise. */ public function maybe_self_deactivate() { if (false === Setup::meets_requirements()) { add_action('admin_init', array('HM\\BackUpWordPress\\Setup', 'self_deactivate')); add_action('admin_notices', array('HM\\BackUpWordPress\\Setup', 'display_admin_notices')); return true; } return false; }
public function database(\Base $f3) { $this->response->data['SUBPART'] = 'settings_database.html'; $cfg = \Config::instance(); if ($f3->get('VERB') == 'POST' && $f3->exists('POST.active_db')) { $type = $f3->get('POST.active_db'); $cfg->{'DB_' . $type} = $f3->get('POST.DB_' . $type); $cfg->ACTIVE_DB = $type; $cfg->save(); \Flash::instance()->addMessage('Config saved', 'success'); $setup = new \Setup(); $setup->install($type); // logout $f3->clear('SESSION.user_id'); } $cfg->copyto('POST'); $f3->set('JIG_format', array('JSON', 'Serialized')); }
public function __construct(Setup $setup) { $this->setup = $setup; $this->storageMode = $setup->databaseType; try { if ($setup->databaseType === 'sqlite') { $this->database = new PDO('sqlite:' . $setup->rootDirectory . '/pages/' . $setup->databaseName . '.sqlite'); } else { $sql_connection = 'host=' . $setup->databaseHost . ';' . 'dbname=' . $setup->databaseName . ';' . 'charset=' . $setup->databaseCharset; $this->database = new PDO($setup->databaseType . ':' . $sql_connection, $setup->databaseUser, $setup->databasePassword); } } catch (PDOException $error) { exit($setup->escapeOutput($error->getMessage(), 'single')); } // Create comment tread table $create = 'CREATE TABLE IF NOT EXISTS \'' . $setup->threadDirectory . '\' ' . '(id TEXT PRIMARY KEY,' . ' name TEXT,' . ' password TEXT,' . ' login_id TEXT,' . ' email TEXT,' . ' encryption TEXT,' . ' website TEXT,' . ' date TEXT,' . ' likes TEXT,' . ' dislikes TEXT,' . ' notifications TEXT,' . ' ipaddr TEXT,' . ' status TEXT,' . ' body TEXT)'; $this->database->exec($create); }
/** * Given a valid servive URI and a valid string of text * this service wraps the TagThe.Net taggin service * * @param string $uri * @param string $json * @return string */ public function InterafceWithService($uri, $text) { $config = Setup::Configuration(); require $config["SwiftriverModulesDirectory"] . "/SwiftriverServiceWrapper/ServiceWrapper.php"; $uri = str_replace("?view=json", "", $uri); $uri = $uri . "?view=json&text=" . $text; $service = new \Swiftriver\Core\Modules\SiSW\ServiceWrapper($uri); $jsonFromService = $service->MakeGETRequest(); return $jsonFromService; }
/** * Get the shared instance for the logger * @return \Log */ public static function GetLogger() { $log = new \Log("this message is ignored, however not supplying one throws an error :o/"); $logger = $log->singleton('file', Setup::Configuration()->CachingDirectory . "/log.log", ' '); if (!self::Configuration()->EnableDebugLogging) { $mask = \Log::UPTO(\PEAR_LOG_INFO); $logger->setMask($mask); } return $logger; }
/** * Get database config. * load it from setup, fall back to legacy config.php constants * * @return array */ public static function getConfig() { $setup = Setup::get(); if (isset($setup['database'])) { $config = $setup['database']->toArray(); } else { // legacy: import from constants $config = array('driver' => APP_SQL_DBTYPE, 'hostname' => APP_SQL_DBHOST, 'database' => APP_SQL_DBNAME, 'username' => APP_SQL_DBUSER, 'password' => APP_SQL_DBPASS, 'port' => APP_SQL_DBPORT, 'table_prefix' => APP_TABLE_PREFIX); // save it back. this will effectively do the migration Setup::save(array('database' => $config)); } return $config; }
public function testParseToRequestJson() { include_once dirname(__FILE__) . "/../../../Setup.php"; include_once dirname(__FILE__) . "/../../../Modules/SiCDSInterface/Parser.php"; include_once dirname(__FILE__) . "/../../../Modules/SiCDSInterface/SiCDSPreProcessingStep.php"; include_once dirname(__FILE__) . "/../../../Modules/SiCDSInterface/ServiceInterface.php"; $item = new ObjectModel\Content(); $item->id = "testId"; $item->difs = array(new ObjectModel\DuplicationIdentificationFieldCollection("names", array(new ObjectModel\DuplicationIdentificationField("first", "homer"), new ObjectModel\DuplicationIdentificationField("second", "simpson")))); $configuration = new MockConfiguration(); $SiCDS = new \Swiftriver\PreProcessingSteps\SiCDSPreProcessingStep(); $SiCDS->Process(array($item), $configuration, Setup::GetLogger()); }
function &init() { static $instance; if (!isset($instance)) { require_once 'base_CLI.class.php'; if (base_CLI::runningFromCLI()) { $interface = 'cli'; } else { $interface = 'web'; } $instance =& Setup::factory($interface); } return $instance; }
/** * Notifies site administrators of the error condition * * @access private * @param mixed $error_msg The error message * @param string $script The script name where the error happened * @param integer $line The line number where the error happened */ function _notify($error_msg = "unknown", $script = "unknown", $line = "unknown") { global $HTTP_SERVER_VARS; $setup = Setup::load(); $notify_list = trim($setup['email_error']['addresses']); if (empty($notify_list)) { return false; } $notify_list = str_replace(';', ',', $notify_list); $notify_list = explode(',', $notify_list); $subject = APP_SITE_NAME . " - Error found! - " . date("m/d/Y H:i:s"); $msg = "Hello,\n\n"; $msg .= "An error was found at " . date("m/d/Y H:i:s") . " (" . time() . ") on line '" . $line . "' of script " . "'{$script}'.\n\n"; $msg .= "The error message passed to us was:\n\n"; if (is_array($error_msg) && count($error_msg) > 1) { $msg .= "'" . $error_msg[0] . "'\n\n"; $msg .= "A more detailed error message follows:\n\n"; $msg .= "'" . $error_msg[1] . "'\n\n"; } else { $msg .= "'{$error_msg}'\n\n"; } @($msg .= "That happened on page '" . $HTTP_SERVER_VARS["PHP_SELF"] . "' from IP Address '" . getenv("REMOTE_ADDR") . "' coming from the page (referrer) '" . getenv("HTTP_REFERER") . "'.\n\n"); @($msg .= "The user agent given was '" . $HTTP_SERVER_VARS['HTTP_USER_AGENT'] . "'.\n\n"); $msg .= "Sincerely yours,\nAutomated Error_Handler Class"; // only try to include the backtrace if we are on PHP 4.3.0 or later if (version_compare(phpversion(), "4.3.0", ">=")) { $msg .= "\n\nA backtrace is available:\n\n"; ob_start(); $backtrace = debug_backtrace(); // remove the two entries related to the error handling stuff itself array_shift($backtrace); array_shift($backtrace); // now we can print it out print_r($backtrace); $contents = ob_get_contents(); $msg .= $contents; ob_end_clean(); } // avoid triggering an email notification about a query that // was bigger than max_allowed_packet (usually 16 megs on 3.23 // client libraries) if (strlen($msg) > 16777216) { return false; } foreach ($notify_list as $notify_email) { $mail = new Mail_API(); $mail->setTextBody($msg); $mail->send($setup['smtp']['from'], $notify_email, $subject); } }
public function __construct() { if (self::$instance === null) { if (!file_exists('/etc/blacklistmonitor.cfg')) { echo 'no config file in /etc/blacklistmonitor.cfg'; } ini_set('error_reporting', E_ALL | E_STRICT | E_NOTICE); $cfg = parse_ini_file('/etc/blacklistmonitor.cfg', false); ini_set('display_errors', $cfg['display_errors']); ini_set('error_log', $cfg['log_path']); self::$settings = $cfg; self::$settings['dns_servers'] = explode(',', $cfg['dns_servers']); self::$connectionArray = array($cfg['db_host'], $cfg['db_username'], $cfg['db_password'], $cfg['db_database']); _Logging::$logFileLocation = $cfg['log_path']; } }
/** * Creates a lock file for the given name. * Returns FALSE if lock couldn't be created (lock already exists) * * @param int $issue_id Issue Id what is being locked * @param string $usr_id User Id who locked the issue * @return bool */ public static function acquire($issue_id, $usr_id) { $setup = Setup::load(); $lock_ttl = $setup['issue_lock']; $expires = time() + $lock_ttl; if (self::isLocked($issue_id)) { $info = self::getInfo($issue_id); // allow lock, if locked by user himself if ($info['usr_id'] != $usr_id) { return false; } } $lockfile = self::getLockFilename($issue_id); $info = array('usr_id' => $usr_id, 'expires' => $expires); $fp = fopen($lockfile, 'w'); flock($fp, LOCK_EX); fwrite($fp, serialize($info)); flock($fp, LOCK_UN); fclose($fp); return true; }
/** * Configue the main template * @param array $contentMain - template content data * @return Template */ public function tpl($contentMain) { // configure main template $this->ssp->pageTitleAdd("User admin"); if (isset($contentMain["title"])) { $this->ssp->pageTitleAdd($contentMain["title"]); } $url = $_SERVER['REQUEST_URI']; $menu = new MenuGen(); $menu->add($this->cfg->userLister . '/filterChange', $this->session->t("Modify Search"), $url === '/sspadmin/filterChange'); if ($this->cfg->adminCheck) { if (!($this->filter->userAdminPending == 1 and $this->filter->creationFinished == 1)) { $menu->add($this->cfg->userLister . '/filterAdminPending', $this->session->t("List Admin Pending"), $url === '/sspadmin/filterAdminPending'); } } $menu->add($this->cfg->userLister . '/filterNormal', $this->session->t("Defualt Listing"), $url === '/sspadmin/filterNormal'); $menu->add('userlisterhelp.php', $this->session->t("Help")); $menu->sv("target=help"); $contentMain["menu"] = $menu->cMenu(); $tpl = $this->ssp->tpl($contentMain); return $tpl; }
/** * Logs the error condition to a specific file and if asked and possible * queue error in mail queue for reporting. * * @param mixed $error_msg The error message * @param string $script The script name where the error happened * @param integer $line The line number where the error happened * @param boolean $notify_error Whether error should be notified by email. */ public static function logError($error_msg = 'unknown', $script = 'unknown', $line = 0, $notify_error = true) { $msg =& self::_createErrorReport($error_msg, $script, $line); if (is_resource(APP_ERROR_LOG)) { fwrite(APP_ERROR_LOG, date('[D M d H:i:s Y] ')); fwrite(APP_ERROR_LOG, $msg); } else { file_put_contents(APP_ERROR_LOG, array(date('[D M d H:i:s Y] '), $msg), FILE_APPEND); } // if there's no database connection, then we cannot possibly queue up the error emails $dbh = DB_Helper::getInstance(); if ($notify_error === false || !$dbh) { return; } $setup = Setup::get(); if (isset($setup['email_error']['status']) && $setup['email_error']['status'] == 'enabled') { $notify_list = trim($setup['email_error']['addresses']); if (empty($notify_list)) { return; } self::_notify($msg, $setup['smtp']['from'], $notify_list); } }
function write_config() { $setup = new Setup(); if ($setup->mysqlConfigExists()) { return 'config already exist'; } $mysql_data['host'] = $_POST['mysql_server']; $mysql_data['user'] = $_POST['user_name']; $mysql_data['passwd'] = $_POST['user_passwd']; $mysql_data['db'] = $_POST['db']; if (!$setup->mysqlConfigIsValid($mysql_data)) { $mysql_admin['user'] = $_POST['admin_name']; $mysql_admin['passwd'] = $_POST['admin_passwd']; $setup->createUser($mysql_data, $mysql_admin); } if ($setup->mysqlConfigIsValid($mysql_data)) { $setup->writeMysqlConfig($mysql_data); } else { return 'invalid config'; } }
<?php /* * This file is part of the Eventum (Issue Tracking System) package. * * @copyright (c) Eventum Team * @license GNU General Public License, version 2 or later (GPL-2+) * * For the full copyright and license information, * please see the COPYING and AUTHORS files * that were distributed with this source code. */ require_once __DIR__ . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/monitor.tpl.html'); Auth::checkAuthentication(); $role_id = Auth::getCurrentRole(); if ($role_id < User::ROLE_REPORTER) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } $tpl->assign('project_list', Project::getAll()); if (!empty($_POST['cat']) && $_POST['cat'] == 'update') { $setup = array('diskcheck' => $_POST['diskcheck'], 'paths' => $_POST['paths'], 'ircbot' => $_POST['ircbot']); $res = Setup::save(array('monitor' => $setup)); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the setup information was saved successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext("ERROR: The system doesn't have the appropriate permissions to create the configuration file in the setup directory (%s). " . 'Please contact your local system administrator and ask for write privileges on the provided path.', APP_CONFIG_PATH), Misc::MSG_NOTE_BOX), -2 => array(ev_gettext("ERROR: The system doesn't have the appropriate permissions to update the configuration file in the setup directory (%s). " . 'Please contact your local system administrator and ask for write privileges on the provided filename.', APP_SETUP_FILE), Misc::MSG_NOTE_BOX))); } $tpl->assign(array('enable_disable', array('enabled' => ev_gettext('Enabled'), 'disabled' => ev_gettext('Disabled')), 'setup' => Setup::get())); $tpl->displayTemplate();
if (!defined('PHPWS_SOURCE_DIR')) { define('PHPWS_SOURCE_DIR', getcwd() . '/'); } if (!defined('PHPWS_SOURCE_HTTP')) { define('PHPWS_SOURCE_HTTP', './'); } require_once 'core/conf/defines.dist.php'; loadTimeZone(); require_once './setup/config.php'; require_once './core/class/Template.php'; require_once './setup/class/Setup.php'; // Core is loaded in Init PHPWS_Core::initCoreClass('Form.php'); PHPWS_Core::initModClass('boost', 'Boost.php'); PHPWS_Core::initModClass('users', 'Current_User.php'); $setup = new Setup(); /** * Starts session, checks if supported on client and server * Program exits here if fails. */ $setup->checkSession(); /** * Check the server for certain settings before getting into the meat * of the installation. Will return if successfully or previously passed. */ $setup->checkServerSettings(); $setup->goToStep(); exit('end of switch'); /** * Returns true if server OS is Windows */
HttpFragmentServiceProvider, UrlGeneratorServiceProvider, DoctrineServiceProvider, SessionServiceProvider, ValidatorServiceProvider }; use Doctrine\ORM\{ Tools\Setup, EntityManager }; $app = new Application(); $app->register(new ServiceControllerServiceProvider()); $app->register(new TwigServiceProvider()); $app->register(new HttpFragmentServiceProvider()); $app->register(new UrlGeneratorServiceProvider()); $app->register(new DoctrineServiceProvider(), array( "db.options" => $dbConnection )); $app->register(new SessionServiceProvider()); $app->register(new ValidatorServiceProvider()); $paths = array(__DIR__."/../src/App/Model"); $isDevMode = false; $config = Setup::createYAMLMetadataConfiguration($paths, $isDevMode, __DIR__.'/cache/'); $config->setAutoGenerateProxyClasses(true); $app['em'] = EntityManager::create($dbConnection, $config); return $app;
public function actionDisableinternet($current_url) { Setup::model()->disableInternetConnection(); Yii::app()->controller->redirect($current_url); }
<?php namespace cvweiss\projectbase; require_once __DIR__ . '/config.php'; if (Config::getInstance()->get('debug', true) === true) { Setup::prepareProject(); } if (php_sapi_name() !== 'cli') { require_once __DIR__ . '/session.php'; require_once __DIR__ . '/twig.php'; require_once __DIR__ . '/router.php'; }
/** public function set_board * Tests and sets the board * * @param string expanded FEN of board * @return void */ public function set_board($xFEN) { call(__METHOD__); call($xFEN); // test the board and make sure all is well if (80 != strlen($xFEN)) { throw new MyException(__METHOD__ . ': Board is not the right size'); } $this->_board = $xFEN; $this->has_sphynx = Setup::has_sphynx($this->_board); call($this->_get_board_ascii()); }