本文整理汇总了PHP中ipConfig函数的典型用法代码示例。如果您正苦于以下问题:PHP ipConfig函数的具体用法?PHP ipConfig怎么用?PHP ipConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ipConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generatePasswordResetSecret
private static function generatePasswordResetSecret($userId)
{
$secret = md5(ipConfig()->get('sessionName') . uniqid());
$data = array('resetSecret' => $secret, 'resetTime' => time());
ipDb()->update('administrator', $data, array('id' => $userId));
return $secret;
}
示例2: initConfig
protected static function initConfig()
{
ipAddCss('Ip/Internal/Core/assets/admin/admin.css');
ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
ipAddJsVariable('ipTranslationSaving', __('Saving...', 'Ip-admin', false));
ipAddJs('Ip/Internal/Design/assets/optionsBox.js');
ipAddJsVariable('ipModuleDesignConfiguration', Helper::getConfigurationBoxHtml());
if (file_exists(ipThemeFile(Model::INSTALL_DIR . 'Options.js'))) {
ipAddJs(ipThemeUrl(Model::INSTALL_DIR . 'Options.js'));
} elseif (file_exists(ipThemeFile(Model::INSTALL_DIR . 'options.js'))) {
ipAddJs(ipThemeUrl(Model::INSTALL_DIR . 'options.js'));
}
$model = Model::instance();
$theme = $model->getTheme(ipConfig()->theme());
if (!$theme) {
throw new \Ip\Exception("Theme doesn't exist");
}
$options = $theme->getOptionsAsArray();
$fieldNames = array();
foreach ($options as $option) {
if (empty($option['name'])) {
continue;
}
$fieldNames[] = $option['name'];
}
ipAddJsVariable('ipModuleDesignOptionNames', $fieldNames);
}
示例3: render
/**
* Render field
*
* @param string $doctype
* @param $environment
* @return string
*/
public function render($doctype, $environment)
{
return '
<input ' . $this->getAttributesStr($doctype) . ' style="display:none;" class="' . implode(' ', $this->getClasses()) . '" name="' . htmlspecialchars($this->getName()) . '[]" ' . $this->getValidationAttributesStr($doctype) . ' type="hidden" value="" />
<input ' . $this->getAttributesStr($doctype) . ' style="display:none;" class="' . implode(' ', $this->getClasses()) . '" name="' . htmlspecialchars($this->getName()) . '[]" ' . $this->getValidationAttributesStr($doctype) . ' type="hidden" value="' . htmlspecialchars(md5(date('Y-m-d') . ipConfig()->get('sessionName'))) . '" />
';
}
示例4: getConnection
/**
* Get database connection object
*
* @throws \Ip\Exception\Db
* @return \PDO
*/
public function getConnection()
{
if ($this->pdoConnection) {
return $this->pdoConnection;
}
$dbConfig = ipConfig()->get('db');
ipConfig()->set('db', null);
if (empty($dbConfig)) {
throw new \Ip\Exception\Db("Can't connect to database. No connection config found or \\Ip\\Db::disconnect() has been used.");
}
try {
if (array_key_exists('driver', $dbConfig) && $dbConfig['driver'] == 'sqlite') {
$dsn = 'sqlite:' . $dbConfig['database'];
$this->pdoConnection = new \PDO($dsn);
$this->pdoConnection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
} else {
$dsn = 'mysql:host=' . str_replace(':', ';port=', $dbConfig['hostname']);
if (!empty($dbConfig['database'])) {
$dsn .= ';dbname=' . $dbConfig['database'];
}
$this->pdoConnection = new \PDO($dsn, $dbConfig['username'], $dbConfig['password']);
$this->pdoConnection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$dt = new \DateTime();
$offset = $dt->format("P");
$this->pdoConnection->exec("SET time_zone='{$offset}';");
$this->pdoConnection->exec("SET CHARACTER SET " . $dbConfig['charset']);
}
} catch (\PDOException $e) {
throw new \Ip\Exception\Db("Can't connect to database. Stack trace hidden for security reasons");
//PHP traces all details of error including DB password. This could be a disaster on live server. So we hide that data.
}
$this->tablePrefix = $dbConfig['tablePrefix'];
return $this->pdoConnection;
}
示例5: ipRelativeDir
/**
* @ignore
* @param int $callLevel
* @return string
* @throws \Ip\Exception
*/
public static function ipRelativeDir($callLevel = 0)
{
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $callLevel + 1);
if (!isset($backtrace[$callLevel]['file'])) {
throw new \Ip\Exception("Can't find caller");
}
$absoluteFile = $backtrace[$callLevel]['file'];
if (DIRECTORY_SEPARATOR == '\\') {
// Replace windows paths
$absoluteFile = str_replace('\\', '/', $absoluteFile);
}
$overrides = ipConfig()->get('fileOverrides');
if ($overrides) {
foreach ($overrides as $relativePath => $fullPath) {
if (DIRECTORY_SEPARATOR == '\\') {
// Replace windows paths
$fullPath = str_replace('\\', '/', $fullPath);
}
if (strpos($absoluteFile, $fullPath) === 0) {
$relativeFile = substr_replace($absoluteFile, $relativePath, 0, strlen($fullPath));
return substr($relativeFile, 0, strrpos($relativeFile, '/') + 1);
}
}
}
$baseDir = ipConfig()->get('baseDir');
$baseDir = str_replace('\\', '/', $baseDir);
if (strpos($absoluteFile, $baseDir) !== 0) {
throw new \Ip\Exception('Cannot find relative path for file ' . esc($absoluteFile));
}
$relativeFile = substr($absoluteFile, strlen($baseDir) + 1);
return substr($relativeFile, 0, strrpos($relativeFile, '/') + 1);
}
示例6: activate
public function activate()
{
$table = ipTable('comments');
$sql = "\n CREATE TABLE IF NOT EXISTS\n " . $table . "\n (\n\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t `language_id` int(11) NOT NULL,\n\t\t `zone_name` varchar(255) NOT NULL,\n\t\t `user_id` int(11) DEFAULT NULL,\n\t\t `name` varchar(255) NOT NULL,\n\t\t `email` varchar(255) DEFAULT NULL,\n\t\t `link` varchar(255) DEFAULT NULL,\n\t\t `text` text NOT NULL,\n\t\t `ip` varchar(39) NOT NULL,\n\t\t `approved` tinyint(1) NOT NULL,\n\t\t `session_id` varchar(255) NOT NULL,\n\t\t `verification_code` varchar(32) NOT NULL,\n\t\t `active` tinyint(1) DEFAULT 0,\n\t\t PRIMARY KEY (`id`),\n\t\t KEY `user_id` (`user_id`)\n )";
ipDb()->execute($sql);
//add title column if not exist
$checkSql = "\n SELECT\n *\n FROM\n information_schema.COLUMNS\n WHERE\n TABLE_SCHEMA = :database\n AND TABLE_NAME = :table\n AND COLUMN_NAME = :column\n ";
$result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'createdAt'));
if (!$result) {
$sql = "ALTER TABLE {$table} ADD `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;";
ipDb()->execute($sql);
}
$result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'modifiedAt'));
if (!$result) {
$sql = "ALTER TABLE {$table} ADD `modifiedAt` timestamp NULL DEFAULT NULL;";
ipDb()->execute($sql);
}
$result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'lastActiveAt'));
if (!$result) {
$sql = "ALTER TABLE {$table} ADD `lastActiveAt` timestamp NULL DEFAULT NULL;";
ipDb()->execute($sql);
}
$result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'isDeleted'));
if (!$result) {
$sql = "ALTER TABLE {$table} ADD `isDeleted` INT(1) NOT NULL DEFAULT 0;";
ipDb()->execute($sql);
}
$result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'deletedAt'));
if (!$result) {
$sql = "ALTER TABLE {$table} ADD `deletedAt` timestamp NULL DEFAULT NULL;";
ipDb()->execute($sql);
}
$result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'isVerified'));
if (!$result) {
$sql = "ALTER TABLE {$table} ADD `isVerified` timestamp NULL DEFAULT NULL;";
ipDb()->execute($sql);
}
$result = ipDb()->fetchAll($checkSql, array('database' => ipConfig()->database(), 'table' => ipConfig()->tablePrefix() . 'comments', 'column' => 'verifiedAt'));
if (!$result) {
$sql = "ALTER TABLE {$table} ADD `verifiedAt` timestamp NULL DEFAULT NULL;";
ipDb()->execute($sql);
}
try {
ipDb()->execute("DROP INDEX `language_id` ON {$table} ");
} catch (\Exception $e) {
//ignore. We don't care if index doesn't exist. We will create it over again
}
try {
ipDb()->execute("DROP INDEX `zone_name` ON {$table} ");
} catch (\Exception $e) {
//ignore. We don't care if index doesn't exist. We will create it over again
}
try {
ipDb()->execute("DROP INDEX `page_id` ON {$table} ");
} catch (\Exception $e) {
//ignore. We don't care if index doesn't exist. We will create it over again
}
ipDb()->execute("ALTER TABLE {$table} ADD KEY `language_id` (`language_id`) ");
ipDb()->execute("ALTER TABLE {$table} ADD KEY `zone_name` (`zone_name`) ");
}
示例7: index
public function index()
{
ipAddJsVariable('ipTranslationAreYouSure', __('Are you sure?', 'Ip-admin', false));
ipAddJs('Ip/Internal/Core/assets/js/angular.js');
ipAddJs('Ip/Internal/Pages/assets/js/pages.js');
ipAddJs('Ip/Internal/Pages/assets/js/pagesLayout.js');
ipAddJs('Ip/Internal/Pages/assets/js/menuList.js');
ipAddJs('Ip/Internal/Pages/assets/jstree/jstree.min.js');
ipAddJs('Ip/Internal/Pages/assets/js/jquery.pageTree.js');
ipAddJs('Ip/Internal/Pages/assets/js/jquery.pageProperties.js');
ipAddJs('Ip/Internal/Grid/assets/grid.js');
ipAddJs('Ip/Internal/Grid/assets/gridInit.js');
ipAddJs('Ip/Internal/Grid/assets/subgridField.js');
ipAddJsVariable('languageList', Helper::languageList());
ipAddJsVariable('ipPagesLanguagesPermission', ipAdminPermission('Languages'));
$menus = Model::getMenuList();
foreach ($menus as $key => &$menu) {
$default = 'top';
if ($key == 0) {
$default = 'bottom';
}
$menu['defaultPosition'] = Model::getDefaultMenuPagePosition($menu['alias'], false, $default);
$default = 'below';
$menu['defaultPositionWhenSelected'] = Model::getDefaultMenuPagePosition($menu['alias'], true, $default);
}
$menus = ipFilter('ipPagesMenuList', $menus);
ipAddJsVariable('menuList', $menus);
$variables = array('addPageForm' => Helper::addPageForm(), 'addMenuForm' => Helper::addMenuForm(), 'languagesUrl' => ipConfig()->baseUrl() . '?aa=Languages.index');
$layout = ipView('view/layout.php', $variables);
ipResponse()->setLayoutVariable('removeAdminContentWrapper', true);
ipAddJsVariable('listStylePageSize', ipGetOption('Pages.pageListSize', 30));
return $layout->render();
}
示例8: ipBeforeController
public static function ipBeforeController()
{
$request = \Ip\ServiceLocator::request();
$sessionLifetime = ini_get('session.gc_maxlifetime');
if (!$sessionLifetime) {
$sessionLifetime = 120;
}
if ($sessionLifetime > 30) {
$sessionLifetime = $sessionLifetime - 20;
}
ipAddJsVariable('ipSessionRefresh', $sessionLifetime);
if (ipConfig()->isDebugMode()) {
ipAddJs('Ip/Internal/Core/assets/ipCore/jquery.js', null, 10);
// default, global jQuery
ipAddJs('Ip/Internal/Core/assets/ipCore/console.log.js', null, 10);
ipAddJs('Ip/Internal/Core/assets/ipCore/functions.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/jquery.tools.form.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/form/color.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/form/file.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/form/richtext.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/form/repositoryFile.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/form/url.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/form.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/validator.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/widgets.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/ipCore.js');
} else {
ipAddJs('Ip/Internal/Core/assets/ipCore.min.js', null, 10);
}
//Form init
$validatorTranslations = array('Ip-admin' => static::validatorLocalizationData('Ip-admin'), ipContent()->getCurrentLanguage()->getCode() => static::validatorLocalizationData('Ip'));
ipAddJsVariable('ipValidatorTranslations', $validatorTranslations);
if (ipAdminId() || \Ip\Internal\Admin\Model::isLoginPage() || \Ip\Internal\Admin\Model::isPasswordResetPage()) {
if (ipConfig()->isDebugMode()) {
ipAddJs('Ip/Internal/Core/assets/admin/managementMode.js');
ipAddJs('Ip/Internal/Core/assets/admin/functions.js');
ipAddJs('Ip/Internal/Core/assets/admin/validator.js');
ipAddJs('Ip/Internal/Core/assets/admin/bootstrap/bootstrap.js');
ipAddJs('Ip/Internal/Core/assets/admin/bootstrap-switch/bootstrap-switch.js');
} else {
ipAddJs('Ip/Internal/Core/assets/admin.min.js', null, 10);
}
ipAddJs('Ip/Internal/Core/assets/tinymce/pastePreprocess.js');
ipAddJs('Ip/Internal/Core/assets/tinymce/default.js');
}
if (ipAdminId()) {
ipAddJs('Ip/Internal/Core/assets/js/tiny_mce/jquery.tinymce.min.js');
ipAddJs('Ip/Internal/Core/assets/js/tiny_mce/tinymce.min.js');
ipAddJsVariable('ipBrowseLinkModalTemplate', ipView('view/browseLinkModal.php')->render());
ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.full.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.browserplus.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.gears.js');
ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/jquery.plupload.queue/jquery.plupload.queue.js');
if (is_file(ipThemeFile('setup/admin.js'))) {
ipAddJs(ipThemeUrl('setup/admin.js'));
}
ipAddCss('Ip/Internal/Core/assets/admin/admin.css');
}
}
示例9: domain
public static function domain()
{
$domain = ipGetOption('GoogleAnalytics.domain');
if (empty($domain)) {
$domain = parse_url(ipConfig()->baseUrl(), PHP_URL_HOST);
}
return $domain;
}
示例10: getLanguageSelectForm
public static function getLanguageSelectForm()
{
//create form object
$form = new \Ip\Form();
$form->setEnvironment(\Ip\Form::ENVIRONMENT_ADMIN);
$form->addClass('ipsLanguageSelect');
//add text field to form object
$field = new \Ip\Form\Field\Select(array('name' => 'languageCode', 'values' => self::getAvailableLocales()));
$field->setValue(ipConfig()->adminLocale());
$form->addfield($field);
return $form;
}
示例11: getTheme
public function getTheme($name = null, $dir = null, $url = null)
{
if ($name == null) {
$name = ipConfig()->theme();
}
if ($dir == null) {
$dir = ipFile('Theme/');
}
$model = Model::instance();
$theme = $model->getTheme($name, $dir, $url);
return $theme;
}
示例12: index
/**
* Index action adds an item to administration menu
*/
public function index()
{
ipAddJs('view/assets/js/vendor/angular.js', 1);
ipAddJs('view/assets/js/vendor/angular-animate.min.js');
ipAddJs('view/assets/js/vendor/angular-sanitize.min.js');
ipAddJs('view/assets/js/vendor/ngToast.min.js');
ipAddJs('view/assets/js/Controllers/WidgetCtrl.js', 6);
ipAddCss('view/assets/css/ngToast.min.css');
$BasePath = ipConfig()->baseUrl();
ipAddJsVariable('BASEPATH', $BasePath);
$data = array();
return ipView('view/main.php', $data)->render();
}
示例13: ipErrorHandler
public static function ipErrorHandler($errno, $errstr, $errfile, $errline)
{
set_error_handler(__CLASS__ . '::ipSilentErrorHandler');
$type = '';
switch ($errno) {
case E_USER_WARNING:
$type .= 'Warning';
break;
case E_USER_NOTICE:
$type .= 'Notice';
break;
case E_WARNING:
$type .= 'Warning';
break;
case E_NOTICE:
$type .= 'Notice';
break;
case E_CORE_WARNING:
$type .= 'Warning';
break;
case E_COMPILE_WARNING:
$type .= 'Warning';
break;
case E_USER_ERROR:
$type .= 'Error';
break;
case E_ERROR:
$type .= 'Error';
break;
case E_PARSE:
$type .= 'Parse';
break;
case E_CORE_ERROR:
$type .= 'Error';
break;
case E_COMPILE_ERROR:
$type .= 'Error';
break;
default:
$type .= 'Unknown exception';
break;
}
if (class_exists('Ip\\Internal\\Log\\Logger')) {
ipLog()->error($type . ': ' . $errstr . ' in {file}:{line}', array('file' => $errfile, 'line' => $errline));
}
if (ipConfig()->showErrors()) {
echo "{$errstr} in {$errfile}:{$errline}";
}
restore_error_handler();
}
示例14: initManagement
public static function initManagement()
{
$widgets = Service::getAvailableWidgets();
$snippets = array();
foreach ($widgets as $widget) {
$snippetHtml = $widget->adminHtmlSnippet();
if ($snippetHtml != '') {
$snippets[] = $snippetHtml;
}
}
ipAddJsVariable('ipWidgetSnippets', $snippets);
ipAddJsVariable('ipContentInit', Model::initManagementData());
ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
ipAddCss('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.css');
if (ipConfig()->isDebugMode()) {
ipAddJs('Ip/Internal/Content/assets/management/ipContentManagementInit.js');
ipAddJs('Ip/Internal/Content/assets/management/content.js');
ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.contentManagement.js');
ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.widgetbutton.js');
ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.layoutModal.js');
ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.block.js');
ipAddJs('Ip/Internal/Content/assets/management/jquery.ip.widget.js');
ipAddJs('Ip/Internal/Content/assets/management/exampleContent.js');
ipAddJs('Ip/Internal/Content/assets/management/drag.js');
ipAddJs('Ip/Internal/Content/Widget/Columns/assets/Columns.js');
ipAddJs('Ip/Internal/Content/Widget/File/assets/File.js');
ipAddJs('Ip/Internal/Content/Widget/File/assets/jquery.ipWidgetFile.js');
ipAddJs('Ip/Internal/Content/Widget/File/assets/jquery.ipWidgetFileContainer.js');
ipAddJs('Ip/Internal/Content/Widget/Form/assets/Form.js');
ipAddJs('Ip/Internal/Content/Widget/Form/assets/FormContainer.js');
ipAddJs('Ip/Internal/Content/Widget/Form/assets/FormField.js');
ipAddJs('Ip/Internal/Content/Widget/Form/assets/FormOptions.js');
ipAddJs('Ip/Internal/Content/Widget/Html/assets/Html.js');
ipAddJs('Ip/Internal/Content/Widget/Video/assets/Video.js');
ipAddJs('Ip/Internal/Content/Widget/Image/assets/Image.js');
ipAddJs('Ip/Internal/Content/Widget/Gallery/assets/Gallery.js');
ipAddJs('Ip/Internal/Content/Widget/Text/assets/Text.js');
ipAddJs('Ip/Internal/Content/Widget/Heading/assets/Heading.js');
ipAddJs('Ip/Internal/Content/Widget/Heading/assets/HeadingModal.js');
ipAddJs('Ip/Internal/Content/Widget/Map/assets/Map.js');
} else {
ipAddJs('Ip/Internal/Content/assets/management.min.js');
}
ipAddJs('Ip/Internal/Core/assets/js/jquery-tools/jquery.tools.ui.scrollable.js');
ipAddJs('Ip/Internal/Content/assets/jquery.ip.uploadImage.js');
ipAddJsVariable('isMobile', \Ip\Internal\Browser::isMobile());
ipAddJsVariable('ipWidgetLayoutModalTemplate', ipView('view/widgetLayoutModal.php')->render());
}
示例15: generateJavascript
public function generateJavascript()
{
$cacheVersion = $this->getCacheVersion();
$javascriptFiles = $this->getJavascript();
$javascriptFilesSorted = array();
foreach ($javascriptFiles as $level) {
foreach ($level as &$file) {
if ($file['type'] == 'file' && $file['cacheFix']) {
$file['value'] .= (strpos($file['value'], '?') !== false ? '&' : '?') . $cacheVersion;
}
}
$javascriptFilesSorted = array_merge($javascriptFilesSorted, $level);
}
$data = array('ip' => array('baseUrl' => ipConfig()->baseUrl(), 'languageId' => null, 'languageUrl' => '', 'theme' => ipConfig()->get('theme'), 'pageId' => null, 'securityToken' => \Ip\ServiceLocator::application()->getSecurityToken(), 'developmentEnvironment' => ipConfig()->isDevelopmentEnvironment(), 'debugMode' => ipconfig()->isDebugMode(), 'isManagementState' => false, 'isAdminState' => false, 'isAdminNavbarDisabled' => false), 'javascriptVariables' => $this->getJavascriptVariables(), 'javascript' => $javascriptFilesSorted);
return ipView(ipFile('Ip/Internal/Config/view/javascript.php'), $data)->render();
}