本文整理汇总了PHP中system::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP system::getInstance方法的具体用法?PHP system::getInstance怎么用?PHP system::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类system
的用法示例。
在下文中一共展示了system::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make
/**
* Create full copy of www dir and mysql database
*/
public function make()
{
system::getInstance()->createPrivateDirectory(root . '/backup/');
$file_mainname = system::getInstance()->toDate(time(), 'd') . "_backup";
$this->zipCreate(root, root . "/backup/" . $file_mainname . "_www.zip");
$this->mysqlDump("/backup/" . $file_mainname . "_sql.sql.gz");
}
示例2: init
public function init()
{
if (database::getInstance()->isDown() || !property::getInstance()->get('collect_statistic')) {
return;
}
$realip = system::getInstance()->getRealIp();
$visittime = time();
$browser = self::user_browser($_SERVER['HTTP_USER_AGENT']);
$os = self::user_os($_SERVER['HTTP_USER_AGENT']);
$cookie = $_COOKIE['source'] ?: '';
$userid = user::getInstance()->get('id');
if ($userid == null) {
$userid = 0;
}
if ($cookie == null) {
$settime = $visittime + 365 * 24 * 60 * 60;
setcookie('source', system::getInstance()->md5random(), $settime, '/');
$cookie = '';
}
$referer = $_SERVER['HTTP_REFERER'] ?: '';
$path = $_SERVER['REQUEST_URI'] ?: '';
$query = "INSERT INTO " . property::getInstance()->get('db_prefix') . "_statistic (ip, cookie, browser, os, time, referer, path, reg_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = database::getInstance()->con()->prepare($query);
$stmt->bindParam(1, $realip, \PDO::PARAM_STR);
$stmt->bindParam(2, $cookie, \PDO::PARAM_STR, 32);
$stmt->bindParam(3, $browser, \PDO::PARAM_STR);
$stmt->bindParam(4, $os, \PDO::PARAM_STR);
$stmt->bindParam(5, $visittime, \PDO::PARAM_INT);
$stmt->bindParam(6, $referer, \PDO::PARAM_STR);
$stmt->bindParam(7, $path, \PDO::PARAM_STR);
$stmt->bindParam(8, $userid, \PDO::PARAM_INT);
$stmt->execute();
}
示例3: log
/**
* Log message to system information. Types: logger::LEVEL_ERR, logger::LEVEL_WARN, logger::LEVEL_NOTIFY
* @param string $type
* @param string $message
*/
public function log($type, $message)
{
system::getInstance()->createPrivateDirectory(root . '/log/');
$iface = defined('loader') ? loader : 'unknown';
$compile_message = "=>[" . $iface . ":" . $type . "](" . system::getInstance()->toDate(time(), 's') . "): " . $message . "\n";
@file_put_contents(root . "/log/" . system::getInstance()->toDate(time(), 'd') . ".log", $compile_message, FILE_APPEND | LOCK_EX);
}
示例4: init
/**
* Check if user is permament banned in database and display ban.tpl theme
*/
public function init()
{
$ip = system::getInstance()->getRealIp();
$time = time();
$userid = user::getInstance()->get('id');
if ($userid > 0) {
$stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE (user_id = ? or ip = ?) AND (express > ? OR express = 0)");
$stmt->bindParam(1, $userid, \PDO::PARAM_INT);
$stmt->bindParam(2, $ip, \PDO::PARAM_STR);
$stmt->bindParam(3, $time, \PDO::PARAM_INT);
$stmt->execute();
} else {
$stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE ip = ? AND (express > ? OR express = 0)");
$stmt->bindParam(1, $ip, \PDO::PARAM_STR);
$stmt->bindParam(2, $time, \PDO::PARAM_INT);
$stmt->execute();
}
$rowFetch = $stmt->fetch();
$count = $rowFetch[0];
if ($count > 0) {
// block founded in db
$content = template::getInstance()->twigRender('ban.tpl', array('local' => array('admin_email' => property::getInstance()->get('mail_from'))));
template::getInstance()->justPrint($content);
}
}
示例5: buildToken
/**
* Get token for csrf prevention. Token is 32...128 chars. Token automatic add in cookie as 'csrf_token' and in template as {{ system.csrf_token }}
* @return string
*/
public function buildToken()
{
$now = time();
if (!isset($_SESSION['csrf_token']) || $_SESSION['csrf_token']['time'] == null || $_SESSION['csrf_token']['data'] == null || $now - $_SESSION['csrf_token']['time'] > self::SESSION_TIME) {
$_SESSION['csrf_token'] = array('time' => $now, 'data' => system::getInstance()->randomSecureString128());
}
template::getInstance()->set(template::TYPE_SYSTEM, 'csrf_token', $_SESSION['csrf_token']['data']);
}
示例6: read
/**
* Read ini structure data and return as associative array or FALSE if file not founded
* @param string $file
* @param bool $sections
* @return array|bool
*/
public function read($file, $sections = false)
{
if (!system::getInstance()->prefixEquals($file, root)) {
$file = root . $file;
}
if (!file_exists($file)) {
return false;
}
return parse_ini_file($file, $sections);
}
示例7: compile
public function compile()
{
template::getInstance()->set(template::TYPE_META, 'description', system::getInstance()->altimplode('. ', $this->metadata['description']));
template::getInstance()->set(template::TYPE_META, 'keywords', system::getInstance()->altimplode('. ', $this->metadata['keywords']));
template::getInstance()->set(template::TYPE_META, 'global_title', $this->metadata['global_title']);
if (property::getInstance()->get('multi_title')) {
template::getInstance()->set(template::TYPE_META, 'title', system::getInstance()->altimplode(" - ", array_reverse($this->metadata['title'])));
} else {
template::getInstance()->set(template::TYPE_META, 'title', array_pop($this->metadata['title']));
}
template::getInstance()->set(template::TYPE_META, 'generator', 'FFCMS engine: ffcms.ru. Version: ' . version);
}
示例8: make
public function make()
{
$iface = system::getInstance()->get('iface');
$object = system::getInstance()->get('object');
$cron = system::getInstance()->get('cron');
if ($cron != null) {
return $this->cronInit();
}
$link = $this->call($iface, $object);
if (method_exists($link, 'make')) {
$link->make();
}
return null;
}
示例9: init
public function init()
{
global $config;
$this->set('ds', '/');
// directory separator, but now in all O.S. supported "/" win,nix
$this->set('slash', '/');
// web slash, mb someone making amazing ;D
$this->set('admin_tpl', 'admin');
$this->set('install_tpl', 'install');
$this->set('collect_statistic', true);
$this->set('upload_img_max_size', 500);
$this->set('tpl_dir', 'templates');
$this->set('user_friendly_url', true);
$this->set('use_multi_language', true);
$this->set('maintenance', false);
// upd
$this->set('upload_other_max_size', 3000);
$this->set('upload_allowed_ext', '.doc;.docx;.rtf;.pdf;.txt;');
if (is_array($config)) {
foreach ($config as $key => $value) {
// allow multi-url support
if ($key == 'url') {
$this->set('source_url', $value);
if (system::getInstance()->contains(';', $value)) {
// contains ; spliter in urls
$adr_array = system::getInstance()->altexplode(';', $value);
$user_address = system::getInstance()->getProtocol() . '://';
$user_address .= $_SERVER['HTTP_HOST'];
foreach ($adr_array as $address) {
if (system::getInstance()->prefixEquals($address, $user_address)) {
$this->set('url', $address);
break;
}
}
if ($this->get('url') == null) {
// if url still null - set first of know
$this->set('url', $adr_array[0]);
}
} else {
$this->set($key, $value);
}
} else {
$this->set($key, $value);
}
}
}
$this->set('yandex_translate_key', 'trnsl.1.1.20140923T120415Z.11ea02784e7b7447.158c20fac47143a5ccda5fc8a8ca81182669c80f');
}
示例10: init
public function init()
{
if (!file_exists(root . '/language/')) {
return;
}
$scan = scandir(root . '/language/');
$found_language = array();
// get all available
foreach ($scan as $file) {
if (!system::getInstance()->prefixEquals($file, '.') && system::getInstance()->suffixEquals($file, '.ini')) {
$found_language = system::getInstance()->arrayAdd(strstr($file, '.', true), $found_language);
}
}
// check if exists
foreach ($found_language as $check_language) {
if (file_exists(root . '/language/' . $check_language . '.ini')) {
$this->available[] = $check_language;
}
}
}
示例11: getConfig
/**
* Get configuration value of extension by config name, extension name and extension type.
* @param string $name
* @param string $ext_dir
* @param string $object
* @param string $var_type
* @return bool|int|string
*/
public function getConfig($name, $ext_dir, $object, $var_type = null)
{
$configs = unserialize($this->extconfigs[$object][$ext_dir]['configs']);
if (in_array($var_type, array('bool', 'boolean', 'bol'))) {
return $configs[$name] == "0" ? false : true;
} elseif (in_array($var_type, array('int', 'integer'))) {
return system::getInstance()->toInt($configs[$name]);
} elseif (in_array($var_type, array('float', 'double'))) {
return (double) $configs[$name];
}
return $configs[$name];
}
示例12: getAllPermissions
/**
* Return array of all available permissions in datatable user_access_level. Ex: array['global/read', 'global/write', 'global/owner' ... , 'etc']
* @return array
*/
public function getAllPermissions()
{
$this->loadAllData();
// get data from db
foreach ($this->full_access_data as $row) {
// even row
$permission_array = system::getInstance()->altexplode(';', $row['permissions']);
// row permissions
foreach ($permission_array as $permission) {
// single permission
if (!in_array($permission, $this->all_permissions) && !system::getInstance()->prefixEquals($permission, 'admin/')) {
$this->all_permissions[] = $permission;
// add
}
}
}
return $this->all_permissions;
}
示例13: viewInstall
private function viewInstall()
{
$params = array();
if (file_exists(root . '/install/.lock')) {
$params['notify']['prepare']['lock'] = true;
}
if (file_exists(root . '/config.php') && !is_writable(root . '/config.php')) {
$params['notify']['prepare']['cfg_write'] = true;
}
if (!is_writable(root . '/install/')) {
$params['notify']['prepare']['inst_write'] = true;
}
if (!file_exists(root . '/install/sql/install.sql')) {
$params['notify']['prepare']['sql_notfound'] = true;
}
$timezone_array = timezone::getInstance()->getZoneUTC();
template::getInstance()->set(template::TYPE_SYSTEM, 'timezones', $timezone_array);
if (sizeof($params['notify']) == 0) {
if (system::getInstance()->post('submit')) {
$testCon = null;
try {
$testCon = @new \PDO("mysql:host=" . system::getInstance()->post('config:db_host') . ";dbname=" . system::getInstance()->post('config:db_name') . "", system::getInstance()->post('config:db_user'), system::getInstance()->post('config:db_pass'));
} catch (\PDOException $exception) {
$params['notify']['process']['db_conn_miss'] = true;
}
if ($testCon != null) {
$reg_login = system::getInstance()->post('admin:login');
$reg_email = system::getInstance()->post('admin:email');
$reg_pass = system::getInstance()->post('admin:pass');
$reg_repass = system::getInstance()->post('admin:repass');
if (!filter_var($reg_email, FILTER_VALIDATE_EMAIL)) {
$params['notify']['process']['reg_email_wrong'] = true;
}
if (!system::getInstance()->validPasswordLength($reg_pass)) {
$params['notify']['process']['reg_pass_wrong'] = true;
}
if (system::getInstance()->length($reg_login) < 3 || system::getInstance()->length($reg_login) > 64) {
$params['notify']['process']['reg_login_wrong'] = true;
}
if ($reg_pass != $reg_repass) {
$params['notify']['process']['reg_repass_nomatch'] = true;
}
if (sizeof($params['notify']) == 0) {
$configs_data = '<?php' . "\n";
foreach (system::getInstance()->post(null) as $var_name => $var_value) {
if (system::getInstance()->prefixEquals($var_name, 'config:')) {
$var_name = substr($var_name, strlen('config:'));
$var_name = system::getInstance()->nohtml($var_name);
if ($var_name === 'seo_title') {
foreach (language::getInstance()->getAvailable() as $clang) {
$configs_data .= '$config[\'' . $var_name . '\'][\'' . $clang . '\'] = "' . system::getInstance()->nohtml($var_value[$clang]) . '";' . "\n";
}
} else {
$configs_data .= '$config[\'' . $var_name . '\'] = "' . system::getInstance()->nohtml($var_value) . '"' . ";\n";
}
}
}
$random_password_salt = system::getInstance()->randomString(rand(12, 16));
$configs_data .= '$config[\'tpl_dir\'] = "templates";
$config[\'tpl_name\'] = "default";
$config[\'debug\'] = true;
$config[\'multi_title\'] = false;
$config[\'cache_interval\'] = "120";
$config[\'token_time\'] = "86400";
$config[\'user_friendly_url\'] = false;
$config[\'mail_from\'] = "admin@example.com";
$config[\'mail_ownername\'] = "Site Admin";
$config[\'mail_smtp_use\'] = false;
$config[\'mail_smtp_host\'] = "smtp.yandex.ru";
$config[\'mail_smtp_port\'] = "25";
$config[\'mail_smtp_auth\'] = true;
$config[\'mail_smtp_login\'] = "admin@example.com";
$config[\'mail_smtp_password\'] = "madness";
$config[\'password_salt\'] = "' . $random_password_salt . '";
';
$configs_data .= '?>';
file_put_contents(root . '/install/.lock', 'Install success');
file_put_contents(root . '/config.php', $configs_data);
$prefix = system::getInstance()->post('config:db_prefix');
if (!system::getInstance()->isLatinOrNumeric($prefix)) {
$prefix = "ffcms";
}
$query_dump = str_replace('{$db_prefix}', $prefix, file_get_contents(root . '/install/sql/install.sql'));
$testCon->exec($query_dump);
$md5_doublehash = system::getInstance()->doublemd5($reg_pass, $random_password_salt);
$stmt = $testCon->prepare("INSERT INTO " . $prefix . "_user (`login`, `email`, `nick`, `pass`, `access_level`) VALUES(?, ?, 'admin', ?, '3')");
$stmt->bindParam(1, $reg_login, \PDO::PARAM_STR);
$stmt->bindParam(2, $reg_email, \PDO::PARAM_STR);
$stmt->bindParam(3, $md5_doublehash, \PDO::PARAM_STR, 32);
$stmt->execute();
$user_id = $testCon->lastInsertId();
$stmt = null;
$stmt = $testCon->prepare("INSERT INTO " . $prefix . "_user_custom(`id`) VALUES (?)");
$stmt->bindParam(1, $user_id, \PDO::PARAM_INT);
$stmt->execute();
$stmt = null;
$testCon = null;
$params['notify']['success'] = true;
}
}
//.........这里部分代码省略.........
示例14: store
/**
* Save data in cache file storage
* @param string $name
* @param string $data
*/
public function store($name, $data)
{
$name = md5($name);
system::getInstance()->putFile($data, root . self::CACHE_DIR . $name . '.cache');
}
示例15: set
/**
* Add to rendering variable with value. If add is true value not be replaced, added.
* @param $type ['content', 'language', 'system']
* @param string $variable
* @param string|array $value
* @param bool $add
*/
public function set($type, $variable, $value, $add = false)
{
if (system::getInstance()->length($variable) < 1 || !is_array($value) && system::getInstance()->length($value) < 1 || is_array($value) && $add) {
return;
}
$this->variables[$type][$variable] = $add ? $this->variables[$type][$variable] . $value : $value;
}