Example #1
0
 function edit_sub_category($name, $id, $markbold, $category_id)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . "/common/class/seo.class.php";
     $seo_class = new seo();
     $sql = "update `" . $this->table . "` set name='" . $this->mysql->magicquotes($name) . "',markbold='" . $this->mysql->magicquotes($markbold) . "',category_id='" . $this->mysql->magicquotes($category_id) . "',seo_url='" . $this->mysql->magicquotes($seo_class->get_seo_url($name)) . "' where id='" . $id . "'";
     $result = $this->mysql->query($sql);
 }
Example #2
0
 public function description($description = false)
 {
     if (!$description) {
         return self::$description;
     }
     self::$description = $description;
 }
Example #3
0
 /**
  * get search results of keywords.
  * 
  * @param  string    $keywords 
  * @param  object    $pager 
  * @access public
  * @return array
  */
 public function getList($keywords, $pager)
 {
     $spliter = $this->app->loadClass('spliter');
     $words = explode(' ', seo::unify($keywords, ' '));
     $against = '';
     foreach ($words as $word) {
         $splitedWords = $spliter->utf8Split($word);
         $against .= '"' . $splitedWords['words'] . '"';
     }
     $words = str_replace('"', '', $against);
     $words = str_pad($words, 5, '_');
     /*$scoreColumn = "((1 * (MATCH(title) AGAINST('{$against}' IN BOOLEAN MODE))) + (0.6 * (MATCH(title) AGAINST('{$against}' IN BOOLEAN MODE))) )";
       $results = $this->dao->select("*, {$scoreColumn} as score")
           ->from(TABLE_SEARCH_INDEX)
           ->where("MATCH(title,content) AGAINST('+{$against}' IN BOOLEAN MODE) >= 1")
           ->andWhere('status')->eq('normal')
           ->andWhere('addedDate')->le(helper::now())
           ->orderBy('score_desc, editedDate_desc')
           ->page($pager)
           ->fetchAll('id');*/
     $words = str_replace('_', '', $words);
     $results = $this->dao->select("*")->from(TABLE_SEARCH_INDEX)->where("title")->like("%{$words}%")->orWhere("content")->like("%{$words}%")->orderBy('editedDate_desc')->page($pager)->fetchAll();
     foreach ($results as $record) {
         $record->title = str_replace('</span> ', '</span>', $this->decode($this->markKeywords($record->title, $words)));
         $record->title = str_replace('_', '', $this->decode($this->markKeywords($record->title, $words)));
         $record->summary = $this->getSummary($record->content, $words);
         $record->summary = str_replace('_', '', $record->summary);
     }
     return $this->processLinks($results);
 }
Example #4
0
 public function action_leaderboard()
 {
     $active = DB::query(Database::SELECT, "\n\t        SELECT users.id, COUNT(talkreplies.user_id) as posts\n\t        FROM talkreplies\n\t        LEFT JOIN users ON users.id = talkreplies.user_id\n\t        GROUP BY talkreplies.user_id\n\t        ORDER BY posts DESC\n\t        LIMIT 10\n\t    ")->execute()->as_array();
     $streaks = ORM::factory('User')->order_by('current_streak', 'DESC')->limit(10)->find_all();
     $points = DB::query(Database::SELECT, "\n\t\t\tSELECT (SUM(page.points)+user.points) as points, page.user_id AS id FROM `pages` AS page\n\t\t\tJOIN `users` AS user ON user.id = page.user_id\n\t\t\tGROUP BY page.user_id\n\t\t\tORDER BY points DESC\n\t\t\tLIMIT 10\n\t\t")->execute()->as_array();
     seo::instance()->title("Morning Pages leaderboard");
     seo::instance()->description("Morning Pages leaderboard");
     $this->bind('active', $active);
     $this->bind('streaks', $streaks);
     $this->bind('points', $points);
 }
Example #5
0
 public function action_404()
 {
     seo::instance()->title("Page not found");
     seo::instance()->description("Morning Pages is about writing three pages of stream of consciousness thought every day. Become a better person by using MorninPages.net");
     $error = ORM::factory('Error');
     $error->type = '404';
     $error->url = URL::site(request::detect_uri() . (isset($_GET) && !empty($_GET) ? '?' . http_build_query($_GET) : ''), request::factory());
     $error->ip = $_SERVER['REMOTE_ADDR'];
     $error->client = $_SERVER['HTTP_USER_AGENT'];
     $error->server = serialize($_SERVER);
     $error->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     $error->time = time();
     $error->save();
     // 404 HTTP response
     $this->response->status(404);
 }
Example #6
0
 public function action_options()
 {
     $this->require_login(true);
     $errors = false;
     if ($_POST) {
         try {
             $user = user::get();
             $user->update_user($_POST, array('email', 'bio', 'website', 'password'));
             $user->save();
             $options = $user->option;
             $options->timezone_id = (int) arr::get($_POST, 'timezone_id', 152);
             $options->language = (int) arr::get($_POST, 'language', 1);
             $options->save();
             notes::success('Your info has been updated!');
             user::redirect('options');
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors('models');
         }
     }
     $this->bind('errors', $errors);
     seo::instance()->title("Morning Pages User Options");
     seo::instance()->description("Use these settings to adjust privacy levels, change writing settings, or more.");
 }
