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 add($args) { // Template $template = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $template .= '<post>'; $template .= '</post>'; // New object $new_obj = new NBXML($template, 0, FALSE, '', FALSE); // Time in UTC-0 $time_unix = Date::unixstamp(); // Default elements $new_obj->addChild('type', $args['type']); $new_obj->addChild('title', $args['title']); $new_obj->addChild('content', preg_replace("/<a(.*?)>/", "<a\$1 target=\"_blank\" rel=\"nofollow\">", $args['content'])); $new_obj->addChild('description', $args['description']); $new_obj->addChild('allow_comments', $args['allow_comments']); $new_obj->addChild('pub_date', $time_unix); $new_obj->addChild('mod_date', '0'); $new_obj->addChild('visits', '0'); // Video post if (isset($args['video'])) { $new_obj->addChild('video', $args['video']); } elseif (isset($args['quote'])) { $new_obj->addChild('quote', $args['quote']); } // Get the last post id $new_id = $this->last_insert_id = $this->get_autoinc(); // Slug $this->slug($new_id, $args['slug']); // Draft, publish $mode = 'NULL'; if (isset($args['mode'])) { if ($args['mode'] == 'draft') { $mode = 'draft'; } } // Time for filename $time_filename = Date::format_gmt($time_unix, 'Y.m.d.H.i.s'); // Filename for the new post $filename = $time_unix . '.' . $new_id . '.' . $args['id_cat'] . '.' . $args['id_user'] . '.' . $mode . '.' . $time_filename . '.xml'; // Save to file if ($new_obj->asXml(PATH_POSTS . $filename)) { // Set the next post id $this->set_autoinc(1); // Save config $this->savetofile(); return $new_id; } return false; }
public function add($args) { // Template $template = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $template .= '<page>'; $template .= '</page>'; // New object $new_obj = new NBXML($template, 0, FALSE, '', FALSE); // Time in UTC-0 $time_unix = Date::unixstamp(); // Default elements $new_obj->addChild('title', $args['title']); $new_obj->addChild('content', $args['content']); $new_obj->addChild('description', $args['description']); $new_obj->addChild('keywords', $args['keywords']); $new_obj->addChild('position', (int) $args['position']); $new_obj->addChild('pub_date', $time_unix); $new_obj->addChild('mod_date', '0'); $new_obj->addChild('visits', '0'); // Get the last page id $new_id = $this->last_insert_id = $this->get_autoinc(); // Slug $slug = $this->slug_generator($args['slug']); $this->slug_add($new_id, $slug); // Draft, publish $mode = 'NULL'; if (isset($args['mode'])) { if ($args['mode'] == 'draft') { $mode = 'draft'; } } // Time for filename $time_filename = Date::format_gmt($time_unix, 'Y.m.d.H.i.s'); // Filename for the new page $filename = $new_id . '.NULL.NULL.' . $mode . '.' . $time_filename . '.xml'; // Save to file if ($new_obj->asXml(PATH_PAGES . $filename)) { // Set the next page id $this->set_autoinc(1); // Save config $this->savetofile(); return $new_id; } 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; }
$node->addAttribute('position', 3); $obj->asXml(FILE_XML_CATEGORIES); // tags.xml $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; $xml .= '<tags autoinc="0">'; $xml .= '<list></list>'; $xml .= '<links></links>'; $xml .= '</tags>'; $obj = new NBXML($xml, 0, FALSE, '', FALSE); $obj->asXml(FILE_XML_TAGS); // comments.xml $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; $xml .= '<comments autoinc="0">'; $xml .= '</comments>'; $obj = new NBXML($xml, 0, FALSE, '', FALSE); $obj->addChild('moderate', 1); $obj->addChild('sanitize', 1); $obj->addChild('monitor_enable', 0); $obj->addChild('monitor_api_key', ''); $obj->addChild('monitor_spam_control', '0.75'); $obj->addChild('monitor_auto_delete', 0); $obj->addChild('disqus_shortname', ''); $obj->addChild('facebook_appid', ''); $obj->asXml(FILE_XML_COMMENTS); // posts.xml $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; $xml .= '<post autoinc="1">'; $xml .= '<friendly></friendly>'; $xml .= '</post>'; $obj = new NBXML($xml, 0, FALSE, '', FALSE); $obj->asXml(FILE_XML_POSTS);
$xml .= '<notifications>'; $xml .= '</notifications>'; $obj = new NBXML($xml, 0, FALSE, '', FALSE); $obj->asXml(FILE_XML_NOTIFICATIONS); echo Html::p(array('class' => 'pass', 'content' => 'File created: ' . FILE_XML_NOTIFICATIONS)); } // ===================================================== // users.xml // ===================================================== if (!file_exists(FILE_XML_USERS)) { require FILE_SHADOW; $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; $xml .= '<users>'; $xml .= '</users>'; $obj = new NBXML($xml, 0, FALSE, '', FALSE); $node = $obj->addChild('user', ''); $node->addAttribute('username', $_USER[0]["username"]); $node->addChild('id', 0); $node->addChild('session_fail_count', 0); $node->addChild('session_date', 0); $obj->asXml(FILE_XML_USERS); echo Html::p(array('class' => 'pass', 'content' => 'File created: ' . FILE_XML_USERS)); } // ===================================================== // tags.xml // ===================================================== if (!file_exists(FILE_XML_TAGS)) { $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; $xml .= '<tags autoinc="0">'; $xml .= '<list></list>'; $xml .= '<links></links>';