public function filtercomment($content) { $result = trim($content); $result = str_replace(array("\r\n", "\r"), "\n", $result); $result = self::quote(htmlspecialchars($result)); if ($this->callevent('oncomment', array(&$result))) { $this->callevent('onaftercomment', array(&$result)); return $result; } $result = self::simplebbcode($result); if ($this->commentautolinks) { $result = self::createlinks($result); } $result = $this->replacecode($result); $result = self::auto_p($result); if (strlen($result) > 4 && !strpos($result, '<p>', 4)) { if (strbegin($result, '<p>')) { $result = substr($result, 3); } if (strend($result, '</p>')) { $result = substr($result, 0, strlen($result) - 4); } $result = trim($result); } $this->callevent('onaftercomment', array(&$result)); return $result; }
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 delete($name, $filename) { $files = tfiles::i(); $icons = ticons::i(); $id = $icons->items[$name]; if ($files->itemexists($id)) { $item = $files->getitem($id); if (strend($item['filename'], $filename)) { $icons->items[$name] = 0; $files->delete($id); } } }
public function __get($name) { if (isset($this->ini[$this->section][$name])) { return $this->ini[$this->section][$name]; } foreach ($this->searchsect as $section) { if (isset($this->ini[$section][$name])) { return $this->ini[$section][$name]; } } if (in_array($name, self::$tags)) { return new thtmltag($name); } if (strend($name, 'red') && in_array(substr($name, 0, -3), self::$tags)) { return new redtag($name); } throw new Exception("the requested {$name} item not found in {$this->section} section"); }
public function setcolor($name, $value) { if (isset($this->colors[$name])) { $value = trim($value); if (strend($name, 'url') || preg_match('/^[0-9a-zA-Z]*+$/', $value)) { $this->colors[$name] = $value; } } }
public function include_file($filename) { if (!tfilestorage::$memcache || litepublisher::$debug || !$this->memcache) { if (file_exists($filename)) { require_once $filename; } return; } if (in_array($filename, $this->included_files)) { return; } if ($s = tfilestorage::$memcache->get($filename)) { $i = strpos($s, ';'); $revision = substr($s, 0, $i); if ($revision == $this->revision_memcache) { eval(substr($s, $i + 1)); return; } tfilestorage::$memcache->delete($filename); } if (file_exists($filename)) { $s = file_get_contents($filename); eval('?>' . $s); //strip php tag and copyright in head if (strbegin($s, '<?php')) { $s = substr($s, 5); } if (strend($s, '?>')) { $s = substr($s, 0, -2); } $s = trim($s); if (strbegin($s, '/*')) { $s = substr($s, strpos($s, '*/') + 2); } $s = $this->revision_memcache . ';' . ltrim($s); tfilestorage::$memcache->set($filename, $s, false, 3600); } }
public static function compress(ttheme $theme, $dir = '') { if ($theme->name == 'default') { return false; } $result = ''; if ($dir == '') { $dir = litepublisher::$paths->themes . $theme->name . DIRECTORY_SEPARATOR; } $parent = ttheme::getinstance($theme->parent == '' ? 'default' : $theme->parent); if ($theme->templates['index'] != $parent->templates['index']) { if (file_put_contents($dir . 'index.tml', $theme->templates['index']) === false) { return false; } $result .= '$template = {@import(index.tml)}'; $result .= "\n\n"; } foreach ($theme->templates as $name => $value) { if ($name == 'index') { continue; } if (is_array($value)) { continue; } $value = trim($value); if ($value == trim($parent->templates[$name])) { continue; } if (strend($name, '.date')) { if ($value == '' || $value == litepublisher::$options->dateformat || $value == tlocal::get('datetime', 'dateformat')) { continue; } } $result .= "\$template.{$name} = [{$value}]\n\n"; } for ($i = 0; $i < count($theme->templates['sidebars']); $i++) { $sidebar =& $theme->templates['sidebars'][$i]; $parentsidebar =& $parent->templates['sidebars'][$i]; foreach ($sidebar as $name => $value) { if (is_string($value)) { $value = trim($value); if ($value == trim($parentsidebar[$name])) { continue; } } else { if (count(array_diff_assoc($value, $parentsidebar[$name])) == 0) { continue; } $a = array_map(create_function('$k, $v', 'return "$k=$v";'), array_keys($value), array_values($value)); $value = implode(',', $a); } $result .= $i == 0 ? 'sidebar.' : "sidebar{$i}."; $result .= "{$name} = [{$value}]\n\n"; } } return file_put_contents($dir . 'theme.txt', $result); }
public function getarchtype($filename) { if (strend($filename, '.zip')) { return 'zip'; } if (strend($filename, '.tar.gz') || strend($filename, '.tar')) { return 'tar'; } return false; }
private function getbackupfilelist() { $list = tfiler::getfiles(litepublisher::$paths->backup); if (!count($list)) { return ''; } $items = array(); $html = $this->html; foreach ($list as $filename) { if (strend($filename, '.gz') || strend($filename, '.zip')) { $items[]['filename'] = $filename; } } if (!count($items)) { return ''; } $lang = $this->lang; return $this->html->h4->backupheadern . $this->html->buildtable($items, array(array('right', $lang->download, "<a href=\"{$this->adminurl}=\$filename&action=download\">\$filename</a>"), array('right', $lang->delete, "<a href=\"{$this->adminurl}=\$filename&action=delete\">{$lang->delete}</a>"))); }
public function trimwords($s, array $words) { if ($s == '') { return ''; } foreach ($words as $word) { if (strbegin($s, $word)) { $s = substr($s, strlen($word)); } if (strend($s, $word)) { $s = substr($s, 0, strlen($s) - strlen * $word); } } return $s; }
public function getinfo($filename) { $realfile = litepublisher::$paths->files . str_replace('/', DIRECTORY_SEPARATOR, $filename); $result = $this->getdefaultvalues($filename); if (preg_match("/\\.({$this->videoext})\$/", $filename, $m)) { $ext = $m[1]; $mime = array('mp4' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'avi' => 'video/x-msvideo', 'mov' => 'video/quicktime', 'ogv' => 'video/ogg', 'webm' => 'video/webm', 'flv' => 'video/x-flv', 'f4v' => 'video/mp4', 'f4p' => 'video/mp4'); if (isset($mime[$ext])) { $result['mime'] = $mime[$ext]; } $result['media'] = 'video'; return $result; } if ($info = @getimagesize($realfile)) { $result['mime'] = $info['mime']; $result['media'] = 'application/x-shockwave-flash' == $info['mime'] ? 'flash' : 'image'; $result['width'] = $info[0]; $result['height'] = $info[1]; return $result; } if (preg_match("/\\.({$this->audioext})\$/", $filename)) { $mime = array('mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav', 'flac' => 'audio/ogg', 'f4a' => 'audio/mp4', 'f4b' => 'audio/mp4'); $result['mime'] = $mime[strtolower(substr($filename, -3))]; $result['media'] = 'audio'; return $result; } if (strend($filename, '.txt')) { $result['mime'] = 'text/plain'; $result['media'] = 'text'; return $result; } if (strend($filename, '.swf')) { $result['media'] = 'flash'; $result['mime'] = 'application/x-shockwave-flash'; require_once litepublisher::$paths->libinclude . 'getid3.php'; require_once litepublisher::$paths->libinclude . 'getid3.lib.php'; require_once litepublisher::$paths->libinclude . 'module.audio-video.swf.php'; $getID3 = new getID3(); $getID3->option_md5_data = true; $getID3->option_md5_data_source = true; $getID3->encoding = 'UTF-8'; //$info = $getID3->analyze($realfile); $getID3->openfile($realfile); $swf = new getid3_swf($getID3); $swf->analyze(); fclose($getID3->fp); $info = $getID3->info; if (!isset($info['error'])) { $result['width'] = (int) round($info['swf']['header']['frame_width'] / 20); $result['height'] = (int) round($info['swf']['header']['frame_height'] / 20); return $result; } } return $result; }
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); }
public function getfilelist($dir) { $dir = trim(str_replace(DIRECTORY_SEPARATOR, '/', $dir), '/'); $realdir = $this->root . str_replace('/', DIRECTORY_SEPARATOR, $dir) . DIRECTORY_SEPARATOR; if ($list = scandir($realdir)) { $result = array('dirs' => array(), 'files' => array()); foreach ($list as $i => $filename) { if (preg_match('/^(\\.|\\.\\.|\\.htaccess|index\\.htm|\\.svn)$/', $filename) || in_array($dir . '/' . $filename, $this->ignore)) { continue; } if (is_dir($realdir . $filename)) { $result['dirs'][] = $filename; } else { if (strend($filename, '.min.js')) { continue; } $result['files'][] = $filename; } } return $result; } return false; }