Example #7
0
 /**
  * Set upload configures.
  * 
  * @access public
  * @return void
  */
 public function setUpload()
 {
     if (!empty($_POST)) {
         $setting = fixer::input('post')->remove('allowedFiles')->setDefault('allowUpload', '0')->get();
         $dangers = explode(',', $this->config->file->dangers);
         $allowedFiles = trim(strtolower($this->post->allowedFiles), ',');
         $allowedFiles = str_replace($dangers, '', $allowedFiles);
         $allowedFiles = seo::unify($allowedFiles, ',');
         $allowedFiles = ',' . $allowedFiles . ',';
         $fileConfig = array('allowed' => $allowedFiles);
         $this->loadModel('setting')->setItems('system.common.file', $fileConfig);
         $result = $this->loadModel('setting')->setItems('system.common.site', $setting);
         $cache = $this->loadModel('cache')->createConfigCache();
         if (!$cache) {
             $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->error->noWritable, $this->app->getTmpRoot() . 'cache')));
         }
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('setupload')));
         }
         $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
     }
     $this->view->title = $this->lang->site->setBasic;
     $this->display();
 }
Example #8
0
$cat_info = $seo->getSectionByName($_GET['cat'], false, $direct_id);
if ($cat_info) {
    $catid = $cat_info['id'];
    $content_type = $content_type ? $content_type : 'dir';
} else {
    $catid = 0;
    $content_type = $content_type ? $content_type : 'direction';
}
$subdomains = $seo->getSubdomains();
$rpath = '../';
$countries = $seo->getCountries();
if (empty($_GET['subdomain']) && empty($_GET['direction']) || !empty($_GET['subdomain']) && empty($_GET['direction'])) {
    if (empty($_GET['subdomain'])) {
        $seo = new seo('all');
    } else {
        $seo = new seo($_GET['subdomain']);
    }
    $tmp_directions = $seo->getDirections();
    foreach ($tmp_directions as $direction) {
        $directions[$direction['id']] = $direction;
    }
    $sections = $seo->getSectionsForMain();
    $content = 'content-main.php';
} else {
    $content = 'content.php';
}
switch ($content_type) {
    case 'article':
        $page_title = $section_content['name_section'];
        break;
    case 'dir':
Example #9
0
 /**
  * Update a product.
  * 
  * @param  int $productID 
  * @access public
  * @return void
  */
 public function update($productID)
 {
     $product = fixer::input('post')->join('categories', ',')->stripTags('content,desc', $this->config->allowedTags->admin)->setDefault('price', 0)->setDefault('amount', 0)->setDefault('promotion', 0)->setDefault('unsaleable', 0)->add('editor', $this->app->user->account)->add('editedDate', helper::now())->get();
     $product->alias = seo::unify($product->alias, '-');
     $product->keywords = seo::unify($product->keywords, ',');
     $this->dao->update(TABLE_PRODUCT)->data($product, $skip = 'categories,uid,label,value')->autoCheck()->batchCheck($this->config->product->require->edit, 'notempty')->checkIF($product->mall, 'mall', 'URL')->where('id')->eq($productID)->exec();
     $attributes = $this->saveAttributes($productID);
     if ($attributes === false) {
         return false;
     }
     $this->loadModel('file')->updateObjectID($this->post->uid, $productID, 'product');
     $this->file->copyFromContent($this->post->content, $productID, 'product');
     if (dao::isError()) {
         return false;
     }
     $this->loadModel('tag')->save($product->keywords);
     $this->processCategories($productID, $this->post->categories);
     $product = $this->getByID($productID);
     if (empty($product)) {
         return false;
     }
     $product->attributes = $attributes;
     return $this->loadModel('search')->save('product', $product);
 }
Example #10
0
<!DOCTYPE html>
<html lang="en">
<head>
	<title>Morning Pages - Free online journaling platform</title>
	<?php 
/* <script src="//use.typekit.net/rod6iku.js"></script>
	<script>try{Typekit.load();}catch(e){}</script> */
?>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta content="Morning Pages" name="name">
	<meta content="<?php 
echo seo::instance()->description();
?>
" name="description">
	<meta name="google-site-verification" content="GRSH_5xF1zNVylG4dVPeMMzbAd-3x5snMapOlZwfNp8" />
	<link href="<?php 
echo URL::site('media/img/favicon.ico');
?>
" rel="shortcut icon" />
	<link rel="apple-touch-icon" href="<?php 
echo URL::site('media/img/favicon.png');
?>
" />
	<link rel="stylesheet" type="text/css" id="mainstyles" href="<?php 
echo URL::site('media/css/style.css');
?>
" />
</head>
<?php 
$theme = '';
Example #11
0
          </ul>
        </li>
      <?php 
            $grnum++;
        }
    }
    //foreach
    ?>
      <?php 
}
?>
      <?php 
if ($direct_id) {
    ?>
      <li class="all-employers"><span class="wrap-item"><a href="<?php 
    echo seo::getFriendlyURL($subdomain, '', '');
    ?>
">Все направления</a></span></li>
      <?php 
}
?>
      </ul>
    <b class="b2"></b>
    <b class="b1"></b>
    </div>
    <script type="text/javascript">asynccall('initCtg(<?php 
echo isset($gr_show) ? $gr_show : -1;
?>
)');</script>

  
Example #12
0
 public function action_faq()
 {
     seo::instance()->title("Morning Pages Questions");
     seo::instance()->description("Frequently asked questions regarding your Morning Pages, the Morning Pages website, and more. Don't see your listed? Check the Morning Pages forum for more info.");
 }
