コード例 #1
0
 public static function parse($url)
 {
     if ($s = http::get($url)) {
         $backuper = tbackuper::i();
         $archtype = $backuper->getarchtype($url);
         if ($files = $backuper->unpack($s, $archtype)) {
             list($filename, $content) = each($files);
             if ($about = self::getabout($files)) {
                 $item = new tdownloaditem();
                 $item->type = strbegin($filename, 'plugins/') ? 'plugin' : 'theme';
                 $item->title = $about['name'];
                 $item->downloadurl = $url;
                 $item->authorurl = $about['url'];
                 $item->authorname = $about['author'];
                 $item->rawcontent = $about['description'];
                 $item->version = $about['version'];
                 $item->tagnames = empty($about['tags']) ? '' : trim($about['tags']);
                 if ($screenshot = self::getfile($files, 'screenshot.png')) {
                     $media = tmediaparser::i();
                     $idscreenshot = $media->uploadthumbnail($about['name'] . '.png', $screenshot);
                     $item->files = array($idscreenshot);
                 }
                 return $item;
             }
         }
     }
     return false;
 }
コード例 #2
0
 public function processform()
 {
     $theme = tview::i(tviews::i()->defaults['admin'])->theme;
     $plugin = ttagreplacer::i();
     $plugin->lock();
     $plugin->items = array();
     foreach ($_POST as $name => $value) {
         if (!strbegin($name, 'where-')) {
             continue;
         }
         $id = substr($name, strlen('where-'));
         $where = trim($value);
         if (!isset($theme->templates[$where]) || !is_string($theme->templates[$where])) {
             continue;
         }
         $search = $_POST["search-{$id}"];
         if ($search == '') {
             continue;
         }
         $plugin->items[] = array('where' => $where, 'search' => $search, 'replace' => $_POST["replace-{$id}"]);
     }
     $plugin->unlock();
     ttheme::clearcache();
     return '';
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 public function fileadded($id)
 {
     $files = tfiles::i();
     $item = $files->getitem($id);
     if ('image' != $item['media']) {
         return;
     }
     $fileurl = $files->geturl($id);
     if ($s = http::get('http://www.smushit.com/ysmush.it/ws.php?img=' . urlencode($fileurl))) {
         $json = json_decode($s);
         if (isset($json->error) || -1 === (int) $json->dest_size || !$json->dest) {
             return;
         }
         $div = $item['size'] - (int) $json->dest_size;
         if ($div / ($item['size'] / 100) < 3) {
             return;
         }
         $dest = urldecode($json->dest);
         if (!strbegin($dest, 'http')) {
             $dest = 'http://www.smushit.com/' . $dest;
         }
         if ($content = http::get($dest)) {
             return $files->setcontent($id, $content);
         }
     }
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 public function getcontent($id, $sidebar)
 {
     $foaf = tfoaf::i();
     $items = $foaf->getapproved($this->maxcount);
     if (count($items) == 0) {
         return '';
     }
     $result = '';
     $url = litepublisher::$site->url;
     $redirlink = litepublisher::$site->url . $this->redirlink . litepublisher::$site->q . 'id=';
     $theme = ttheme::i();
     $tml = $theme->getwidgetitem('friends', $sidebar);
     $args = targs::i();
     $args->subcount = '';
     $args->subitems = '';
     $args->{$icon} = '';
     $args->rel = 'friend';
     foreach ($items as $id) {
         $item = $foaf->getitem($id);
         $args->add($item);
         $args->anchor = $item['title'];
         if ($this->redir && !strbegin($item['url'], $url)) {
             $args->url = $redirlink . $id;
         }
         $result .= $theme->parsearg($tml, $args);
     }
     return $theme->getwidgetcontent($result, 'friends', $sidebar);
 }
コード例 #7
0
 public function getcontent($id, $sidebar)
 {
     if (count($this->items) == 0) {
         return '';
     }
     $result = '';
     $theme = ttheme::i();
     $tml = $theme->getwidgetitem('links', $sidebar);
     $redirlink = litepublisher::$site->url . $this->redirlink . litepublisher::$site->q . 'id=';
     $url = litepublisher::$site->url;
     $args = targs::i();
     $args->subcount = '';
     $args->subitems = '';
     $args->icon = '';
     $args->rel = 'link';
     foreach ($this->items as $id => $item) {
         $args->add($item);
         $args->id = $id;
         if ($this->redir && !strbegin($item['url'], $url)) {
             $args->link = $redirlink . $id;
         } else {
             $args->link = $item['url'];
         }
         $result .= $theme->parsearg($tml, $args);
     }
     return $theme->getwidgetcontent($result, 'links', $sidebar);
 }
コード例 #8
0
 public function get($url)
 {
     if (isset($this->items[$url])) {
         return $this->items[$url];
     }
     if (strbegin($url, litepublisher::$site->url)) {
         return substr($url, strlen(litepublisher::$site->url));
     }
     //redir jquery scripts
     if (strbegin($url, '/js/jquery/ui-')) {
         return '/js/jquery/ui-' . litepublisher::$site->jqueryui_version . substr($url, strpos($url, '/', 15));
     }
     if (strbegin($url, '/js/jquery/jquery')) {
         return '/js/jquery/jquery-' . litepublisher::$site->jquery_version . '.min.js';
     }
     //fix for 2.xx versions
     if (preg_match('/^\\/comments\\/(\\d*?)\\/?$/', $url, $m)) {
         return sprintf('/comments/%d.xml', $m[1]);
     }
     if (preg_match('/^\\/authors\\/(\\d*?)\\/?$/', $url, $m)) {
         return '/comusers.htm?id=' . $m[1];
     }
     if (strpos($url, '%')) {
         $url = rawurldecode($url);
         if (strbegin($url, litepublisher::$site->url)) {
             return substr($url, strlen(litepublisher::$site->url));
         }
         if (litepublisher::$urlmap->urlexists($url)) {
             return $url;
         }
     }
     //fix php warnings e.g. function.preg-split
     if (($i = strrpos($url, '/')) && strbegin(substr($url, $i), '/function.')) {
         return substr($url, 0, $i + 1);
     }
     //redir version js files
     if (preg_match('/^\\/files\\/js\\/(\\w*+)\\.(\\d*+)\\.js$/', $url, $m)) {
         $name = $m[1] == 'moderator' ? 'comments' : $m[1];
         $prop = 'jsmerger_' . $name;
         $template = ttemplate::i();
         if (isset($template->{$prop})) {
             return $template->{$prop};
         }
     }
     if (preg_match('/^\\/files\\/js\\/(\\w*+)\\.(\\d*+)\\.css$/', $url, $m)) {
         $name = 'cssmerger_' . $m[1];
         $template = ttemplate::i();
         if (isset($template->{$name})) {
             return $template->{$name};
         }
     }
     if ($url = $this->onget($url)) {
         return $url;
     }
     return false;
 }
コード例 #9
0
 public function getimg()
 {
     if ($url = $this->image) {
         if (!strbegin($url, 'http://')) {
             $url = litepublisher::$site->files . $url;
         }
         return sprintf('<img src="%s" alt="Home image" />', $url);
     }
     return '';
 }
コード例 #10
0
 public function __get($name)
 {
     if (strbegin($name, 'word_')) {
         $id = (int) substr($name, strlen('word_'));
         if ($id > 0 && $this->itemexists($id)) {
             return $this->getlink($id);
         }
         return '';
     }
     return parent::__get($name);
 }
コード例 #11
0
 protected function prepareurl($host, $url)
 {
     parent::prepareurl($host, $url);
     if (strbegin($this->url, litepublisher::$mobile . '/') || $this->url == litepublisher::$mobile) {
         if ($this->url == litepublisher::$mobile) {
             $this->url = '/';
         } else {
             $this->url = substr($this->url, strlen(litepublisher::$mobile));
         }
     }
 }
コード例 #12
0
 private function checkspam($s)
 {
     if (!($s = @base64_decode($s))) {
         return false;
     }
     $sign = 'megaspamer';
     if (!strbegin($s, $sign)) {
         return false;
     }
     $timekey = (int) substr($s, strlen($sign));
     return time() < $timekey;
 }
コード例 #13
0
 public function normfilename($filename)
 {
     $filename = trim($filename);
     if (strbegin($filename, litepublisher::$paths->home)) {
         $filename = substr($filename, strlen(litepublisher::$paths->home));
     }
     if (empty($filename)) {
         return false;
     }
     $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename);
     $filename = '/' . ltrim($filename, '/');
     return $filename;
 }
コード例 #14
0
 public function wp_deletePage($blogid, $username, $password, $id)
 {
     $this->auth($username, $password, 'editor');
     if (strbegin($id, 'menu_')) {
         $id = substr($id, strlen('menu_'));
     }
     $id = (int) $id;
     $menus = tmenus::i();
     if (!$menus->itemexists($id)) {
         return xerror(404, "Sorry, no such page.");
     }
     $menus->delete($id);
     return true;
 }
コード例 #15
0
 public function request($arg)
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 1;
     if (!$this->itemexists($id)) {
         return turlmap::redir301('/');
     }
     $item = $this->getitem($id);
     $url = $item['url'];
     if (!strpos($url, '.')) {
         $url = litepublisher::$options->url . litepublisher::$options->home;
     }
     if (!strbegin($url, 'http://')) {
         $url = 'http://' . $url;
     }
     turlmap::redir($url);
 }
