/** * Save a single page * * @param integer $id * @param array $page */ function savePage($page) { global $PIVOTX; // Get a new code, for newly created pages.. if ($page['code'] == "" || $page['code'] == ">") { for ($i = 1; $i < 1000; $i++) { if (!file_exists($PIVOTX['paths']['db_path'] . "pages/page_{$i}.php")) { $page['code'] = $i; $page['uid'] = $i; break; } } } unset($page['oldstatus']); if ($page['title'] == '') { $page['title'] = __('No title..'); } // Edit date is 'now'.. $page['edit_date'] = date("Y-m-d-H-i", getCurrentDate()); saveSerialize($PIVOTX['paths']['db_path'] . "pages/page_" . intval($page['code']) . ".php", $page); // TODO: Update the search index. $this->saveIndex(); // Return the uid of the page we just inserted / updated.. return intval($page['code']); }
private function saveCache() { // Store the version number along with the config. $this->data['version'] = $this->app->getVersion(); if ($this->get('general/caching/config')) { saveSerialize($this->app['resources']->getPath('cache') . '/config_cache.php', $this->data); return; } @unlink($this->app['resources']->getPath('cache') . '/config_cache.php'); }
/** * Creates the file that holds the last trackbacks. Just returns * if we're using SQL. * * @param array $temptrack * @return void */ function generateLastTrackbacks($temptrack) { global $PIVOTX; // If we're using MySQL, there's no need for the last trackbacks file.. if ($PIVOTX['db']->db_type != "flat") { return ""; } $lasttrack_file = $PIVOTX['paths']['db_path'] . 'ser_lasttrack.php'; // if it exists, load it if (file_exists($lasttrack_file)) { $lasttrack = loadSerialize($lasttrack_file, true, true); } else { $lasttrack = array(); } $lasttrack[] = array('title' => $temptrack['title'], 'excerpt' => trimText($temptrack['excerpt'], 250), 'name' => $temptrack['name'], 'url' => $temptrack['url'], 'date' => $temptrack['date'], 'entry_uid' => $temptrack['entry_uid'], 'uid' => makeTrackbackUID($temptrack), 'category' => $PIVOTX['db']->entry['category'], 'ip' => $temptrack['ip']); if (count($lasttrack) > intval($PIVOTX['config']->get('lastcomm_amount_max'))) { array_shift($lasttrack); } saveSerialize($lasttrack_file, $lasttrack); }
/** * Get the TagCosmos. Flat file version. * * Preferably use the cached version, otherwise just make it * on the fly. (and then we store the cached version) * * The $weblogname parameter is used to return tags for a single weblog. * A value of '_all_' returns the tags for all weblogs combined. * If $max is given, it will return at most that many tags, ordered by size. * * Returns an array with the following elements: * 'minvalue' => minimum value of a tag * 'maxvalue' => maximum value of a tag * 'amount' => number of tags * 'tags' => array of the tags. The indices are the tags, the values the number of occurences * * @param integer $max * @param string $weblogname * @return array * @see getTagCosmos * */ function getTagCosmosFlat($max = 0, $weblogname, $match, $exclude = array()) { global $PIVOTX; // If the cached version is fresh enough, we restore that if (file_exists($PIVOTX['paths']['db_path'] . "ser_tags.php") && filectime($PIVOTX['paths']['db_path'] . "ser_tags.php") > time() - 60 * $PIVOTX['config']->get('tag_cache_timeout')) { // Just load it.. $data = loadSerialize($PIVOTX['paths']['db_path'] . "ser_tags.php"); $tagcosmos = $data[$weblogname]; } else { // We have to compute it.. $tagcosmos = array(); $tagcosmos['tags'] = array(); $multi_weblog = false; if (count($PIVOTX['weblogs']->getWeblogNames()) > 1) { $multi_weblog = true; foreach ($PIVOTX['weblogs']->getWeblogNames() as $name) { $tagcosmos[$name] = array(); } $temp_db = new db(FALSE); } $tagdir = dir($PIVOTX['paths']['db_path'] . "tagdata/"); // Read all tags, build the tag index and save it or later. while (false !== ($entry = $tagdir->read())) { if (getExtension($entry) == "tag") { list($tagname) = explode(".", $entry); $tagname = urldecode($tagname); $tagfile = implode("", file($PIVOTX['paths']['db_path'] . "tagdata/" . $entry)); $tagfile = explode(",", $tagfile); if (!in_array($tagname, $exclude)) { if ($tagname != "") { $tagcosmos['_all_']['tags'][$tagname] = count($tagfile); if ($multi_weblog) { foreach ($tagfile as $entrycode) { $temp_entry = $temp_db->read_entry($entrycode); $cat_weblogs = $PIVOTX['weblogs']->getWeblogsWithCat($temp_entry['category']); foreach ($cat_weblogs as $cat_weblog) { $tagcosmos[$cat_weblog]['tags'][$tagname]++; } } } } } } } $tagdir->close(); saveSerialize($PIVOTX['paths']['db_path'] . "ser_tags.php", $tagcosmos); $tagcosmos = $tagcosmos[$weblogname]; } if (isset($tagcosmos['tags'])) { $tagcosmos['amount'] = count($tagcosmos['tags']); } else { $tagcosmos['amount'] = 0; $tagcosmos['tags'] = array(); } if ($tagcosmos['amount'] > 0) { // if $max is given, we need to filter out the smaller tags, until the required size is reached. if ($max != 0 && $max < count($tagcosmos['tags'])) { arsort($tagcosmos['tags']); $tagcosmos['tags'] = array_slice($tagcosmos['tags'], 0, $max); } } return $tagcosmos; }
/** * Process a comment for moderation. Action 1 = allow, * action 2 = delete. * * When allowed, the comment is changed in the entry, so it is displayed, and it * is added to the latest_comments. Whene deleted it'll be deleted from the entry * * @param array $comm * @param integer $action */ function moderateProcessComment($comm, $action) { global $PIVOTX; if (!isset($db)) { $db = new db(); } if ($action == 1) { // Allow comment. // First, get the entry.. $entry = $PIVOTX['db']->read_entry($comm['entry_uid']); $send_notification = false; foreach ($entry['comments'] as $key => $loopcomm) { if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) { // fix the entry.. $entry['comments'][$key]['moderate'] = 0; // Store the comment that's approved. We need it a bit later on to send the notifications $modcomment = $entry['comments'][$key]; // Save it.. $PIVOTX['db']->set_entry($entry); $PIVOTX['db']->save_entry(); // Remove the compiled/parsed pages from the cache. if ($PIVOTX['config']->get('smarty_cache')) { $PIVOTX['template']->clear_cache(); } $lastcommfile = $PIVOTX['paths']['db_path'] . "ser_lastcomm.php"; // Add it to the 'latest comments'.. if (file_exists($lastcommfile)) { $lastcomm = loadSerialize($lastcommfile, true, true); } else { $lastcomm = array(); } $lastcomm[] = $comm; saveSerialize($lastcommfile, $lastcomm); $send_notification = true; } } if ($send_notification && $PIVOTX['config']->get('dont_send_mail_notification') != 1) { // Handle the users that want to be notified via email.. sendMailNotification('comment', array($entry, $modcomment)); } } else { if ($action == 2) { // Delete comment. // First, get the entry.. $entry = $PIVOTX['db']->read_entry($comm['entry_uid']); foreach ($entry['comments'] as $key => $loopcomm) { if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) { // fix the entry.. unset($entry['comments'][$key]); // Save it.. $PIVOTX['db']->set_entry($entry); $PIVOTX['db']->save_entry(); } } // Remove the compiled/parsed pages from the cache. if ($PIVOTX['config']->get('smarty_cache')) { $PIVOTX['template']->clear_cache(); } } } }
function write_date_index() { global $PIVOTX; asort($this->date_index); debug("Save date index (" . count($this->date_index) . "," . count($this->cat_index) . ")"); saveSerialize($PIVOTX['paths']['db_path'] . "ser-dates.php", $this->date_index); saveSerialize($PIVOTX['paths']['db_path'] . "ser-cats.php", $this->cat_index); saveSerialize($PIVOTX['paths']['db_path'] . "ser-uris.php", $this->uri_index); }
function save() { global $PIVOTX; // Trim the event log, if it's too long. if (count($this->data) > $this->maxevents + 10) { $this->data = array_slice($this->data, -$this->maxevents); } saveSerialize($PIVOTX['paths']['db_path'] . $this->filename, $this->data); }
function saveUser($user) { global $PIVOTX; $name_md5 = strtolower(md5(strtolower($user['name']))); if (saveSerialize($PIVOTX['paths']['db_path'] . 'users/' . $name_md5 . '.php', $user)) { // echo "User stored!<br /><br />"; } else { echo "Could not store user!!<br /><br />"; } }
private function saveCache() { // Store the version number along with the config. $this->data['version'] = $this->app->getVersion(); if ($this->get('general/caching/config')) { saveSerialize(BOLT_CACHE_DIR . '/config_cache.php', $this->data); return; } @unlink(BOLT_CACHE_DIR . '/config_cache.php'); }
private function saveCache() { if ($this->get('general/caching/config')) { saveSerialize(__DIR__ . "/../../cache/config_cache.php", $this->data); } else { @unlink(__DIR__ . "/../../cache/config_cache.php"); } }
/** * Save keys */ protected function save_keys() { global $PIVOTX; saveSerialize($PIVOTX['paths']['db_path'] . 'ser_spamkiller.php', self::$keys); if (count(self::$keys) >= self::MAX_KEYS) { $this->logpost('Maximum number of keys are stored (' . count(self::$keys) . ')'); } }
private function saveCache() { if ($this->get('general/caching/config')) { saveSerialize(__DIR__ . '/../../cache/config_cache.php', $this->data); return; } @unlink(__DIR__ . '/../../cache/config_cache.php'); }