public function getcontent($id, $sidebar) { if (litepublisher::$urlmap->is404 || litepublisher::$urlmap->adminpanel || strbegin(litepublisher::$urlmap->url, '/croncron.php') || strend(litepublisher::$urlmap->url, '.xml')) { return ''; } $id = litepublisher::$urlmap->itemrequested['id']; $filename = litepublisher::$paths->data . 'keywords' . DIRECTORY_SEPARATOR . $id . '.' . litepublisher::$urlmap->page . '.php'; if (@file_exists($filename)) { $links = file_get_contents($filename); } else { if (count($this->links) < $this->count) { return ''; } $arlinks = array_splice($this->links, 0, $this->count); $this->save(); //$links = "\n<li>" . implode("</li>\n<li>", $arlinks) . "</li>"; $links = ''; $text = ''; foreach ($arlinks as $link) { $links .= sprintf('<li><a href="%s">%s</a></li>', $link['url'], $link['text']); $text .= $link['text'] . "\n"; } file_put_contents($filename, $links); if ($this->notify) { $plugin = tkeywordsplugin::i(); $plugin->added($filename, $text); } } $theme = ttheme::i(); return $theme->getwidgetcontent($links, $this->template, $sidebar); }
public function processform() { $datadir = litepublisher::$paths->data . 'keywords' . DIRECTORY_SEPARATOR; if (isset($_POST['optionsform'])) { extract($_POST, EXTR_SKIP); $plugin = tkeywordsplugin::i(); $widget = tkeywordswidget::i(); $widgets = twidgets::i(); $idwidget = $widgets->find($widget); $widget->lock(); $widget->settitle($idwidget, $title); $widget->count = (int) $count; $widget->notify = isset($notify); $trace = isset($trace); if ($widget->trace != $trace) { if ($trace) { litepublisher::$urlmap->afterrequest = $plugin->parseref; } else { litepublisher::$urlmap->delete_event_class('afterrequest', get_class($plugin)); } } $widget->trace = $trace; $widget->unlock(); $plugin->blackwords = array(); $words = strtoarray($blackwords); if (litepublisher::$options->language != 'en') { tlocal::usefile('translit'); foreach ($words as $word) { $word = strtr($word, tlocal::$self->ini['translit']); $word = trim($word); if (empty($word)) { continue; } $plugin->blackwords[] = strtolower($word); } } $plugin->save(); return; } if (isset($_GET['filename'])) { $filename = str_replace('_', '.', $_GET['filename']); $content = trim($_POST['content']); if ($content == '') { @unlink($datadir . $filename); } else { file_put_contents($datadir . $filename, $content); } return; } foreach ($_POST as $filename => $value) { $filename = str_replace('_', '.', $filename); if (preg_match('/^\\d+?\\.\\d+?\\.php$/', $filename)) { unlink($datadir . $filename); } } }