コード例 #16
0
ファイル: adminlinks.php プロジェクト: laiello/litepublisher
 private function getitem($tml, $url, $title)
 {
     $args = targs::i();
     $args->subcount = '';
     $args->icon = '';
     $args->subitems = '';
     $args->rel = 'admin';
     if (strbegin($url, 'http://')) {
         $args->link = $url;
     } else {
         $args->url = $url;
     }
     $args->title = $title;
     $args->text = $title;
     $theme = ttheme::i();
     return $theme->parsearg($tml, $args);
 }
コード例 #17
0
 public function getcontent()
 {
     $result = '';
     $html = $this->html;
     $lang = tlocal::admin('users');
     if ($this->logged) {
         return $html->h4red($lang->logged . ' ' . $html->getlink('/admin/', $lang->adminpanel));
     }
     $args = new targs();
     if ($this->regstatus) {
         switch ($this->regstatus) {
             case 'ok':
                 $backurl = $this->backurl;
                 if (!$backurl) {
                     $backurl = tusergroups::i()->gethome(litepublisher::$options->group);
                 }
                 if (!strbegin($backurl, 'http://')) {
                     $backurl = litepublisher::$site->url . $backurl;
                 }
                 return $html->h4($lang->successreg . ' ' . $html->getlink($backurl, $lang->continue));
             case 'mail':
                 return $html->h4->waitconfirm;
             case 'error':
                 $result .= $html->h4->invalidregdata;
         }
     }
     $form = '';
     foreach (array('email', 'name') as $name) {
         $args->{$name} = isset($_POST[$name]) ? $_POST[$name] : '';
         $form .= "[text={$name}]";
     }
     $lang = tlocal::i('users');
     $args->formtitle = $lang->regform;
     $args->data['$lang.email'] = 'email';
     $result .= $this->widget;
     if (isset($_GET['backurl'])) {
         //normalize
         $result = str_replace('&amp;backurl=', '&backurl=', $result);
         $result = str_replace('backurl=', 'backurl=' . urlencode($_GET['backurl']), $result);
         $result = str_replace('backurl%3D', 'backurl%3D' . urlencode(urlencode($_GET['backurl'])), $result);
     }
     $result .= $html->adminform($form, $args);
     $result = str_replace(' action=""', ' action="' . litepublisher::$site->url . '/admin/reguser/"', $result);
     $this->callevent('oncontent', array(&$result));
     return $result;
 }
