public function import($s) { require_once litepublisher::$paths->lib . 'domrss.class.php'; $a = xml2array($s); $urlmap = turlmap::i(); $urlmap->lock(); $cats = tcategories::i(); $cats->lock(); $tags = ttags::i(); $tags->lock(); $posts = tposts::i(); $posts->lock(); foreach ($a['rss']['channel'][0]['item'] as $item) { if ($post = $this->add($item)) { $posts->add($post); if (isset($item['wp:comment']) && is_array($item['wp:comment'])) { $this->importcomments($item['wp:comment'], $post->id); } if (!tfilestorage::$disabled) { $post->free(); } } } $posts->unlock(); $tags->unlock(); $cats->unlock(); $urlmap->unlock(); }
function installClasses() { litepublisher::$urlmap = turlmap::i(); litepublisher::$urlmap->lock(); $posts = tposts::i(); $posts->lock(); $xmlrpc = TXMLRPC::i(); $xmlrpc->lock(); ttheme::$defaultargs = array(); $theme = ttheme::getinstance('default'); // $html = tadminhtml::i(); // $html->loadinstall(); foreach (litepublisher::$classes->items as $class => $item) { //echo "$class<br>\n"; if (preg_match('/^(titem|titem_storage|titemspostsowner|tcomment|IXR_Client|IXR_Server|tautoform|tchildpost|tchildposts|tlitememcache)$/', $class)) { continue; } $obj = getinstance($class); if (method_exists($obj, 'install')) { $obj->install(); } } $xmlrpc->unlock(); $posts->unlock(); litepublisher::$urlmap->unlock(); }
function TRSSPrevNextUninstall($self) { $rss = trss::i(); $rss->unbind($self); $urlmap = turlmap::i(); $urlmap->clearcache(); }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function tcommontagsInstall($self) { if ('tcommontags' == get_class($self)) { return; } $posts = tposts::i(); $posts->lock(); $posts->added = $self->postedited; $posts->edited = $self->postedited; $posts->deleted = $self->postdeleted; $posts->unlock(); $urlmap = turlmap::i(); $urlmap->add("/{$self->PermalinkIndex}/", get_class($self), 0); if (dbversion) { $manager = tdbmanager::i(); $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $manager->createtable($self->table, file_get_contents($dir . 'tags.sql')); $manager->createtable($self->itemsposts->table, file_get_contents($dir . 'items.posts.sql')); $manager->createtable($self->contents->table, file_get_contents($dir . 'tags.content.sql')); } else { $dir = litepublisher::$paths->data . $self->basename; @mkdir($dir, 0777); @chmod($dir, 0777); } }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function tmanifestInstall($self) { $urlmap = turlmap::i(); $urlmap->lock(); $urlmap->add('/wlwmanifest.xml', get_class($self), 'manifest'); $urlmap->add('/rsd.xml', get_class($self), 'rsd'); $urlmap->Unlock(); }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function TXMLRPCInstall($self) { $urlmap = turlmap::i(); $urlmap->lock(); $urlmap->add('/rpc.xml', get_class($self), null); $urlmap->add('/xmlrpc.php', get_class($self), null); $urlmap->unlock(); }
public function delete($id) { if (parent::delete($id)) { $urlmap = turlmap::i(); $urlmap->clearcache(); return true; } return false; }
public function add($value) { if (!in_array($value, $this->items)) { $this->items[] = $value; $this->save(); $urlmap = turlmap::i(); $urlmap->setexpired($this->idurl); $this->added($value); } }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function tdownloadcounterInstall($self) { if (dbversion) { $manager = TDBManager::i(); $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $manager->CreateTable($self->table, file_get_contents($dir . 'downloadcounter.sql')); } $files = tfiles::i(); $files->deleted = $self->delete; $urlmap = turlmap::i(); $urlmap->add('/downloadcounter/', get_class($self), null, 'get'); }
private function dochanged($name, $value) { if ($name == 'perpage') { $this->perpagechanged(); $urlmap = turlmap::i(); $urlmap->clearcache(); } elseif ($name == 'cache') { $urlmap = turlmap::i(); $urlmap->clearcache(); } else { $this->changed($name, $value); } }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function tlinkswidgetInstall($self) { if (get_class($self) != 'tlinkswidget') { return; } tlocal::usefile('admin'); $lang = tlocal::i('installation'); $self->add($lang->homeurl, $lang->homedescription, $lang->homename); $urlmap = turlmap::i(); $urlmap->add($self->redirlink, get_class($self), null, 'get'); $robots = trobotstxt::i(); $robots->AddDisallow($self->redirlink); $robots->save(); }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function trssMultimediaInstall($self) { $urlmap = turlmap::i(); $urlmap->lock(); $urlmap->add('/rss/multimedia.xml', get_class($self), ''); $urlmap->add('/rss/images.xml', get_class($self), 'image'); $urlmap->add('/rss/audio.xml', get_class($self), 'audio'); $urlmap->add('/rss/video.xml', get_class($self), 'video'); $urlmap->unlock(); $files = tfiles::i(); $files->changed = $self->fileschanged; $self->save(); $meta = tmetawidget::i(); $meta->add('media', '/rss/multimedia.xml', tlocal::get('default', 'rssmedia')); }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function trobotstxtInstall($self) { $self->lock(); $urlmap = turlmap::i(); $self->idurl = $urlmap->add('/robots.txt', get_class($self), null); $self->add("#" . litepublisher::$site->url . "/"); $self->add('User-agent: *'); //$self->AddDisallow('/rss.xml'); //$self->AddDisallow('/comments.xml'); //$self->AddDisallow('/comments/'); $self->AddDisallow('/admin/'); $self->AddDisallow('/admin/'); $self->AddDisallow('/wlwmanifest.xml'); $self->AddDisallow('/rsd.xml'); $self->unlock(); }
/** * Lite Publisher * Copyright (C) 2010 - 2015 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function tkeywordspluginInstall($self) { @mkdir(litepublisher::$paths->data . 'keywords', 0777); @chmod(litepublisher::$paths->data . 'keywords', 0777); $item = litepublisher::$classes->items[get_class($self)]; litepublisher::$classes->add('tkeywordswidget', 'keywords.widget.php', $item[1]); $widget = tkeywordswidget::i(); $widgets = twidgets::i(); $widgets->lock(); $id = $widgets->add($widget); $sidebars = tsidebars::i(); $sidebars->insert($id, false, 1, -1); $widgets->unlock(); $urlmap = turlmap::i(); $urlmap->lock(); $urlmap->afterrequest = $self->parseref; $urlmap->deleted = $self->urldeleted; $urlmap->unlock(); }
public function ping($from, $to) { if (!strbegin($to, litepublisher::$site->url)) { return new IXR_Error(0, 'Is there no link to us?'); } $url = substr($to, strlen(litepublisher::$site->url)); $urlmap = turlmap::i(); if (!($item = $urlmap->finditem($url))) { return $this->xerror(0, 'Is there no link to us?'); } if ($item['class'] != litepublisher::$classes->classes['post']) { return $this->xerror(33, 'The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'); } $post = tpost::i($item['arg']); if (!$post->pingenabled || $post->status != 'published') { return $this->xerror(33, 'The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'); } $pingbacks = $post->pingbacks; if ($pingbacks->exists($from)) { return new IXR_Error(48, 'The pingback has already been registered.'); } if (!($s = http::get($from))) { return new IXR_Error(16, 'The source URL does not exist.'); } $s = str_replace('<!DOC', '<DOC', $s); $s = preg_replace('/[\\s\\r\\n\\t]+/', ' ', $s); // normalize spaces if (!preg_match('|<title>([^<]*?)</title>|is', $s, $matchtitle) || empty($matchtitle[1])) { return new IXR_Error(32, 'We cannot find a title on that page.'); } $s = strip_tags($s, '<a>'); if (!preg_match("|<a([^>]+?" . preg_quote($to) . "[^>]*)>[^>]+?</a>|", $s, $match)) { return new IXR_Error(17, 'The source URL does not contain a link to the target URL, and so cannot be used as a source.'); } if (preg_match('/nofollow|noindex/is', $match[1])) { return new IXR_Error(32, 'The source URL contain nofollow or noindex atribute'); } $pingbacks->add($from, $matchtitle[1]); return "Pingback from {$from} to {$to} registered. Keep the web talking! :-)"; }
public function delete($id) { $urlmap = turlmap::i(); $urlmap->deleteitem($this->items[$id]['idurl']); parent::delete($id); }
require_once litepublisher::$paths->lib . 'options.class.php'; require_once litepublisher::$paths->lib . 'site.class.php'; } else { require_once litepublisher::$paths->lib . 'kernel.php'; } define('dbversion', true); /* if (class_exists('Memcache')) { tfilestorage::$memcache = new Memcache; tfilestorage::$memcache->connect('127.0.0.1', 11211); } */ if (!tstorage::loaddata()) { if (file_exists(litepublisher::$paths->data . 'storage.php') && filesize(litepublisher::$paths->data . 'storage.php')) { die('Storage not loaded'); } require_once litepublisher::$paths->lib . 'install' . DIRECTORY_SEPARATOR . 'install.php'; } litepublisher::$classes = tclasses::i(); litepublisher::$options = toptions::i(); litepublisher::$db = tdatabase::i(); litepublisher::$site = tsite::i(); litepublisher::$urlmap = turlmap::i(); if (!defined('litepublisher_mode')) { litepublisher::$urlmap->request(strtolower($_SERVER['HTTP_HOST']), $_SERVER['REQUEST_URI']); } } catch (Exception $e) { litepublisher::$options->handexception($e); } litepublisher::$options->savemodified(); litepublisher::$options->showerrors();
public function delete($id) { if (!$this->itemexists($id)) { return false; } $urlmap = turlmap::i(); $idurl = $this->db->getvalue($id, 'idurl'); $this->db->setvalue($id, 'status', 'deleted'); if ($this->childtable) { $db = $this->getdb($this->childtable); $db->delete("id = {$id}"); } $this->lock(); $this->PublishFuture(); $this->UpdateArchives(); $this->cointerface('delete', $id); $this->unlock(); $this->deleted($id); $this->changed(); $urlmap->clearcache(); return true; }
public function wpnewComment($blog_id, $login, $password, $idpost, $struct) { $this->auth($login, $password, 'moderator'); if (is_numeric($idpost)) { $idpost = absint($idpost); } else { $urlmap = turlmap::i(); if (!($item = $urlmap->finditem($url))) { return $this->xerror(404, 'Invalid post ID.'); } if ($item['class'] != litepublisher::$classes->classes['post']) { return $this->xerror(404, 'Invalid post ID.'); } $idpost = $item['arg']; } $post = tpost::i($idpost); if (!$post->commentenabled || $post->status != 'published') { return $this->xerror(403, 'The specified post cannot be used to commenting'); } $manager = tcommentmanager::i(); return $manager->add($idpost, isset($struct['author']) ? $struct['author'] : '', isset($struct['author_email']) ? $struct['author_email'] : '', isset($struct['author_url']) ? $struct['author_url'] : '', $struct['content']); }
function ExportPosts() { global $wpdb, $from; $urlmap = turlmap::i(); $urlmap->lock(); $posts = tposts::i(); $posts->lock(); if (dbversion) { $r = $wpdb->get_results("SELECT max(ID) as autoid FROM {$wpdb->posts} "); $autoid = (int) $r[0]->autoid; echo "{$autoid} = auto id posts\n"; $posts->db->exec(sprintf('ALTER TABLE %s AUTO_INCREMENT = %d', $posts->thistable, $autoid)); } $categories = tcategories::i(); $categories->loadall(); $categories->lock(); $tags = ttags::i(); $tags->loadall(); $tags->lock(); if ($from == 0) { echo "import categories\n"; ExportCategories(); echo "import pages\n"; ExportPages(); } $cron = tcron::i(); $cron->disableadd = true; //$list = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post'"); $list = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} \r\nWHERE post_type = 'post'\r\nand ID > {$from}\r\nlimit 500\r\n"); echo count($list), " = countposts\n"; foreach ($list as $index => $idresult) { //$itemres= $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID = $idresult"); $itemres = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE ID = {$idresult->ID}"); $item =& $itemres[0]; $post = new tpost(); $post->id = (int) $item->ID; echo $post->id, " = id post\n"; $post->posted = strtotime(mysql2date('Ymd\\TH:i:s', $item->post_date)); $post->title = $item->post_title; $post->categories = wp_get_post_categories($item->ID); $taglist = array(); $wptags = wp_get_post_tags($item->ID); foreach ($wptags as $wptag) { AddTag($tags, (int) $wptag->term_id, 0, $wptag->name, get_tag_link($wptag->term_id)); $taglist[] = (int) $wptag->term_id; } $post->tags = $taglist; $UrlArray = parse_url(@get_permalink($item->ID)); $url = $UrlArray['path']; if (!empty($UrlArray['query'])) { $url .= '?' . $UrlArray['query']; } $post->url = $url; $post->idurl = litepublisher::$urlmap->add($post->url, get_class($post), $post->id); $post->content = $item->post_content; $post->commentsenabled = 'open' == $item->comment_status; $post->pingenabled = 'open' == $item->ping_status; $post->password = $item->post_password; $post->status = $item->post_status == 'publish' ? 'published' : 'draft'; savepost($post); $categories->itemsposts->setitems($post->id, $post->categories); $tags->itemsposts->setitems($post->id, $post->tags); ExportComments($post); $post->free(); } $cron->unlock(); //$CommentManager->SubscribtionEnabled = true; //$CommentManager->NotifyModerator = true; $tags->unlock(); $categories->unlock(); $posts->UpdateArchives(); $posts->addrevision(); $posts->unlock(); $urlmap->clearcache(); $arch = tarchives::i(); $arch->postschanged(); $urlmap->unlock(); if (count($list) < 500) { return false; } return $item->ID; }
public function editurl($obj, $schema) { if (!isset($obj->url) || !isset($obj->idurl) || !isset($obj->url)) { return $this->error("The properties url and title not found"); } $urlmap = turlmap::i(); $oldurl = $urlmap->getidurl($obj->idurl); if ($oldurl == $obj->url) { return; } if ($obj->url == '') { $obj->url = $this->createlink($obj, $schema, false); if ($oldurl == $obj->url) { return; } } $url = trim(strip_tags($obj->url), "\n\r\t \v,.;?!/\\<>():;-\"'"); if ($url == '') { $obj->url = $this->createlink($obj, $schema, false); if ($oldurl == $obj->url) { return; } } $url = '/' . $url; if (strend($obj->url, '/')) { $url .= '/'; } if ($oldurl == $url) { $obj->url = $oldurl; return; } $url = $this->encode($url); $url = $this->clean($url); if ($oldurl == $url) { $obj->url = $oldurl; return; } //check unique url if ($urlitem = $urlmap->findurl($url)) { $url = $this->MakeUnique($url); } $obj->url = $url; $urlmap->setidurl($obj->idurl, $obj->url); $urlmap->addredir($oldurl, $obj->url); }