public function install($position = 0) { if (!mkdir(PATH_PLUGINS_DB . $this->dir_name, 0777, true)) { return false; } // Template $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $xml .= '<plugin>'; $xml .= '</plugin>'; // Object $new_obj = new NBXML($xml, 0, FALSE, '', FALSE); // Default attributes $new_obj->addAttribute('name', $this->name); $new_obj->addAttribute('author', $this->author); $new_obj->addAttribute('version', $this->version); $new_obj->addAttribute('installed_at', Date::unixstamp()); // Default fields $new_obj->addChild('position', $position); $new_obj->addChild('title', $this->name); foreach ($this->fields as $field => $value) { $new_obj->addChild($field, $value); } if (!$new_obj->asXml(PATH_PLUGINS_DB . $this->dir_name . '/db.xml')) { return false; } return true; }
public function set($args) { if (!$this->set_file($args['id'])) { return false; } $new_obj = new NBXML(PATH_POSTS . $this->files[0], 0, TRUE, '', FALSE); $new_obj->setChild('title', $args['title']); $new_obj->setChild('content', $args['content']); $new_obj->setChild('description', $args['description']); $new_obj->setChild('allow_comments', $args['allow_comments']); $new_obj->setChild('mod_date', Date::unixstamp()); // Quote if (isset($args['quote'])) { $new_obj->setChild('quote', $args['quote']); } // --------------------------------------------------------- // Filename // --------------------------------------------------------- $file = explode('.', $this->files[0]); // Category if (isset($args['id_cat'])) { $file[2] = $args['id_cat']; } // Draft, publish $file[4] = 'NULL'; if (isset($args['mode'])) { if ($args['mode'] == 'draft') { $file[4] = 'draft'; } } // Publish date if (isset($args['unixstamp'])) { $file[0] = $args['unixstamp']; $new_obj->setChild('pub_date', $args['unixstamp']); $file[5] = Date::format_gmt($args['unixstamp'], 'Y'); $file[6] = Date::format_gmt($args['unixstamp'], 'm'); $file[7] = Date::format_gmt($args['unixstamp'], 'd'); $file[8] = Date::format_gmt($args['unixstamp'], 'H'); $file[9] = Date::format_gmt($args['unixstamp'], 'i'); $file[10] = Date::format_gmt($args['unixstamp'], 's'); } // Implode the filename $filename = implode('.', $file); // Delete the old post if ($this->delete(array('id' => $args['id']))) { // Slug $this->slug($args['id'], $args['slug']); // Save config $this->savetofile(); // Save the new post return $new_obj->asXml(PATH_POSTS . $filename); } return false; }
// notifications.xml $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $xml .= '<notifications>'; $xml .= '</notifications>'; $obj = new NBXML($xml, 0, FALSE, '', FALSE); $obj->asXml(FILE_XML_NOTIFICATIONS); // users.xml $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $xml .= '<users>'; $xml .= '</users>'; $obj = new NBXML($xml, 0, FALSE, '', FALSE); $node = $obj->addGodChild('user', array('username' => $_POST['username'])); $node->addChild('id', 0); $node->addChild('session_fail_count', 0); $node->addChild('session_date', 0); $obj->asXml(FILE_XML_USERS); // shadow.php $new_salt = Text::random_text(11); $new_hash = Crypt::get_hash($_POST['password'], $new_salt); $text = '<?php $_USER[0]["uid"] = "0"; $_USER[0]["username"] = "******"; $_USER[0]["password"] = "******"; $_USER[0]["salt"] = "' . $new_salt . '"; $_USER[0]["email"] = "' . $_POST['email'] . '"; ?>'; $file = fopen(FILE_SHADOW, 'w'); fputs($file, $text); fclose($file); // keys.php $key1 = Crypt::get_hash(Text::random_text(11)); $key2 = Crypt::get_hash(Text::random_text(11)); $key3 = Crypt::get_hash(Text::random_text(11)); $text = '<?php $_KEYS[0] = "nibbl' . $key1 . '"; $_KEYS[1] = "eblog' . $key2 . '"; $_KEYS[2] = "rulez' . $key3 . '"; ?>'; $file = fopen(FILE_KEYS, 'w'); fputs($file, $text); fclose($file);
public function set($args) { if (!$this->set_file($args['id'])) { return false; } $new_obj = new NBXML(PATH_PAGES . $this->files[0], 0, TRUE, '', FALSE); $new_obj->setChild('title', $args['title']); $new_obj->setChild('content', $args['content']); $new_obj->setChild('description', $args['description']); $new_obj->setChild('keywords', $args['keywords']); $new_obj->setChild('position', (int) $args['position']); $new_obj->setChild('mod_date', Date::unixstamp()); // --------------------------------------------------------- // Filename // --------------------------------------------------------- $file = explode('.', $this->files[0]); // Draft, publish $file[3] = 'NULL'; if (isset($args['mode'])) { if ($args['mode'] == 'draft') { $file[3] = 'draft'; } } // Publish date if (isset($args['unixstamp'])) { $new_obj->setChild('pub_date', $args['unixstamp']); $file[4] = Date::format_gmt($args['unixstamp'], 'Y'); $file[5] = Date::format_gmt($args['unixstamp'], 'm'); $file[6] = Date::format_gmt($args['unixstamp'], 'd'); $file[7] = Date::format_gmt($args['unixstamp'], 'H'); $file[8] = Date::format_gmt($args['unixstamp'], 'i'); $file[9] = Date::format_gmt($args['unixstamp'], 's'); } // Implode the filename $filename = implode('.', $file); // Delete the old page if ($this->delete(array('id' => $args['id']))) { // Slug $slug = $this->slug_generator($args['slug']); $this->slug_add($args['id'], $slug); // Save config $this->savetofile(); // Save the new page return $new_obj->asXml(PATH_PAGES . $filename); } return false; }
public function add($args) { global $Login; // Template $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $xml .= '<comment>'; $xml .= '</comment>'; // Object $new_obj = new NBXML($xml, 0, FALSE, '', FALSE); // Time - UTC=0 $time_unix = Date::unixstamp(); // Time for Filename $time_filename = Date::format_gmt($time_unix, 'Y.m.d.H.i.s'); // Encrypt the user IP and Email include FILE_KEYS; $user_ip = Crypt::encrypt($args['author_ip'], $_KEYS[1]); $user_email = Crypt::encrypt($args['author_email'], $_KEYS[1]); $new_obj->addChild('author_name', $args['author_name']); $new_obj->addChild('content', $args['content']); $new_obj->addChild('author_email', $user_email); $new_obj->addChild('author_ip', $user_ip); $new_obj->addChild('pub_date', $time_unix); $new_obj->addChild('highlight', '0'); // Last insert ID $new_id = $this->last_insert_id = $this->get_autoinc(); // User ID if ($Login->is_logged()) { $id_user = $Login->get_user_id(); } else { $id_user = '******'; } // Filename for new post $filename = $new_id . '.' . $args['id_post'] . '.' . $id_user . '.' . $args['type'] . '.' . $time_filename . '.xml'; // Save to file if ($new_obj->asXml(PATH_COMMENTS . $filename)) { // Increment the AutoINC $this->set_autoinc(1); // Save config file $this->savetofile(); return $new_id; } return false; }
// Categories // ===================================================== $obj = new NBXML(FILE_XML_CATEGORIES, 0, TRUE, '', FALSE); $position = 0; foreach ($obj->children() as $children) { // Slug $name = utf8_decode((string) $children->attributes()->name); $slug = Text::clean_url($name, '-', $translit_enable); @$children->addAttribute('slug', ''); $children->attributes()->slug = utf8_encode($slug); // Position @$children->addAttribute('position', ''); $children->attributes()->position = utf8_encode($position); $position++; } $obj->asXml(FILE_XML_CATEGORIES); echo Html::p(array('class' => 'pass', 'content' => 'Categories updated...')); // ===================================================== // Uninstall plugins // ===================================================== $plugins = array('last_posts'); foreach ($plugins as $plugin) { $path = PATH_PLUGINS_DB . $plugin; if (file_exists($path . '/db.xml')) { $files = Filesystem::ls($path . '/', '*', '*'); foreach ($files as $file) { unlink($path . '/' . $file); } rmdir($path); echo Html::p(array('class' => 'pass', 'content' => 'Plugin ' . $plugin . ' uninstalled, plugin deprecated.')); }