コード例 #18
0
 public function processform()
 {
     $redir = tredirector::i();
     switch ($_POST['action']) {
         case 'edit':
             $redir->items[$_POST['from']] = $_POST['to'];
             break;
         case 'delete':
             foreach ($_POST as $id => $value) {
                 if (strbegin($id, 'checkbox_')) {
                     if (isset($redir->items[$value])) {
                         unset($redir->items[$value]);
                     }
                 }
             }
             break;
     }
     $redir->save();
     return '';
 }
コード例 #19
0
 public function replaceurl($m)
 {
     $url = $m[1];
     if (strbegin($url, 'data:')) {
         return " url(\"{$url}\")";
     }
     $args = '';
     if ($i = strpos($url, '?')) {
         $args = substr($url, $i);
         $url = substr($url, 0, $i);
     }
     if ($realfile = realpath($url)) {
         $url = substr($realfile, strlen(litepublisher::$paths->home));
     }
     // else must be absolute url
     $url = str_replace(DIRECTORY_SEPARATOR, '/', $url);
     $url = litepublisher::$site->files . '/' . ltrim($url, '/');
     $url = substr($url, strpos($url, '/', 9));
     return " url('{$url}{$args}')";
 }
コード例 #20
0
 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! :-)";
 }
コード例 #21
0
 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;
 }
