本文整理汇总了PHP中gpFiles::SaveArray方法的典型用法代码示例。如果您正苦于以下问题:PHP gpFiles::SaveArray方法的具体用法?PHP gpFiles::SaveArray怎么用?PHP gpFiles::SaveArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpFiles
的用法示例。
在下文中一共展示了gpFiles::SaveArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveAddonData
function SaveAddonData()
{
$addonData = array();
while (count($this->addonHistory) > 30) {
array_shift($this->addonHistory);
}
$addonData['history'] = $this->addonHistory;
$addonData['reviews'] = $this->addonReviews;
return gpFiles::SaveArray($this->dataFile, 'addonData', $addonData);
}
示例2: saveSettings
private function saveSettings()
{
global $langmessage;
$this->updateSetting('wysiwygDelay');
$this->updateBooleanSetting('wysiwygEnabled');
$this->updateBooleanSetting('markupEscaped');
$this->updateBooleanSetting('breaksEnabled');
$this->updateBooleanSetting('urlsLinked');
if (gpFiles::SaveArray($this->conf, 'settings', $this->settings)) {
message($langmessage['SAVED']);
return;
}
message($langmessage['OOPS']);
$this->settings = $_POST;
}
示例3: SaveConfig
function SaveConfig()
{
global $langmessage;
$format = htmlspecialchars($_POST['date_format']);
if (@date($format)) {
$this->config['date_format'] = $format;
}
$this->config['commenter_website'] = (string) $_POST['commenter_website'];
if (isset($_POST['comment_captcha'])) {
$this->config['comment_captcha'] = true;
} else {
$this->config['comment_captcha'] = false;
}
if (!gpFiles::SaveArray($this->config_file, 'config', $this->config)) {
message($langmessage['OOPS']);
return false;
}
message($langmessage['SAVED']);
return true;
}
示例4: Upgrade_234
/**
* Update the gp_index, gp_titles and menus so that special pages can be renamed
*
*/
function Upgrade_234()
{
global $gp_index, $gp_titles, $gp_menu, $config, $dataDir;
includeFile('tool/gpOutput.php');
$special_indexes = array();
$new_index = array();
$new_titles = array();
foreach ($gp_index as $title => $index) {
$info = $gp_titles[$index];
$type = common::SpecialOrAdmin($title);
if ($type == 'special') {
$special_indexes[$index] = strtolower($title);
$index = strtolower($title);
$info['type'] = 'special';
//some older versions didn't maintain this value well
}
$new_index[$title] = $index;
$new_titles[$index] = $info;
}
$gp_titles = $new_titles;
$gp_index = $new_index;
//update gp_menu
$gp_menu = $this->FixMenu($gp_menu, $special_indexes);
//save pages
if (!admin_tools::SavePagesPHP()) {
return;
}
$config['gpversion'] = '2.3.4';
admin_tools::SaveConfig();
//update alt menus
if (isset($config['menus']) && is_array($config['menus'])) {
foreach ($config['menus'] as $key => $value) {
$menu_file = $dataDir . '/data/_menus/' . $key . '.php';
if (file_exists($menu_file)) {
$menu = gpOutput::GetMenuArray($key);
$menu = $this->FixMenu($menu, $special_indexes);
gpFiles::SaveArray($menu_file, 'menu', $menu);
}
}
}
}
示例5: AddRedirect
function AddRedirect($source, $target)
{
global $dataDir;
$error_data = array();
$datafile = $dataDir . '/data/_site/error_data.php';
if (file_exists($datafile)) {
require $datafile;
}
$changed = false;
//remove redirects from the $target
if (isset($error_data['redirects'][$target])) {
unset($error_data['redirects'][$target]);
$changed = true;
}
//redirect already exists for $source
if (!isset($error_data['redirects'][$source])) {
$error_data['redirects'][$source]['target'] = $target;
$error_data['redirects'][$source]['code'] = '301';
$changed = true;
}
if ($changed) {
gpFiles::SaveArray($datafile, 'error_data', $error_data);
}
}
示例6: SaveConfig
/**
* Save the current configuration
* If successful, reset the lists and titles variables
*/
function SaveConfig()
{
if (!gpFiles::SaveArray($this->config_file, 'config', $this->config)) {
return false;
}
$this->lists = $this->config['lists'];
$this->titles = $this->config['titles'];
if (count($this->config['langs'])) {
$this->langs = $this->config['langs'];
}
return true;
}
示例7: connect
/**
* Connect to ftp server using either Post or saved values
* Connection values will not be kept in $config in case they're being used for a system revert which will replace the config.php file
* Also handle moving ftp connection values from $config to a sep
*
* @return bool true if connected, error message otherwise
*/
function connect()
{
global $config, $dataDir, $langmessage;
$save_values = false;
$args = false;
//get connection values
$connect_args = array();
$connection_file = $dataDir . '/data/_updates/connect.php';
if (file_exists($connection_file)) {
include $connection_file;
}
if (!isset($connection_file['ftp_user']) && isset($config['ftp_user'])) {
$connect_args['ftp_user'] = $config['ftp_user'];
$connect_args['ftp_server'] = $config['ftp_server'];
$connect_args['ftp_pass'] = $config['ftp_pass'];
$connect_args['ftp_root'] = $config['ftp_root'];
$save_values = true;
}
if (isset($_POST['ftp_pass'])) {
$connect_args = $_POST;
$save_values = true;
}
$connect_args = $this->get_connect_vars($connect_args);
$connected = $this->connect_handler($connect_args);
if ($connected !== true) {
return $connected;
}
//get the ftp_root
if (empty($connect_args['ftp_root']) || $save_values) {
$this->ftp_root = $this->get_base_dir();
if (!$this->ftp_root) {
return $langmessage['couldnt_connect'] . ' (Couldn\'t find root)';
}
$connect_args['ftp_root'] = $this->ftp_root;
$save_values = true;
} else {
$this->ftp_root = $connect_args['ftp_root'];
}
//save ftp info
if (!$save_values) {
return $connected;
}
if (!gpFiles::SaveArray($connection_file, 'connect_args', $connect_args)) {
return $connected;
}
/*
* Remove from $config if it's not a safe mode installation
*/
if (!isset($config['useftp']) && isset($config['ftp_user'])) {
unset($config['ftp_user']);
unset($config['ftp_server']);
unset($config['ftp_pass']);
unset($config['ftp_root']);
admin_tools::SaveConfig();
}
return $connected;
}
示例8: Delete
/**
* Delete a blog post
* @return bool
*
*/
public static function Delete()
{
global $langmessage;
$post_id = $_POST['del_id'];
$posts = false;
//post in single file or collection
$post_file = self::PostFilePath($post_id);
if (!file_exists($post_file)) {
$posts = self::GetPostFile($post_id, $post_file);
if ($posts === false) {
message($langmessage['OOPS']);
return false;
}
if (!isset($posts[$post_id])) {
message($langmessage['OOPS']);
return false;
}
unset($posts[$post_id]);
//don't use array_splice here because it will reset the numeric keys
}
//now delete post also from categories:
self::DeletePostFromCategories($post_id);
//reset the index string
$new_index = SimpleBlogCommon::$data['str_index'];
$new_index = preg_replace('#"\\d+>' . $post_id . '"#', '"', $new_index);
preg_match_all('#(?:"\\d+>)([^">]*)#', $new_index, $matches);
SimpleBlogCommon::$data['str_index'] = SimpleBlogCommon::AStrFromArray($matches[1]);
//remove post from other index strings
SimpleBlogCommon::AStrRm('drafts', $post_id);
SimpleBlogCommon::AStrRm('comments_closed', $post_id);
SimpleBlogCommon::AStrRm('titles', $post_id);
SimpleBlogCommon::AStrRm('post_times', $post_id);
if (!SimpleBlogCommon::SaveIndex()) {
message($langmessage['OOPS']);
return false;
}
//save data file or remove the file
if ($posts) {
if (!gpFiles::SaveArray($post_file, 'posts', $posts)) {
message($langmessage['OOPS']);
return false;
}
} elseif (!unlink($post_file)) {
message($langmessage['OOPS']);
return false;
}
//delete the comments
$commentDataFile = self::$data_dir . '/comments/' . $post_id . '.txt';
if (file_exists($commentDataFile)) {
unlink($commentDataFile);
SimpleBlogCommon::ClearCommentCache();
}
SimpleBlogCommon::GenStaticContent();
message($langmessage['file_deleted']);
return true;
}
示例9: SaveData
function SaveData()
{
global $langmessage, $addonPathData;
if (!isset($_REQUEST['index'])) {
return $langmessage['OOPS'] . ' - nothing to save!';
}
$index = $_REQUEST['index'];
$configFile = $addonPathData . '/ec_pagedata.php';
$pagedata = self::LoadData();
if ($_REQUEST) {
if (array_key_exists("datafilter", $_REQUEST)) {
$_REQUEST["datafilter"] = array_diff($_REQUEST["datafilter"], array(''));
$pagedata[$index]['datafilter'] = implode(",", $_REQUEST["datafilter"]);
} else {
$pagedata[$index]['datafilter'] = "";
}
}
$pagedata[$index]['image_url'] = urlencode($_REQUEST['custom_img']);
//save added opts
$temp = new Catalog_Easy();
$temp->getConfig();
if (isset($temp->addon_name) and $temp->addon_name != "") {
foreach ($temp->addon_name as $name) {
$name = str_replace(' ', '_', $name);
if (array_key_exists($name, $_REQUEST)) {
$pagedata[$index][$name] = $_REQUEST[$name];
}
}
}
if (gpFiles::SaveArray($configFile, 'pagedata', $pagedata)) {
return $langmessage['SAVED'];
} else {
return $langmessage['OOPS'];
}
}
示例10: SaveConfig
/**
* Save the current configuration
* If successful, reset the lists and titles variables
*/
public function SaveConfig($refresh_msg = false)
{
global $langmessage;
if (!gpFiles::SaveArray($this->config_file, 'config', $this->config)) {
message($langmessage['OOPS']);
return false;
}
$this->lists = $this->config['lists'];
$this->titles = $this->config['titles'];
if (count($this->config['langs'])) {
$this->langs = $this->config['langs'];
}
if ($refresh_msg) {
message($langmessage['SAVED'] . ' ' . $langmessage['REFRESH']);
} else {
message($langmessage['SAVED']);
}
return true;
}
示例11: SendPassword
function SendPassword()
{
global $langmessage, $dataDir, $gp_mailer;
includeFile('tool/email_mailer.php');
include $dataDir . '/data/_site/users.php';
$username = $_POST['username'];
if (!isset($users[$username])) {
message($langmessage['OOPS']);
return false;
}
$userinfo = $users[$username];
if (empty($userinfo['email'])) {
message($langmessage['no_email_provided']);
return false;
}
$passwordChars = str_repeat('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 3);
$newpass = str_shuffle($passwordChars);
$newpass = substr($newpass, 0, 8);
$users[$username]['newpass'] = common::hash(trim($newpass));
if (!gpFiles::SaveArray($dataDir . '/data/_site/users.php', 'users', $users)) {
message($langmessage['OOPS']);
return false;
}
if (isset($_SERVER['HTTP_HOST'])) {
$server = $_SERVER['HTTP_HOST'];
} else {
$server = $_SERVER['SERVER_NAME'];
}
$link = common::AbsoluteLink('Admin_Main', $langmessage['login']);
$message = sprintf($langmessage['passwordremindertext'], $server, $link, $username, $newpass);
if ($gp_mailer->SendEmail($userinfo['email'], $langmessage['new_password'], $message)) {
list($namepart, $sitepart) = explode('@', $userinfo['email']);
$showemail = substr($namepart, 0, 3) . '...@' . $sitepart;
message(sprintf($langmessage['password_sent'], $username, $showemail));
return true;
}
message($langmessage['OOPS'] . ' (Email not sent)');
return false;
}
示例12: Cron
/**
* Perform regular tasks
* Once an hour only when admin is logged in
*
*/
function Cron()
{
global $dataDir;
$file_stats = $cron_info = array();
$time_file = $dataDir . '/data/_site/cron_info.php';
if (file_exists($time_file)) {
require $time_file;
}
$file_stats += array('modified' => 0);
if (time() - $file_stats['modified'] < 3600) {
return;
}
gpsession::CleanTemp();
gpFiles::SaveArray($time_file, 'cron_info', $cron_info);
}
示例13: SaveThis
function SaveThis()
{
if (!is_array($this->meta_data) || !is_array($this->file_sections)) {
return false;
}
//file count
if (!isset($this->meta_data['file_number'])) {
$this->meta_data['file_number'] = gpFiles::NewFileNumber();
}
return gpFiles::SaveArray($this->file, 'meta_data', $this->meta_data, 'file_sections', $this->file_sections);
}
示例14: SaveSiteData
function SaveSiteData()
{
$check = $this->CheckSum($this->siteData);
if ($check === $this->checksum) {
return true;
}
unset($this->siteData['destination']);
//no longer used
unset($this->siteData['useftp']);
//no longer used
return gpFiles::SaveArray($this->dataFile, 'siteData', $this->siteData);
}
示例15: NewTitle
/**
* Save the content for a new page in /data/_pages/<title>
* @since 1.8a1
*
*/
function NewTitle($title, $section_content = false, $type = 'text')
{
if (empty($title)) {
return false;
}
$file = gpFiles::PageFile($title);
if (!$file) {
return false;
}
$file_sections = array();
$file_sections[0] = array('type' => $type, 'content' => $section_content);
$meta_data = array('file_number' => gpFiles::NewFileNumber(), 'file_type' => $type);
return gpFiles::SaveArray($file, 'meta_data', $meta_data, 'file_sections', $file_sections);
}