public function processform() { if (!isset($_POST['contactvalue'])) { return ''; } $time = substr($_POST['contactvalue'], strlen('_contactform')); if (time() > $time) { return $this->errmesg; } $email = trim($_POST['email']); if (!tcontentfilter::ValidateEmail($email)) { return sprintf('<p><strong>%s</strong></p>', tlocal::get('comment', 'invalidemail')); } $url = trim($_POST['site']); if (empty($url) || strbegin($url, litepublisher::$site->url)) { return $this->errmesg; } if ($s = http::get($url)) { if (!strpos($s, '<meta name="generator" content="Lite Publisher')) { return $this->errmesg; } } else { return $this->errmesg; } $content = trim($_POST['content']); if (strlen($content) <= 15) { return sprintf('<p><strong>%s</strong></p>', tlocal::get('comment', 'emptycontent')); } $content = "{$url}\n" . $_POST['sitetitle'] . "\n\n" . $content; tmailer::sendmail('', $email, '', litepublisher::$options->email, $this->subject, $content); return $this->success; }
/** * Lite Publisher * Copyright (C) 2010 - 2013 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function tusernewsInstall($self) { $name = basename(dirname(__FILE__)); $self->data['dir'] = $name; $self->save(); tlocalmerger::i()->addplugin($name); $filter = tcontentfilter::i(); $filter->phpcode = true; $filter->save(); litepublisher::$options->parsepost = false; litepublisher::$options->reguser = true; $adminoptions = tadminoptions::i(); $adminoptions->usersenabled = true; $groups = tusergroups::i(); $groups->defaults = array($groups->getidgroup('author')); $groups->save(); $rights = tauthor_rights::i(); $rights->lock(); $rights->gethead = $self->gethead; $rights->getposteditor = $self->getposteditor; $rights->editpost = $self->editpost; $rights->changeposts = $self->changeposts; $rights->canupload = $self->canupload; $rights->candeletefile = $self->candeletefile; $rights->unlock(); }
public function processform() { if (!isset($_POST['contactvalue'])) { return ''; } $time = substr($_POST['contactvalue'], strlen('_contactform')); if (time() > $time) { return $this->errmesg; } $email = trim($_POST['email']); if (!tcontentfilter::ValidateEmail($email)) { return sprintf('<p><strong>%s</strong></p>', tlocal::get('comment', 'invalidemail')); } $content = trim($_POST['content']); if (strlen($content) <= 10) { return sprintf('<p><strong>%s</strong></p>', tlocal::get('comment', 'emptycontent')); } if (false !== strpos($content, '<a href')) { return $this->errmesg; } foreach ($this->data['extra'] as $name => $title) { if (isset($_POST[$name])) { $content .= sprintf("\n\n%s:\n%s", $title, trim($_POST[$name])); } } tmailer::sendmail('', $email, '', litepublisher::$options->email, $this->subject, $content); return $this->success; }
public function escape(array $item) { foreach (array('title', 'description', 'keywords') as $name) { $item[$name] = tcontentfilter::escape(tcontentfilter::unescape($item[$name])); } return $item; }
public function add($url, $title) { $filter = tcontentfilter::i(); $title = $filter->gettitle($title); $id = $this->doadd($url, $title); $this->added($id); $this->sendmail($id); return $id; }
public function addcomuser($name, $email, $website, $ip) { $users = tusers::i(); $id = $users->add(array('email' => strtolower(trim($email)), 'name' => $name, 'website' => tcontentfilter::clean_website($website), 'status' => 'comuser', 'idgroups' => 'commentator')); if ($id) { $this->comuseradded($id); } return $id; }
function tpollsmanUninstall($self) { tcontentfilter::i()->unbind($self); tcron::i()->deleteclass(get_class($self)); $posts = tposts::i(); $posts->syncmeta = false; $posts->unbind($self); litepublisher::$db->table = 'postsmeta'; litepublisher::$db->delete("name = 'poll'"); }
public function edit($id, $title, $description, $keywords, $content) { if (!$this->itemexists($id)) { return false; } $filter = tcontentfilter::i(); $item = $this->items[$id]; $this->items[$id] = array('idurl' => $item['idurl'], 'url' => $item['url'], 'title' => $title, 'filtered' => $filter->filter($content), 'rawcontent' => $content, 'description' => tcontentfilter::escape($description), 'keywords' => tcontentfilter::escape($keywords), 'idview' => $item['idview']); $this->save(); litepublisher::$urlmap->clearcache(); }
function ExportPages() { global $wpdb; $menus = tmenus::i(); $menus->lock(); litepublisher::$urlmap->lock(); $r = $wpdb->get_results("SELECT max(ID) as autoid FROM {$wpdb->posts} WHERE post_type = 'page'"); $autoid = (int) $r[0]->autoid; $menus->autoid = $autoid; $filter = tcontentfilter::i(); $list = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE post_type = 'page'"); foreach ($list as $item) { $id = (int) $item->ID; if ($id == 1) { $id = ++$menus->autoid; } if ($id == $menus->idhome) { $id = ++$menus->autoid; } $menu = new tmenu(); $menu->data['id'] = 0; $menu->data['title'] = $item->post_title; $menu->data['rawcontent'] = $item->post_content; $menu->data['content'] = $filter->filter($item->post_content); $menu->data['status'] = 'published'; $menu->data['order'] = (int) $item->menu_order; $menu->data['parent'] = (int) $item->post_parent; $url = @get_permalink($item->ID); $UrlArray = parse_url($url); $url = $UrlArray['path']; if (!empty($UrlArray['query'])) { $url .= '?' . $UrlArray['query']; } $menu->data['url'] = $url; //$menu->data['idurl'] = litepublisher::$urlmap->add($url, get_class($menu), $id); $menus->items[$id] = array('id' => $id, 'class' => get_class($menu)); //move props foreach (tmenu::$ownerprops as $prop) { $menus->items[$id][$prop] = $menu->{$prop}; if (array_key_exists($prop, $menu->data)) { unset($menu->data[$prop]); } } $menu->id = $id; $menu->idurl = litepublisher::$urlmap->add($url, get_class($menu), $id); $menu->save(); echo "menu {$menu->id}\n"; flush(); } $menus->sort(); $menus->unlock(); litepublisher::$urlmap->unlock(); }
public function updatefiltered() { $result = $this->getticketcontent(); $filter = tcontentfilter::i(); $filter->filterpost($this, $this->rawcontent); $result .= $this->filtered; if (!empty($this->childdata['code'])) { $lang = tlocal::i('ticket'); $result .= sprintf('<h2>%s</h2>', $lang->code); $result .= highlight_string($this->code, true); } $this->filtered = $result; }
function texternallinksUninstall($self) { $filter = tcontentfilter::i(); $filter->unbind($self); $cron = tcron::i(); $cron->deleteclass(get_class($self)); turlmap::unsub($self); if (dbversion) { $manager = tdbmanager::i(); $manager->deletetable($self->table); } tposts::i()->addrevision(); }
function twikiwordsUninstall($self) { unset(litepublisher::$classes->classes['wikiword']); litepublisher::$classes->save(); $filter = tcontentfilter::i(); $filter->unbind($self); tposts::unsub($self); if ($self->dbversion) { $manager = tdbmanager::i(); $manager->deletetable($self->table); $manager->deletetable($self->itemsposts->table); } }
function tcodedocpluginUninstall($self) { //die("Warning! You can lost all tickets!"); tposts::unsub($self); $menus = tmenus::i(); $menus->deleteurl('/doc/'); litepublisher::$classes->delete('tcodedocmenu'); litepublisher::$classes->delete('tcodedocfilter'); $filter = tcontentfilter::i(); $filter->unbind($self); $merger = tlocalmerger::i(); $merger->delete('codedoc'); $manager = tdbmanager::i(); $manager->deletetable('codedoc'); }
public function settagnames($names) { $names = trim($names); if ($names == '') { $this->tags = array(); return; } $parent = $this->getparenttag(); $tags = ttags::i(); $items = array(); $list = explode(',', trim($names)); foreach ($list as $title) { $title = tcontentfilter::escape($title); if ($title == '') { continue; } $items[] = $tags->add($parent, $title); } $this->tags = $items; }
public function getcontent($id, $sidebar) { $recent = $this->getrecent($this->maxcount); if (count($recent) == 0) { return ''; } $result = ''; $theme = ttheme::i(); $tml = $theme->getwidgetitem('comments', $sidebar); $url = litepublisher::$site->url; $args = targs::i(); $args->onrecent = tlocal::get('comment', 'onrecent'); foreach ($recent as $item) { $args->add($item); $args->link = $url . $item['posturl']; $args->content = tcontentfilter::getexcerpt($item['content'], 120); $result .= $theme->parsearg($tml, $args); } return $theme->getwidgetcontent($result, 'comments', $sidebar); }
public function processform() { extract($_POST, EXTR_SKIP); if (!($id = $this->getiduser())) { return; } $item = array('rawcontent' => trim($rawcontent), 'content' => tcontentfilter::i()->filter($rawcontent)); if ('admin' == litepublisher::$options->group) { $item['idview'] = (int) $idview; $item['url'] = $url; $item['head'] = $head; $item['keywords'] = $keywords; $item['description'] = $description; } $pages = tuserpages::i(); $pages->edit($id, $item); tusers::i()->edit($id, array('name' => $name, 'website' => tcontentfilter::clean_website($website))); $useroptions = tuseroptions::i(); $useroptions->setvalue($id, 'subscribe', isset($subscribe) ? 'enabled' : 'disabled'); $useroptions->setvalue($id, 'authorpost_subscribe', isset($authorpost_subscribe) ? 'enabled' : 'disabled'); }
public function convert($content) { $result = ''; $content = str_replace(array("\r\n", "\r"), "\n", trim($content)); $lines = explode("\n", $content); $q = array(); $a = array(); $filter = tcontentfilter::i(); foreach ($lines as $s) { $s = trim($s); if (strbegin($s, 'q:') || strbegin($s, 'Q:')) { $q[] = trim(substr($s, 2)); } elseif (strbegin($s, 'a:') || strbegin($s, 'A:')) { $a[] = trim(substr($s, 2)); } elseif ($s != '') { $result .= $this->createlist($q, $a); $q = array(); $a = array(); $result .= $filter->simplefilter($s); } } $result .= $this->createlist($q, $a); return $result; }
public function updatefiltered() { tcontentfilter::i()->filterpost($this, $this->rawcontent); }
private function parsemenu(&$str) { $result =& $this->theme->templates; $s = $this->parsetag($str, 'menulist', '$template.menu'); if ($s == '') { return $this->copy('menu'); } $default =& $this->default->templates; $item = trim($this->parsetag($s, 'item', '$item')); $result['menu.item.submenu'] = $this->parsetag($item, 'submenu', '$submenu', $default['menu.item.submenu']); $result['menu.item'] = $item != '' ? $item : $default['menu.item']; $result['menu.current'] = $this->parsetag($s, 'current', '', $default['menu.current']); //fix old version if ($this->fixold) { if (strpos($result['menu.item.submenu'], '%')) { $result['menu.item.submenu'] = sprintf($result['menu.item.submenu'], '$items'); } if (strpos($result['menu.item'], '%')) { $result['menu.item'] = sprintf($result['menu.item'], '$link', '$title', '$submenu'); } if (strpos($result['menu.current'], '%')) { $result['menu.current'] = sprintf($result['menu.current'], '$link', '$title', '$submenu'); } } //hover $nohover = '<!--nohover-->'; if (is_int($i = strpos($s, $nohover))) { $result['menu.hover'] = 'false'; $s = substr_replace($s, '', $i, strlen($nohover)); } elseif ($id = tcontentfilter::getidtag('*', $s)) { preg_match('/\\<(\\w*)/', $item, $t); $tag = $t[1]; $result['menu.hover'] = 'true'; $js = sprintf(' <script type="text/javascript"> $(document).ready(function() { $("#%s %s").hover(function(){$(this).addClass("jshover");}, function(){$(this).removeClass("jshover");}); }); </script>', $id, $tag); $s = $js . $s; } $s = $this->deletespaces($s); if ($s == '') { if (!isset($result['menu.hover'])) { $result['menu.hover'] = $menu->hover; } $result['menu'] = $default['menu']; } else { if (!isset($result['menu.hover'])) { $result['menu.hover'] = 'false'; } $result['menu'] = $s; } }
public function processcomuser(array &$values) { $lang = tlocal::i('comment'); if (empty($values['name'])) { return $this->geterrorcontent($lang->emptyname); } $values['name'] = tcontentfilter::escape($values['name']); $values['email'] = isset($values['email']) ? strtolower(trim($values['email'])) : ''; if (!tcontentfilter::ValidateEmail($values['email'])) { return $this->geterrorcontent($lang->invalidemail); } $values['url'] = isset($values['url']) ? tcontentfilter::escape(tcontentfilter::clean_website($values['url'])) : ''; $values['subscribe'] = isset($values['subscribe']); }
public function setcontent($id, $content) { $item = $this->getitem($id); $filter = tcontentfilter::i(); $item['rawcontent'] = $content; $item['content'] = $filter->filterpages($content); $item['description'] = tcontentfilter::getexcerpt($content, 80); $this->setitem($id, $item); }
public function setrawcontent($s) { $this->data['rawcontent'] = $s; $filter = tcontentfilter::i(); $this->data['content'] = $filter->filtercomment($s); }
public function uninstall() { $filter = tcontentfilter::i(); $filter->unbind($this); }
public static function refilter() { $db = litepublisher::$db; $filter = tcontentfilter::i(); $from = 0; while ($a = $db->res2assoc($db->query("select id, rawcontent from {$db->rawcomments} where id > {$from} limit 500"))) { $db->table = 'comments'; foreach ($a as $item) { $s = $filter->filtercomment($item['rawcontent']); $db->setvalue($item['id'], 'content', $s); $from = max($from, $item['id']); } unset($a); } }
function tsmilesUninstall($self) { tcontentfilter::i()->unbind($self); tposts::i()->addrevision(); }
public function uninstall() { tcontentfilter::i()->unbind($this); }
public function files_setprops(array $args) { if (!litepublisher::$options->hasgroup('author')) { return $this->forbidden(); } $id = (int) $args['idfile']; $files = tfiles::i(); if (!$files->itemexists($id)) { return $this->forbidden(); } $item = $files->getitem($id); $item['title'] = tcontentfilter::escape(tcontentfilter::unescape($args['title'])); $item['description'] = tcontentfilter::escape(tcontentfilter::unescape($args['description'])); $item['keywords'] = tcontentfilter::escape(tcontentfilter::unescape($args['keywords'])); $this->callevent('onprops', array(&$item)); $item = $files->escape($item); $files->db->updateassoc($item); return array('item' => $item); }
public function getcontent() { $result = ''; $files = tfiles::i(); $html = $this->html; $lang = $this->lang; $args = new targs(); if (!isset($_GET['action'])) { $args->add(array('uploadmode' => 'file', 'downloadurl' => '', 'title' => '', 'description' => '', 'keywords' => '')); $form = new adminform($args); $form->upload = true; $form->title = "<a id='files-source' href='#'>{$lang->switchlink}</a>"; $form->items = '[upload=filename] [hidden=uploadmode] [text=downloadurl] [text=title] [text=description] [text=keywords] [checkbox=overwrite]'; if (litepublisher::$options->show_file_perm) { $form->items .= tadminperms::getcombo(0, 'idperm'); } $result .= $form->get(); } else { $id = $this->idget(); if (!$files->itemexists($id)) { return $this->notfound; } switch ($_GET['action']) { case 'delete': if ($this->confirmed) { if ('author' == litepublisher::$options->group && ($r = tauthor_rights::i()->candeletefile($id))) { return $r; } $files->delete($id); $result .= $html->h2->deleted; } else { $item = $files->getitem($id); $args->add($item); $args->id = $id; $args->adminurl = $this->adminurl; $args->action = 'delete'; $args->confirm = sprintf($this->lang->confirm, $item['filename']); return $html->confirmform($args); } break; case 'edit': $item = $files->getitem($id); $args->add($item); $args->title = tcontentfilter::unescape($item['title']); $args->description = tcontentfilter::unescape($item['description']); $args->keywords = tcontentfilter::unescape($item['keywords']); $args->formtitle = $this->lang->editfile; $result .= $html->adminform('[text=title] [text=description] [text=keywords]' . (litepublisher::$options->show_file_perm ? tadminperms::getcombo($item['idperm'], 'idperm') : ''), $args); break; } } $perpage = 20; $type = $this->name == 'files' ? '' : $this->name; $sql = 'parent =0'; $sql .= litepublisher::$options->user <= 1 ? '' : ' and author = ' . litepublisher::$options->user; $sql .= $type == '' ? " and media<> 'icon'" : " and media = '{$type}'"; $count = $files->db->getcount($sql); $from = $this->getfrom($perpage, $count); $list = $files->select($sql, " order by posted desc limit {$from}, {$perpage}"); if (!$list) { $list = array(); } $result .= sprintf($html->h4->countfiles, $count, $from, $from + count($list)); $args->adminurl = $this->adminurl; $result .= $html->buildtable($files->items, array(array('right', 'ID', '$id'), array('right', $lang->filename, '<a href="$site.files/files/$filename">$filename</a>'), array('left', $lang->title, $type != 'icon' ? '$title' : '<img src="$site.files/files/$filename" alt="$filename" />'), array('center', $lang->edit, "<a href=\"{$this->adminurl}=\$id&action=edit\">{$lang->edit}</a>"), array('center', $lang->thumbnail, '<a href="' . tadminhtml::getadminlink('/admin/files/thumbnail/', 'id=') . "\$id\" target=\"_blank\">{$lang->thumbnail}</a>"), array('center', $lang->delete, "<a href=\"{$this->adminurl}=\$id&action=delete\">{$lang->delete}</a>"))); $theme = ttheme::i(); $result .= $theme->getpages($this->url, litepublisher::$urlmap->page, ceil($count / $perpage)); return $result; }
function ttidyfilterUninstall($self) { $filter = tcontentfilter::i(); $filter->unbind($self); }
public function processform() { if (empty($_POST['title'])) { return ''; } extract($_POST, EXTR_SKIP); $istags = $this->name == 'tags' || $this->name == 'addtag'; $tags = $istags ? litepublisher::$classes->tags : litepublisher::$classes->categories; $tags->lock(); $id = $this->idget(); if ($id == 0) { $id = $tags->add((int) $parent, $title); if (isset($order)) { $tags->setvalue($id, 'customorder', (int) $order); } if (isset($url)) { $tags->edit($id, $title, $url); } if (isset($idview)) { $item = $tags->getitem($id); $item = $this->set_view($item); $tags->items[$id] = $item; $item['id'] = $id; unset($item['url']); if ($tags->dbversion) { $tags->db->updateassoc($item); } } } else { $item = $tags->getitem($id); $item['title'] = $title; if (isset($parent)) { $item['parent'] = (int) $parent; } if (isset($order)) { $item['customorder'] = (int) $order; } if (isset($idview)) { $item = $this->set_view($item); } $tags->items[$id] = $item; if (!empty($url) && $url != $item['url']) { $tags->edit($id, $title, $url); } $tags->items[$id] = $item; if (dbversion) { unset($item['url']); $tags->db->updateassoc($item); } } if (isset($raw) || isset($keywords)) { $item = $tags->contents->getitem($id); if (isset($raw)) { $filter = tcontentfilter::i(); $item['rawcontent'] = $raw; $item['content'] = $filter->filterpages($raw); } if (isset($keywords)) { $item['keywords'] = $keywords; $item['description'] = $description; $item['head'] = $head; } $tags->contents->setitem($id, $item); } $tags->unlock(); $_GET['id'] = $_POST['id'] = $id; return sprintf($this->html->h2->success, $title); }