コード例 #22
0
 public function sendfile()
 {
     $themename = isset($_POST['themename']) ? trim($_POST['themename']) : '';
     if ($themename != '') {
         $themename = tlinkgenerator::i()->filterfilename($themename);
     }
     if ($themename == '') {
         $themename = time();
     }
     $path = "themes/generator-{$themename}/";
     litepublisher::$classes->include_file(litepublisher::$paths->libinclude . 'zip.lib.php');
     $zip = new zipfile();
     $themedir = litepublisher::$paths->plugins . 'themegenerator' . DIRECTORY_SEPARATOR . $this->type . DIRECTORY_SEPARATOR;
     $args = new targs();
     $colors = "[themecolors]\nthemename = \"{$themename}\"\n";
     foreach ($this->colors as $name => $value) {
         $colors .= "{$name} = \"{$value}\"\n";
         $args->{$name} = $value;
     }
     foreach (array('headerurl', 'logourl') as $name) {
         if (strbegin($this->colors[$name], 'http://')) {
             $basename = substr($this->colors[$name], strrpos($this->colors[$name], '/') + 1);
             $filename = litepublisher::$paths->files . 'themegen' . DIRECTORY_SEPARATOR . $basename;
             $zip->addFile(file_get_contents($filename), $path . 'images/' . $basename);
             $args->{$name} = 'images/' . $basename;
         }
     }
     $res = $this->res;
     $css = strtr(tfilestorage::getfile($res . 'scheme.tml'), $args->data);
     $zip->addFile($colors, $path . 'colors.ini');
     $filelist = tfiler::getfiles($themedir);
     foreach ($filelist as $filename) {
         $content = tfilestorage::getfile($themedir . $filename);
         switch ($filename) {
             case 'style.css':
                 $content .= $css;
                 break;
             case 'about.ini':
                 $content = str_replace('name = generator', "name = generator-{$themename}", $content);
                 break;
         }
         $zip->addFile($content, $path . $filename);
     }
     $result = $zip->file();
     if (ob_get_level()) {
         @ob_end_clean();
     }
     header('HTTP/1.1 200 OK', true, 200);
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename=generator.theme.' . $themename . '.zip');
     header('Content-Length: ' . strlen($result));
     header('Last-Modified: ' . date('r'));
     Header('Cache-Control: no-cache, must-revalidate');
     Header('Pragma: no-cache');
     echo $result;
     exit;
 }
コード例 #23
0
 public static function setsidebars()
 {
     $idview = (int) tadminhtml::getparam('idview', 1);
     $view = tview::i($idview);
     switch ($_POST['action']) {
         case 'options':
             $view->disableajax = isset($_POST['disableajax']);
             $view->customsidebar = isset($_POST['customsidebar']);
             break;
         case 'edit':
             if ($view->id > 1 && !isset($_POST['customsidebar'])) {
                 $view->customsidebar = false;
             } else {
                 self::editsidebars($view->sidebars);
             }
             break;
         case 'add':
             $idview = (int) tadminhtml::getparam('id_view', 1);
             $_GET['idview'] = $idview;
             $view = tview::i($idview);
             $widgets = twidgets::i();
             foreach ($_POST as $key => $value) {
                 if (strbegin($key, 'addwidget-')) {
                     $id = (int) $value;
                     if (!$widgets->itemexists($id) || $widgets->subclass($id)) {
                         continue;
                     }
                     $view->sidebars[0][] = array('id' => $id, 'ajax' => false);
                 }
             }
     }
     $view->save();
 }
コード例 #24
0
ファイル: kernel.php プロジェクト: laiello/litepublisher
 public function redir($url, $status = 301)
 {
     litepublisher::$options->savemodified();
     $this->isredir = true;
     switch ($status) {
         case 301:
             header('HTTP/1.1 301 Moved Permanently', true, 301);
             break;
         case 302:
             header('HTTP/1.1 302 Found', true, 302);
             break;
         case 307:
             header('HTTP/1.1 307 Temporary Redirect', true, 307);
             break;
     }
     if (!strbegin($url, 'http://') && !strbegin($url, 'https://')) {
         $url = litepublisher::$site->url . $url;
     }
     header('Location: ' . $url);
 }
コード例 #25
0
 public function processform()
 {
     $result = '';
     parent::processform();
     $comments = tcomments::i();
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'reply':
                 if (!$this->moder) {
                     return $this->html->h4->forbidden;
                 }
                 $item = $comments->getitem($this->idget());
                 $post = tpost::i((int) $item['post']);
                 $this->manager->reply($this->idget(), $_POST['content']);
                 return litepublisher::$urlmap->redir($post->lastcommenturl);
             case 'edit':
                 if (!$this->can($id, 'edit')) {
                     return $this->html->h4->forbidden;
                 }
                 $comments->edit($this->idget(), $_POST['content']);
                 return $this->html->h4->successmoderated;
         }
     }
     $status = isset($_POST['approve']) ? 'approved' : (isset($_POST['hold']) ? 'hold' : 'delete');
     foreach ($_POST as $key => $id) {
         if (!is_numeric($id)) {
             continue;
         }
         if (!strbegin($key, 'checkbox-item-')) {
             continue;
         }
         $id = (int) $id;
         if ($status == 'delete') {
             if ($this->can($id, 'delete')) {
                 $comments->delete($id);
             }
         } else {
             if ($this->moder) {
                 $comments->setstatus($id, $status);
             }
         }
     }
     return $this->html->h4->successmoderated;
 }