Example #13
0
 /**
  * Update an article.
  * 
  * @param string   $articleID 
  * @access public
  * @return void
  */
 public function update($articleID, $type = 'article')
 {
     $article = $this->getByID($articleID);
     $category = array_keys($article->categories);
     $article = fixer::input('post')->stripTags('content,link', $this->config->allowedTags->admin)->join('categories', ',')->add('editor', $this->app->user->account)->add('editedDate', helper::now())->setIF(!$this->post->isLink, 'link', '')->get();
     $article->keywords = seo::unify($article->keywords, ',');
     $article->alias = seo::unify($article->alias, '-');
     $article->content = $this->rtrimContent($article->content);
     $this->dao->update(TABLE_ARTICLE)->data($article, $skip = 'categories,uid,isLink')->autoCheck()->batchCheckIF($type != 'page' and !$this->post->isLink, $this->config->article->require->edit, 'notempty')->batchCheckIF($type == 'page' and !$this->post->isLink, $this->config->article->require->page, 'notempty')->batchCheckIF($type != 'page' and $this->post->isLink, $this->config->article->require->link, 'notempty')->batchCheckIF($type == 'page' and $this->post->isLink, $this->config->article->require->pageLink, 'notempty')->checkIF($type == 'page' and $this->post->alias, 'alias', 'unique', "type='page' and id<>{$articleID}")->where('id')->eq($articleID)->exec();
     $this->loadModel('file')->updateObjectID($this->post->uid, $articleID, $type);
     $this->file->copyFromContent($this->post->content, $articleID, $type);
     if (dao::isError()) {
         return false;
     }
     $this->loadModel('tag')->save($article->keywords);
     if ($type != 'page') {
         $this->processCategories($articleID, $type, $this->post->categories);
     }
     if (dao::isError()) {
         return false;
     }
     $article = $this->getByID($articleID);
     if (empty($article)) {
         return false;
     }
     return $this->loadModel('search')->save($type, $article);
 }
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stdf.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/seo.php';
/*
 * Исправление сбитых позиций в SEO-каталоге /catalog/ 
 */
$sql = 'SELECT parent FROM seo_sections 
        WHERE parent <> 0 
        GROUP BY parent 
        HAVING COUNT(parent) <> MAX(pos_num) OR MIN(pos_num) <> 1';
$parents = $DB->rows($sql);
$seo = new seo();
if ($parents) {
    foreach ($parents as $k => $v) {
        $sql = "SELECT id FROM seo_sections WHERE parent = {$v['parent']} ORDER BY id ASC";
        $rows = $DB->rows($sql);
        if ($rows) {
            foreach ($rows as $i => $row) {
                $info['pos_num'] = $i + 1;
                $seo->updateSection($row['id'], $info);
            }
            echo "Update parent - {$v['parent']}<br/>";
        }
    }
}
Example #15
0
<div class="b-menu b-menu_seo b-menu_padtop_20 b-menu_padbot_20 b-menu_bordtop_b2">
	<div class="b-menu__inner">
		<h3 class="b-menu__h4 b-menu__h4_padbot_10">О разделах каталога фрилансеров:</h3>
		<table class="b-menu__table b-menu__table_width_full" cellpadding="0" cellspacing="0" border="0">
			<tbody>
			<?php 
$n = 1;
foreach ($seo_catalog_data as $seo_direct) {
    if ($n == 1) {
        echo '<tr class="b-menu__tr">';
    }
    echo '<td class="b-menu__td b-menu__td_padright_20 b-menu__td_padbot_10"><a class="b-menu__link b-menu__link_fontsize_11" href="' . seo::getFriendlyURL('', $seo_direct['name_section_link'], '') . '">' . reformat($seo_direct['dir_name']) . '</a></td>';
    if ($n == 8) {
        echo '</tr>';
        $n = 1;
    } else {
        $n++;
    }
}
if ($n != 1) {
    for ($i = $n; $i <= 8; $i++) {
        echo '<td class="b-menu__td b-menu__td_padright_20 b-menu__td_padbot_10">&nbsp;</td>';
    }
    echo '</tr>';
}
?>
			</tbody>
		</table>
	</div>
</div>
     $smarty->assignByRef('langs', $langs);
     // список доступных локализаций
     // URL где находится форма менеджера SEO
     $seoUrl = '?m=users&s=companies&action=seo';
     $smarty->assignByRef('seoUrl', $seoUrl);
     if (isset($_POST['save'])) {
         unset($_POST['save']);
         if (!empty($_POST)) {
             foreach ($_POST as $key => $val) {
                 $file = str_replace("_", ".", $key);
                 seo::saveSeoFile($file, $val, $currLang);
             }
             messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . $seoUrl);
         }
     }
     $smarty->assign('seo', seo::getSeoFiles('companies', $currLang));
 } else {
     /**
      * Действия
      */
     if (!empty($_POST['action'])) {
         // отображение на главной
         if ('show' === $_POST['action'] && !empty($_POST['companies'])) {
             $user->updateConfUser(array('main_logo' => 1), 'id IN (' . implode(',', secure::escQuoteData(array_keys($_POST['companies']))) . ')');
             messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . '?m=users&s=companies');
         }
         // удаление с главной
         if ('remove' === $_POST['action'] && !empty($_POST['companies'])) {
             $user->updateConfUser(array('main_logo' => 0), 'id IN (' . implode(',', secure::escQuoteData(array_keys($_POST['companies']))) . ')');
             messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . '?m=users&s=companies');
         }
Example #17
0
function deleteDirection($id)
{
    session_start();
    if (!hasPermissions('seo')) {
        return false;
    }
    $objResponse = new xajaxResponse();
    $id = intval($id);
    if (!$id) {
        $objResponse->alert('Идентификатор направления не указан');
        return $objResponse;
    }
    $seo = new seo();
    if (!$seo->deleteDirection($id)) {
        $objResponse->alert('Ошибка удаления');
        return $objResponse;
    }
    $objResponse->redirect('/catalog/admin/?direction=-1');
    return $objResponse;
}
Example #18
0
 public function action_index()
 {
     seo::instance()->title("Morning Pages");
     seo::instance()->description("Morning Pages is a website in which users write three pages of stream of consciousness thought and earn rewards, gain self-enlightenment, and most importantly, have fun! Begin writing with no registration!");
 }
Example #19
0
<?php

chdir(dirname(__FILE__));
require_once '../classes/stdf.php';
require_once '../classes/seo.php';
$seo = new seo();
$directions = $seo->getDirections($direct_id);
$res = $seo->getSections(true, $direct_id);
$sections = array();
if ($res) {
    foreach ($res as $row) {
        $sections[$row['direct_id']][] = $row;
    }
}
$subdomains = $seo->getSubdomains(true);
foreach ($subdomains as $subdomain) {
    $f = fopen("./seo-data-{$subdomain['subdomain']}.csv", "w");
    foreach ($directions as $direction) {
        if ($direction['id'] != 2 && $direction['id'] != 19 && $direction['id'] != 18 && $direction['id'] != 20 && $direction['id'] != 21 && $direction['id'] != 11 && $direction['id'] != 1) {
            fwrite($f, '"-' . $direction['dir_name'] . "\"\n");
            if ($sections[$direction['id']]) {
                foreach ($sections[$direction['id']] as $key => $section) {
                    fwrite($f, '"--' . $section['name_section'] . "\"\n");
                    if ($section['subsection']) {
                        foreach ($section['subsection'] as $i => $subsection) {
                            if ($subsection['subdomain_id'] == $subdomain['id']) {
                                fwrite($f, '"---' . $subsection['name_section'] . "\"\n");
                            }
                        }
                    }
                }
Example #20
0
 /**
  * Unify keywords of article, product and category, count tag's rank and save.
  *
  * @access public
  * @return void
  */
 public function processTag()
 {
     $tags = '';
     $articles = $this->dao->select('id, keywords')->from(TABLE_ARTICLE)->fetchPairs('id', 'keywords');
     foreach ($articles as $id => $keywords) {
         $keywords = seo::unify($keywords, ',');
         $this->dao->update(TABLE_ARTICLE)->set('keywords')->eq($keywords)->where('id')->eq($id)->exec();
         $tags = $keywords;
     }
     $products = $this->dao->select('id, keywords')->from(TABLE_PRODUCT)->fetchPairs('id', 'keywords');
     foreach ($products as $id => $keywords) {
         $keywords = seo::unify($keywords, ',');
         $this->dao->update(TABLE_PRODUCT)->set('keywords')->eq($keywords)->where('id')->eq($id)->exec();
         $tags .= ',' . $keywords;
     }
     $categories = $this->dao->select('id, keywords')->from(TABLE_CATEGORY)->fetchPairs('id', 'keywords');
     foreach ($categories as $id => $keywords) {
         $keywords = seo::unify($keywords, ',');
         $this->dao->update(TABLE_CATEGORY)->set('keywords')->eq($keywords)->where('id')->eq($id)->exec();
         $tags .= ',' . $keywords;
     }
     $this->loadModel('tag')->save($tags);
 }
Example #21
0
 public function action_talk()
 {
     $tag = $this->request->param('tag');
     $talk = $this->request->param('talk');
     if (user::logged()) {
         // Iterate views
         if ($talk->user_id != user::get()->id) {
             $talk->views = $talk->views + 1;
             try {
                 $talk->save();
             } catch (ORM_Validation_Exception $e) {
                 //var_dump($e->errors());
             }
         }
         // Set when the user last saw the topic
         $user = user::get();
         $viewed = $user->talkviews->where('talk_id', '=', $talk->id)->find();
         if (!$viewed->loaded()) {
             $viewed->user_id = $user->id;
             $viewed->talk_id = $talk->id;
         }
         $viewed->last = time();
         $viewed->save();
     }
     $replies = $talk->replies->where('op', '!=', 1);
     $counter = $talk->replies->where('op', '!=', 1);
     $limit = Kohana::$config->load('talk')->get('pagination_limit');
     $numreplies = $counter->count_all();
     $numpages = ceil($numreplies / $limit);
     $page = (int) arr::get($_GET, 'page', 0);
     if ($_POST) {
         $this->require_login();
         $reply = ORM::factory('Talkreply');
         $reply->values($_POST);
         $reply->user_id = user::get()->id;
         $reply->talk_id = $talk->id;
         try {
             $reply->save();
             $page = $numpages;
             $talk->last_reply = time();
             $talk->save();
             $subscriptions = $talk->subscriptions->find_all();
             if ((bool) $subscriptions->count()) {
                 foreach ($subscriptions as $subscription) {
                     if ($subscription->user_id != $reply->user_id) {
                         mail::create('talkreplyposted')->to($subscription->user->email)->tokenize(array('username' => $subscription->user->username, 'sendername' => $reply->user->username, 'title' => $talk->title, 'reply' => $reply->content, 'link' => HTML::anchor(URL::site($talk->url() . '?page=' . $page . '#comment-' . $reply->id, 'http'), $talk->title)))->send();
                     }
                 }
             }
             $vote = ORM::factory('User_Talkvote');
             $vote->type = 'talkreply';
             $vote->user_id = user::get()->id;
             $vote->object_id = $reply->id;
             $vote->save();
             notes::success('Your reply has been posted.');
             site::redirect($talk->url() . '?page=' . $page . '#comment-' . $reply->id);
         } catch (ORM_Validation_Exception $e) {
             notes::error('Whoops! Your submission contained errors. Please review it and submit again');
             $errors = $e->errors();
         }
     }
     if ($page < 1) {
         $page = 1;
     }
     if ($page > $numpages) {
         $page = $numpages;
     }
     $replies = $replies->limit($limit);
     if ($page - 1 > 0) {
         $replies = $replies->offset($limit * ($page - 1));
     }
     $replies = $replies->find_all();
     $this->bind('tag', $tag);
     $this->bind('talk', $talk);
     $this->bind('replies', $replies);
     $this->bind('tags', ORM::factory('Talktag')->find_all());
     $this->bind('numpages', $numpages);
     $this->bind('currentpage', $page);
     seo::instance()->title($talk->title);
     seo::instance()->description("Talk About Morning Pages, or anything else you might find interesting. Use this area to ask questions, make friends, or find out information about Morning Pages.");
 }
Example #22
0
    ?>
">登录</a><a class="reg" href="<?php 
    echo IUrl::creatUrl("/simple/reg?callback=" . $callback . "");
    ?>
">免费注册</a>]
			<?php 
}
?>
			</p>
		</div>
	    <?php 
$seo_data = array();
$site_config = new Config('site_config');
$site_config = $site_config->getInfo();
$seo_data['title'] = "用户登录_" . $site_config['name'];
seo::set($seo_data);
?>
<div class="wrapper clearfix">
	<div class="wrap_box">
		<h3 class="notice">已注册用户,请登录</h3>
		<p class="tips">欢迎来到我们的网站,如果您已是本站会员请登录</p>
		<div class="box login_box clearfix">
			<form action='<?php 
echo IUrl::creatUrl("/simple/login_act");
?>
' method='post'>
				<input type="hidden" name='callback' />
				<table width="515" class="form_table f_l">
					<col width="120px" />
					<col />
Example #23
0
 /**
  * Parse SEO URI for setRouteByPathInfo.
  *
  * @param uri
  * return string
  */
 public static function parseURI($uri)
 {
     global $config;
     if (!helper::inSeoMode()) {
         return $uri;
     }
     $categoryAlias = $config->seo->alias->category;
     $pageAlias = $config->seo->alias->page;
     $forumAlias = isset($config->seo->alias->forum) ? $config->seo->alias->forum : array();
     $methodAlias = $config->seo->alias->method;
     $params = array();
     if (strpos($uri, '_') !== false) {
         $uri = substr($uri, 0, strpos($uri, '_'));
     }
     /* Is there a pageID variable in the url?  */
     $pageID = 0;
     if (preg_match('/\\/p\\d+$/', $uri, $matches)) {
         $pageID = str_replace('/p', '', $matches[0]);
         // Get pageID thus the flowing logic can use it.
         $uri = str_replace($matches[0], '', $uri);
         // Remove the pageID part from the url.
     }
     /* Split uri to items and try to get module and params from it. */
     $items = explode('/', $uri);
     $module = $items[0];
     /* Use book instead of help. */
     if ($module == 'help') {
         $module = $items[0] = 'book';
     }
     /* There's no '/' in uri. */
     if (strpos($uri, '/') === false) {
         /* Use book instead of help. */
         if ($uri == 'help') {
             $uri = 'book';
         }
         if ($pageID and $module == 'blog' and count($items) == 1) {
             $params['category'] = 0;
             return seo::convertURI($module, 'index', $params, $pageID);
         }
         /* Not an alias, return directly. */
         if (empty($categoryAlias[$uri])) {
             return $uri;
         }
         /* The module is an alias of a category. */
         $module = $categoryAlias[$uri]->module;
         $params['category'] = $categoryAlias[$uri]->category;
         return seo::convertURI($module, 'browse', $params, $pageID);
     }
     /* Is the module an alias of a category? */
     if (isset($categoryAlias[$module])) {
         $category = $categoryAlias[$module]->category;
         // Get the category.
         $module = $categoryAlias[$module]->module;
         // Get the module of the alias category.
         /* If the first param is number, like article/123.html, should call view method. */
         if (is_numeric($items[1])) {
             $params['id'] = $items[1];
             return seo::convertURI($module, 'view', $params, $pageID);
         } else {
             if (!empty($items[1])) {
                 $viewparams = explode('-', $items[1]);
                 $id = end($viewparams);
             }
             if (is_numeric($id)) {
                 $params['id'] = $id;
                 return seo::convertURI($module, 'view', $params, $pageID);
             }
         }
         $params['category'] = $category;
         return seo::convertURI($module, 'browse', $params, $pageID);
     }
     //------------- The module is an system module-------------- */
     /* Is the module an alias of a page. */
     if ($module == 'page' && isset($pageAlias[$items[1]])) {
         $params['page'] = $items[1];
         return seo::convertURI($module, 'view', $params, $pageID);
     }
     if ($module == 'page' && !isset($pageAlias[$items[1]])) {
         $params['page'] = $items[1];
         return seo::convertURI($module, 'view', $params, $pageID);
     }
     if ($module == 'book' && count($items) > 2) {
         $uri = str_replace('/' . $items[1], '', $uri);
         $items[1] = $items[2];
     }
     if ($module == 'forum' && isset($pageAlias[$items[1]])) {
         $method = $methodAlias[$module]['browse'];
         return seo::convertURI($module, $method, $params, $pageID);
     }
     /*  If the first param is a category id, like news/c123.html. */
     if (preg_match('/^c\\d+$/', $items[1])) {
         $params['category'] = str_replace('c', '', $items[1]);
         $method = $methodAlias[$module]['browse'];
         return seo::convertURI($module, $method, $params, $pageID);
     }
     /* The first param is an object id. */
     if (is_numeric($items[1])) {
         $params['id'] = $items[1];
         $method = $methodAlias[$module]['view'];
         return seo::convertURI($module, $method, $params, $pageID);
     }
     $viewparams = explode('-', $items[1]);
     if (count($viewparams) > 1) {
         $id = end($viewparams);
         if (is_numeric($id)) {
             $params['id'] = $id;
             $method = $methodAlias[$module]['view'];
             return seo::convertURI($module, $method, $params, $pageID);
         }
     } else {
         /* The first param is a category alias. */
         $params['category'] = $items[1];
     }
     $method = isset($methodAlias[$module]['browse']) ? $methodAlias[$module]['browse'] : 'browse';
     return seo::convertURI($module, $method, $params, $pageID);
 }
Example #24
0
 /**
  * Manage children of one category.
  * 
  * @param string $type 
  * @param string $children 
  * @access public
  * @return void
  */
 public function manageChildren($type, $parent, $children)
 {
     /* Get parent. */
     $parent = $this->getByID($parent);
     /* Init the category object. */
     $category = new stdclass();
     $category->parent = $parent ? $parent->id : 0;
     $category->grade = $parent ? $parent->grade + 1 : 1;
     $category->type = $type;
     $category->postedDate = helper::now();
     $i = 1;
     foreach ($children as $key => $categoryName) {
         $alias = $this->post->alias[$key];
         $alias = seo::unify($alias, '-');
         $order = $i * 10;
         if (empty($categoryName)) {
             continue;
         }
         /* First, save the child without path field. */
         $category->name = $categoryName;
         $category->alias = $alias;
         $category->order = $order;
         $mode = $this->post->mode[$key];
         /* Add id to check alias. */
         $category->id = $mode == 'new' ? 0 : ($category->id = $key);
         if (!$this->checkAlias($category)) {
             return sprintf($this->lang->tree->aliasRepeat, $alias);
         }
         if ($category->type == 'forum' or $category->type == 'blog') {
             if (is_numeric($category->alias)) {
                 return $this->lang->tree->aliasNumber;
             }
         }
         if ($mode == 'new') {
             unset($category->id);
             $this->dao->insert(TABLE_CATEGORY)->data($category)->exec();
             /* After saving, update it's path. */
             $categoryID = $this->dao->lastInsertID();
             $categoryPath = $parent ? $parent->path . $categoryID . ',' : ",{$categoryID},";
             $this->dao->update(TABLE_CATEGORY)->set('path')->eq($categoryPath)->where('id')->eq($categoryID)->exec();
         } else {
             $categoryID = $key;
             $this->dao->update(TABLE_CATEGORY)->set('name')->eq($categoryName)->set('alias')->eq($alias)->set('order')->eq($order)->where('id')->eq($categoryID)->exec();
         }
         $i++;
     }
     return !dao::isError();
 }
Example #25
0
 public function index()
 {
     $itemId = intval(input::get('item_id'));
     if (empty($itemId)) {
         return redirect::action('topc_ctl_default@index');
     }
     if (userAuth::check()) {
         $pagedata['nologin'] = 1;
     }
     $pagedata['user_id'] = userAuth::id();
     $pagedata['image_default_id'] = $this->__setting();
     $params['item_id'] = $itemId;
     $params['fields'] = "*,item_desc.pc_desc,item_count,item_store,item_status,sku,item_nature,spec_index";
     $detailData = app::get('topc')->rpcCall('item.get', $params);
     if (!$detailData) {
         $pagedata['error'] = "很抱歉,您查看的宝贝不存在,可能已下架或者被转移";
         return $this->page('topc/items/error.html', $pagedata);
     }
     if (count($detailData['sku']) == 1) {
         $detailData['default_sku_id'] = array_keys($detailData['sku'])[0];
     }
     $detailData['valid'] = $this->__checkItemValid($detailData);
     //判断此商品发布的平台,如果是wap端,跳转至wap链接
     if ($detailData['use_platform'] == 2) {
         redirect::action('topm_ctl_item@index', array('item_id' => $itemId))->send();
         exit;
     }
     //相册图片
     if ($detailData['list_image']) {
         $detailData['list_image'] = explode(',', $detailData['list_image']);
     }
     //获取商品的促销信息
     $promotionDetail = app::get('topc')->rpcCall('item.promotiontag.get', array('item_id' => $itemId));
     if ($promotionDetail) {
         $promotionIds = explode(',', $promotionDetail['promotion_ids']);
         foreach ($promotionIds as $promotionId) {
             $basicPromotionInfo = app::get('topc')->rpcCall('promotion.promotion.get', array('promotion_id' => $promotionId, 'platform' => 'pc'));
             if ($basicPromotionInfo['valid'] === true) {
                 $pagedata['promotionDetail'][$promotionId] = $basicPromotionInfo;
             }
         }
     }
     $pagedata['promotion_count'] = count($pagedata['promotionDetail']);
     // 活动促销(如名字叫团购)
     $activityDetail = app::get('topc')->rpcCall('promotion.activity.item.info', array('item_id' => $itemId, 'valid' => 1), 'buyer`');
     if ($activityDetail) {
         $pagedata['activityDetail'] = $activityDetail;
     }
     $detailData['spec'] = $this->__getSpec($detailData['spec_desc'], $detailData['sku']);
     $detailData['qrCodeData'] = $this->__qrCode($itemId);
     $pagedata['item'] = $detailData;
     //获取商品详情页左侧店铺分类信息
     $pagedata['shopCat'] = app::get('topc')->rpcCall('shop.cat.get', array('shop_id' => $pagedata['item']['shop_id']));
     //获取该商品的店铺信息
     $pagedata['shop'] = app::get('topc')->rpcCall('shop.get', array('shop_id' => $pagedata['item']['shop_id']));
     //获取该商品店铺的DSR信息
     $pagedata['shopDsrData'] = $this->__getShopDsr($pagedata['item']['shop_id']);
     $pagedata['next_page'] = url::action("topc_ctl_item@index", array('item_id' => $itemId));
     if ($pagedata['user_id']) {
         //获取该用户的最近购买记录
         $pagedata['buyerList'] = app::get('topc')->rpcCall('trade.user.buyerList', array('user_id' => $pagedata['user_id']));
     }
     //设置此页面的seo
     $brand = app::get('topc')->rpcCall('category.brand.get.info', array('brand_id' => $detailData['brand_id']));
     $cat = app::get('topc')->rpcCall('category.cat.get.info', array('cat_id' => $detailData['cat_id']));
     $seoData = array('item_title' => $detailData['title'], 'shop_name' => $pagedata['shop']['shop_name'], 'item_brand' => $brand['brand_name'], 'item_bn' => $detailData['bn'], 'item_cat' => $cat[$detailData['cat_id']]['cat_name'], 'sub_title' => $detailData['sub_title']);
     seo::set('topc.item.detail', $seoData);
     //echo '<pre>';print_r($pagedata);exit();
     return $this->page('topc/items/index.html', $pagedata);
 }
Example #26
0
 /**
  * Update a node.
  *
  * @param int $nodeID
  * @access public
  * @return bool
  */
 public function update($nodeID)
 {
     $oldNode = $this->getNodeByID($nodeID);
     $node = fixer::input('post')->add('id', $nodeID)->add('editor', $this->app->user->account)->add('editedDate', helper::now())->setForce('keywords', seo::unify($this->post->keywords, ','))->setForce('alias', seo::unify($this->post->alias, '-'))->setForce('type', $oldNode->type)->stripTags('content', $this->config->allowedTags->admin)->get();
     $this->dao->update(TABLE_BOOK)->data($node, $skip = 'uid,referer')->autoCheck()->batchCheckIF($node->type == 'book', $this->config->book->require->book, 'notempty')->batchCheckIF($node->type != 'book', $this->config->book->require->node, 'notempty')->checkIF($node->type == 'book', 'alias', 'unique', "`type` = 'book' AND id != '{$nodeID}'")->where('id')->eq($nodeID)->exec();
     if (dao::isError()) {
         return false;
     }
     $this->fixPath($oldNode->book->id);
     if (dao::isError()) {
         return false;
     }
     $this->loadModel('tag')->save($node->keywords);
     if (dao::isError()) {
         return false;
     }
     if ($node->type == 'article') {
         $this->loadModel('file')->updateObjectID($this->post->uid, $nodeID, 'book');
         $this->file->copyFromContent($this->post->content, $nodeID, 'book');
         if (dao::isError()) {
             return false;
         }
     }
     $book = $this->getNodeByID($nodeID);
     return $this->loadModel('search')->save('book', $book);
 }
Example #27
0
 /**
  * Set upload configures.
  *
  * @access public
  * @return void
  */
 public function setUpload()
 {
     $this->lang->site->menu = $this->lang->security->menu;
     $this->lang->menuGroups->site = 'security';
     $this->loadModel('file');
     if (!empty($_POST)) {
         $setting = fixer::input('post')->remove('allowedFiles,thumbs')->setDefault('allowUpload', '0')->get();
         $dangers = explode(',', $this->config->file->dangers);
         $allowedFiles = trim(strtolower($this->post->allowedFiles), ',');
         $allowedFiles = str_replace($dangers, '', $allowedFiles);
         $allowedFiles = seo::unify($allowedFiles, ',');
         if (!preg_match('/^[a-z0-9,]+$/', $allowedFiles)) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
         }
         $allowedFiles = explode(',', $allowedFiles);
         foreach ($allowedFiles as $extension) {
             if (strlen($extension) > 5) {
                 $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
             }
         }
         $allowedFiles = implode(',', $allowedFiles);
         foreach ($dangers as $danger) {
             if (strpos($allowedFiles, $danger) !== false) {
                 $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
             }
         }
         $allowedFiles = ',' . $allowedFiles . ',';
         $result = $this->loadModel('setting')->setItem('system.common.file.allowed', $allowedFiles);
         if (!$result) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
         }
         $result = $this->loadModel('setting')->setItems('system.common.site', $setting);
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('setupload')));
         }
         $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
     }
     $this->view->title = $this->lang->site->setUpload;
     $this->display();
 }