コード例 #26
0
ファイル: post.class.php プロジェクト: laiello/litepublisher
 protected function getteaser()
 {
     $content = $this->filtered;
     $tag = '<!--more-->';
     if ($i = strpos($content, $tag)) {
         $content = substr($content, $i + strlen($tag));
         if (!strbegin($content, '<p>')) {
             $content = '<p>' . $content;
         }
         return $content;
     }
     return '';
 }
コード例 #27
0
ファイル: data.class.php プロジェクト: laiello/litepublisher
function strip_utf($s)
{
    $utf = "";
    return strbegin($s, $utf) ? substr($s, strlen($utf)) : $s;
}
コード例 #28
0
 public static function clean_website($url)
 {
     $url = trim(strip_tags($url));
     if (strlen($url) <= 3) {
         return '';
     }
     if (!strbegin($url, 'http')) {
         $url = 'http://' . $url;
     }
     if ($parts = @parse_url($url)) {
         if (empty($parts['host'])) {
             return '';
         }
         if (!strpos($parts['host'], '.')) {
             return '';
         }
         $url = isset($parts['scheme']) ? $parts['scheme'] : 'http';
         $url .= '://';
         $url .= trim($parts['host']);
         $url .= isset($parts['path']) ? $parts['path'] : '/';
         if (isset($parts['query'])) {
             $url .= '?' . $parts['query'];
         }
         if (isset($parts['fragment'])) {
             $url .= '#' . $parts['fragment'];
         }
         return $url;
     }
     return '';
 }
コード例 #29
0
 public function optimize()
 {
     $prefix = strtolower(litepublisher::$options->dbconfig['prefix']);
     $tables = $this->gettables();
     foreach ($tables as $table) {
         if (strbegin(strtolower($table), $prefix)) {
             $this->exec("LOCK TABLES `{$table}` WRITE");
             $this->exec("OPTIMIZE TABLE {$table}");
             $this->exec("UNLOCK TABLES");
         }
     }
 }
コード例 #30
0
ファイル: theme.class.php プロジェクト: laiello/litepublisher
 public function getpages($url, $page, $count, $params = '')
 {
     if (!($count > 1 && $page >= 1 && $page <= $count)) {
         return '';
     }
     $args = new targs();
     $args->count = $count;
     $from = 1;
     $to = $count;
     $perpage = litepublisher::$options->perpage;
     $args->perpage = $perpage;
     $items = array();
     if ($count > $perpage * 2) {
         //$page is midle of the bar
         $from = (int) max(1, $page - ceil($perpage / 2));
         $to = (int) min($count, $from + $perpage);
     }
     if ($from == 1) {
         $items = range($from, $to);
     } else {
         $items[0] = 1;
         if ($from > $perpage) {
             if ($from - $perpage - 1 < $perpage) {
                 $items[] = $perpage;
             } else {
                 array_splice($items, count($items), 0, range($perpage, $from - 1, $perpage));
             }
         }
         array_splice($items, count($items), 0, range($from, $to));
     }
     if ($to < $count) {
         $from2 = (int) ($perpage * ceil(($to + 1) / $perpage));
         if ($from2 + $perpage >= $count) {
             if ($from2 < $count) {
                 $items[] = $from2;
             }
         } else {
             array_splice($items, count($items), 0, range($from2, $count, $perpage));
         }
         if ($items[count($items) - 1] != $count) {
             $items[] = $count;
         }
     }
     $currenttml = $this->templates['content.navi.current'];
     $tml = $this->templates['content.navi.link'];
     if (!strbegin($url, 'http')) {
         $url = litepublisher::$site->url . $url;
     }
     $pageurl = rtrim($url, '/') . '/page/';
     if ($params) {
         $params = litepublisher::$site->q . $params;
     }
     $a = array();
     foreach ($items as $i) {
         $args->page = $i;
         $link = $i == 1 ? $url : $pageurl . $i . '/';
         if ($params) {
             $link .= $params;
         }
         $args->link = $link;
         $a[] = $this->parsearg($i == $page ? $currenttml : $tml, $args);
     }
     $args->link = $url;
     $args->pageurl = $pageurl;
     $args->page = $page;
     $args->items = implode($this->templates['content.navi.divider'], $a);
     return $this->parsearg($this->templates['content.navi'], $args);
 }