Example #28
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/seo.php";
session_start();
if (!hasPermissions('seo')) {
    header("Location: /404.php");
    exit;
}
/**
 * @todo $_GET['subdomain'] сделано дл¤ тестировани¤, скорей всего при разборе URI апачем можно будет писать в эту переменную поддомен 
 */
$_SESSION['subdomain'] = $subdomain = $_GET['subdomain'] ? $_GET['subdomain'] : 'all';
$seo = new seo($subdomain);
$countries = $seo->getCountries();
$direct_link = $direct_id = __paramInit('string', 'direction');
if ($direct_link) {
    $direct = $seo->getDirectionByLink($direct_link);
    $direct_id = null;
    if ($direct['id']) {
        $direct_id = $direct['id'];
    }
} else {
    $direct_id = $seo->getDirectionIdFirst();
}
if (intval($direct_link) == -1) {
    $direct_id = -1;
}
switch ($_GET['msgok']) {
    case 1:
        $is_save = true;
        $msgtext = '–аздел успешно добавлен';
 /**
  * Fill in default values for our properties before rendering the output.
  */
 public function after()
 {
     parent::after();
     if ($this->auto_render === TRUE) {
         // Add custom CSS if enabld and front controller
         if (is_subclass_of($this, 'Auth_Controller') === FALSE and ($custom_css = Theme::get_custom_css()) !== FALSE) {
             Theme::$styles = array_merge(Theme::$styles, array($custom_css => 'screen'));
         }
         //cookie consent
         if (Core::config('general.cookie_consent') == 1) {
             Theme::$styles = array_merge(Theme::$styles, array('css/jquery.cookiebar.css' => 'screen'));
             $this->template->scripts['footer'][] = 'js/jquery.cookiebar.js';
             $this->template->scripts['footer'][] = Route::url('default', array('controller' => 'jslocalization', 'action' => 'cookieconsent'));
         }
         //adblock detection
         if (Core::config('general.adblock') == 1) {
             Theme::$styles = array_merge(Theme::$styles, array('css/adi.js/jquery.adi.css' => 'screen'));
             Theme::$scripts['footer'][] = 'js/advertisement.js';
             Theme::$scripts['footer'][] = 'js/jquery.adi.js';
             $this->template->scripts['footer'][] = Route::url('default', array('controller' => 'jslocalization', 'action' => 'adi'));
         }
         // Add defaults to template variables.
         $this->template->styles = array_merge_recursive(Theme::$styles, $this->template->styles);
         $this->template->scripts = array_reverse(array_merge_recursive(Theme::$scripts, $this->template->scripts));
         //in case theres no description given
         if ($this->template->meta_description == '') {
             $this->template->meta_description = $this->template->title;
         }
         //title concatenate the site name
         if ($this->template->title != '') {
             $this->template->title .= ' - ';
         }
         $this->template->title .= core::config('general.site_name');
         //auto generate keywords and description from content
         seo::$charset = Kohana::$charset;
         $this->template->title = seo::text($this->template->title, 70);
         //not meta keywords given
         //remember keywords are useless :( http://googlewebmastercentral.blogspot.com/2009/09/google-does-not-use-keywords-meta-tag.html
         if ($this->template->meta_keywords == '') {
             $this->template->meta_keywords = seo::keywords($this->template->meta_description);
         }
         $this->template->meta_description = seo::text($this->template->meta_description);
     }
     $this->response->body($this->template->render());
 }
Example #30
0
<?php

if (!dyn::get('backend')) {
    extension::add('URL_REWRITE', function ($return) {
        return seo_rewrite::rewriteId($return['id']);
    });
    $seo = new seo_rewrite();
    $id = $seo->parseUrl($_SERVER['REQUEST_URI']);
    seo::setPageId($id);
} else {
    $page = type::super('page', 'string');
    $subpage = type::super('subpage', 'string');
    $action = type::super('action', 'string');
    $structure_id = type::super('structure_id', 'int', 0);
    $id = type::super('id', 'int', 0);
    // Falls was an der Page geändert worden ist
    if ($page == 'structure' && $subpage == 'pages' && in_array($action, ['add', 'edit', 'seo']) && !$structure_id) {
        extension::add('FORM_AFTER_SAVE', function ($form) {
            seo_rewrite::generatePathlist();
            return $form;
        });
    }
    // Wenn SEO Button geklickt worden ist
    if ($page == 'structure' && $subpage == 'pages' && $action == 'seo') {
        seoPage::generateForm($id);
        layout::addJsCode("\n\t\tvar default_url = \$('#seo-costum-url').text();\n\t\t\n\t\t\$('#seo-costum-url-text').keyup(function() {\n\t\t\tvar val = \$(this).val();\n\t\t\t\n\t\t\tif(val == '')\n\t\t\t\tval = default_url;\n\t\t\t\t\t\t\t\n\t\t\t\$('#seo-costum-url').text(val);\n\t\t});\n\t\t\n\t\tvar default_title = \$('#seo-default-title').text();\n\t\t\$('#seo-title-text').keyup(function() {\n\t\t\tvar val = \$(this).val();\n\t\t\t\n\t\t\tif(val == '')\n\t\t\t\tval = default_title;\n\t\t\t\n\t\t\t\$('#seo-title').text(val);\n\t\t});\n\t\t");
    }
    // Wenn Sortiert worden ist
    if ($page == 'structure' && $subpage == 'pages' && (ajax::is() || $action == 'delete' && !$structure_id)) {
        extension::add('BACKEND_OUTPUT', function ($output) {
            seo_rewrite::generatePathlist();