CVE-2017-5345 (PHP, published 2017-01-12T06:59Z)
Description: value: SQL injection vulnerability in inc/lib/Control/Ajax/tags-ajax.control.php in GeniXCMS 0.0.8 allows remote authenticated editors to execute arbitrary SQL commands via the term parameter to the default URI.
Severity: MEDIUM (CVSS v3 base score: 8.8)
Weakness: CWE-89 \u2014 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
Repository: https://github.com/semplon/GeniXCMS
Files changed:
assets/js/plugins/summernote-ext-genixcms.js
gxadmin/inc/media.php
gxadmin/inc/pages_form.php
gxadmin/inc/posts_form.php
inc/lib/Categories.class.php
inc/lib/Comments.class.php
inc/lib/Control.class.php
inc/lib/Control/Ajax/saveimage-ajax.control.php
inc/lib/Control/Ajax/tags-ajax.control.php
inc/lib/Control/Ajax/version-ajax.control.php
inc/lib/Control/Backend/mods.control.php
inc/lib/Control/Backend/posts.control.php
inc/lib/Control/Backend/themes.control.php
inc/lib/Control/Backend/users.control.php
inc/lib/Control/Frontend/author.control.php
inc/lib/Control/Frontend/cat.control.php
inc/lib/Control/Frontend/post.control.php
inc/lib/Control/Frontend/tag.control.php
inc/lib/Control/Frontend/thumb.control.php
inc/lib/Hooks.class.php
inc/lib/Mod.class.php
inc/lib/Posts.class.php
inc/lib/Router.class.php
inc/lib/Theme.class.php
inc/lib/Url.class.php
inc/lib/User.class.php
inc/themes/default/options.php
inc/themes/gneex/author.php
inc/themes/gneex/cat.php
inc/themes/gneex/css/style.css
inc/themes/gneex/fullwidth.php
inc/themes/gneex/function.php
inc/themes/gneex/index.php
inc/themes/gneex/options.php
inc/themes/gneex/single.php
register.php
Commit message: Add Post Param at Hooks
Filter Categories for Tags
Change $url position to correct location at Comments.class.php
Add Author Pages
#60 Security Fix Issue
Change Ajax URL Router format
Change Ajax, Mods router scrapper


Vulnerable code:
                        elfinderDialog();
if (isset($data['alertSuccess'])) {
    
    echo '<div class="alert alert-success" >
    <button type="button" class="close" data-dismiss="alert">
        <span aria-hidden="true">&times;</span>
        <span class="sr-only">'.CLOSE.'</span>
    </button>';
    foreach ($data['alertSuccess'] as $alert) {
        
        echo "$alert\n";
    }
    echo '</div>';
}
if (isset($data['alertDanger'])) {
    
    echo '<div class="alert alert-danger" >
    <button type="button" class="close" data-dismiss="alert">
        <span aria-hidden="true">&times;</span>
        <span class="sr-only">'.CLOSE.'</span>
    </button>';
    foreach ($data['alertDanger'] as $alert) {
        
        echo "$alert\n";
    }
    echo '</div>';
}
        <div class="row">
            <div id="elfinder"></div>
        </div>



                $where .= '1 ';
                $where .= " AND `type` = '".$vars['type']."' ";
                $where .= '';
                $where .= " `type` = '{$vars['type']}' AND ";
        $sql = "SELECT `id` FROM `cat` WHERE `id` = '{$cat}' AND `type` = 'post'";
        $url = isset($v->url) ? $v->url : '#';
        $arr = ['ajax', 'post', 'page', 'cat', 'mod', 'sitemap', 'rss',
                    'account', 'search', 'author', 'tag', 'thumb', 'default'];

if (isset($_GET['token']) && Token::isExist($_GET['token'])) {

if (isset($_GET['token']) && Token::isExist($_GET['token'])) {
            "SELECT * FROM `cat` WHERE `type` = 'tag' AND `name` LIKE '".$_GET['term']."%' ORDER BY `name` ASC"
if (isset($_GET['token']) && Token::isExist($_GET['token'])) {
$data['sitetitle'] = MODULES;
Mod::options($_GET['mod']);

        $data['sitetitle'] = THEMES;
        Theme::options(Options::v('themes'));
                    if (!User::isExist($_POST['userid'])) {
                        if (!User::isExist($_POST['userid'])) {
                    'where' => '`type` = \''.$type.'\' AND `cat` = \''.$cat.'\'',
    $theme = ($data['p_type'] == 'post') ? 'single' : $data['p_type'];
    Theme::footer();
                'where' => '`type` = \''.$type.'\' ',
    Theme::footer();
                'init' => array(), // init the system
                'header_pre_action' => array(), // action before load header
                'site_title_filter' => array(), // filter website title
                'site_desc_filter' => array(),
                'site_key_filter' => array(),
                'header_load_meta' => array(),
                'footer_load_lib' => array(),
                'post_title_filter' => array(),
                'post_meta_filter' => array(),
                'post_content_filter' => array(),
                'post_author_filter' => array(),
                'post_date_filter' => array(),
                'post_category_filter' => array(),
                'post_submit_add_action' => array(), // on submit
                'post_sqladd_action' => array(), // on sql add
                'post_submit_edit_action' => array(), // on submit
                'post_sqledit_action' => array(), // on sql add
                'post_submit_title_filter' => array(),
                'post_submit_content_filter' => array(),
                'post_submit_category_filter' => array(),
                'post_delete_action' => array(), // on delete
                'post_sqldel_action' => array(), // on sql delete
                'user_submit_add_action' => array(),
                'user_sqladd_action' => array(),
                'user_submit_edit_action' => array(),
                'user_sqledit_action' => array(),
                'user_delete_action' => array(),
                'user_sqldel_action' => array(),
                'user_reg_action' => array(),
                'user_login_action' => array(),
                'user_logout_action' => array(),
                'user_activation_action' => array(),
                'admin_page_notif_action' => array(),
                'admin_page_top_action' => array(),
                'admin_page_bottom_action' => array(),
                'admin_page_dashboard_action' => array(),
                'admin_page_dashboard_statslist_action' => array(),
                'admin_footer_action' => array(),
                'module_install_action' => array(),
                'theme_install_action' => array(),
                'mod_control' => array(),
        //$mod = '';
    public static function related($id, $num, $cat, $type = 'list')
                        AND A.`type` = 'post'
            if ($type == 'list') {
            } elseif ($type == 'box') {
                        $title = (strlen($p->title) > 40) ? substr($p->title, 0, 38).'...' : $p->title;
                        <img src="'.$img.'" class="img-responsive center-block">'.$title.'</a><br /><br /></li>';
        'thumb/type/(.*)/size/([0-9]+)/align/(.*)/(.*)' => array('thumb' => '4', 'type' => '1', 'size' => '2', 'align' => '3'),
        'thumb/type/(.*)/size/([0-9]+)/(.*)' => array('thumb' => '3', 'type' => '1', 'size' => '2'),
        'thumb/size/([0-9]+)/align/(.*)/(.*)' => array('thumb' => '3', 'size' => '1', 'align' => '2'),
        'category/([0-9]+)/(.*)/paging/([0-9]+)/' => array('cat' => '1', 'paging' => '3'),
        'category/([0-9]+)/(.*)/' => array('cat' => '1'),
        'tag/(.*)/paging/([0-9]+)/' => array('tag' => '1', 'paging' => '3'),
        'tag/(.*)/' => array('tag' => '1'),
        '([a-z]+)/mod/(.*)'.GX_URL_PREFIX => array('mod' => '2', 'lang' => '1'),
        // '/(.[a-z]+)/(.+)'.GX_URL_PREFIX => array('page' => '2', 'lang' => '1'),
        'mod/(.*)'.GX_URL_PREFIX => array('mod' => '1'),
        // '/(.+)'.GX_URL_PREFIX => array('page' => '1'),
        'paging/([0-9]+)/' => array('default', 'paging' => '1'),
        'error/([0-9]+)/' => array('error' => '1'),
        '([a-z]+)/(.*)'.GX_URL_PREFIX => array('post' => '2', 'lang' => '1'),
        '(.*)'.GX_URL_PREFIX => array('post' => '1'),
        'ajax/(.*)/(.*)' => array('ajax' => '1', 'token' => '2'),
        'thumb/size/([0-9]+)/(.*)' => array('thumb' => '2', 'size' => '1'),
        'thumb/type/(.*)/(.*)' => array('thumb' => '2', 'type' => '1'),
        'thumb/align/(.*)/(.*)' => array('thumb' => '2', 'align' => '1'),
        'thumb/(.*)' => array('thumb' => '1'),
        'error/' => array('error'),
        'sitemap/' => array('sitemap'),
        'rss/' => array('rss'),
        '/' => array('default'),
        $va = [];
    public static function isExist($user)
        if (isset($_GET['act']) && $_GET['act'] == 'edit') {
            $id = Typo::int($_GET['id']);
            $where = "AND `id` != '{$id}' ";
            return false;
        } else {
                $o = [];
                                <div class="blog-meta"><small>published at '.Date::format($p->date, 'd M Y')." by <a href=\"#\">{$p->author}</a></small><br /><br /></div>
                                <div class="blog-footer">posted in '.Categories::name($p->cat).', at '.Date::format($p->date)." by <a href=\"#\">{$p->author}</a></div>
    text-transform: uppercase;
    background-color: rgba(0,0,0,.7);
        $o = [];
                if ($gneex['front_layout'] == 'magazine') {
                    # code...
                ?>
                <?php
                    $cat = $gneex['panel_1'];
                    $post = Posts::getPostCat($cat, 8); ?>
                
                    <h3 class="panel-title"><?=Categories::name($cat); ?></h3>
                            <?php
                            if (!isset($post['error'])) {
                                $content = Posts::content($post[0]->content);
                                $title = Posts::title($post[0]->id);
                                $img = Gneex::getImage($content);
                                if ($img != '') {
                                    $im = '<img src="'.Url::thumb($img, 'large').'" class="img-responsive">';
                                } else {
                                    $im = '<img src="'.Url::thumb('assets/images/noimage.png', 'large').'" class="img-responsive">';
                                }
                                echo '
                                    <a href="'.Url::post($post[0]->id)."\">
                                    <div class=\"horizontal-list\">
                                        {$im}
                                    </div>
                                    <div class=\"\">
                                        <h4 >{$title}</h4>
                                    </div>
                                    </a>
                                ";
                                unset($post[0]);
                            } ?>
                            </div>
                            <div class="col-sm-8">
                            <ul class="list-unstyled">
                                foreach ($post as $p => $v) {
                                    <li>
                                    <h5><a href="'.Url::post($v->id).'">'.$v->title.'</a></h5>
                                    </li>
                                    ';
                                } ?> 
                            </ul>
                            
                        
                    echo '<div class="row"><div class="col-md-12">'.Gneex::opt('adsense').'</div></div><hr />';
                    
                    <div class="col-sm-6">
                        <?php
                        $cat = $gneex['panel_2'];
                        $post = Posts::getPostCat($cat, 6); ?>
                        
                            <h3 class="panel-title"><?=Categories::name($cat); ?></h3>
                                    <?php
                                    if (!isset($post['error'])) {
                                        $content = Posts::content($post[0]->content);
                                        $title = Posts::title($post[0]->id);
                                        $img = Gneex::getImage($content);
                                        if ($img != '') {
                                            $im = '<img src="'.Url::thumb($img, 'large').'" class="img-responsive">';
                                        } else {
                                            $im = '<img src="'.Url::thumb('assets/images/noimage.png', 'large').'" class="img-responsive">';
                                        }
                                        echo '
                                            <a href="'.Url::post($post[0]->id)."\">
                                            <div class=\"vertical-list\">
                                                {$im}
                                            </div>
                                            <div class=\"\">
                                                <h4 >{$title}</h4>
                                            </div>
                                            </a>
                                        ";
                                        unset($post[0]);
                                    } ?>
                                    </div>
                                    <div class="col-md-12">
                                    <ul class="list-unstyled">
                                        foreach ($post as $p => $v) {
                                            <li>
                                            <h5><a href="'.Url::post($v->id).'">'.$v->title.'</a></h5>
                                            </li>
                                            ';
                                        } ?> 
                                    </ul>
                                    
                                
                    
                    <div class="col-sm-6">
                        <?php
                        $cat = $gneex['panel_3'];
                        $post = Posts::getPostCat($cat, 6); ?>
                        
                            <h3 class="panel-title"><?=Categories::name($cat); ?></h3>
                                    <?php
                                    if (!isset($post['error'])) {
                                        $content = Posts::content($post[0]->content);
                                        $title = Posts::title($post[0]->id);
                                        $img = Gneex::getImage($content);
                                        if ($img != '') {
                                            $im = '<img src="'.Url::thumb($img, 'large').'" class="img-responsive">';
                                        } else {
                                            $im = '<img src="'.Url::thumb('assets/images/noimage.png', 'large').'" class="img-responsive">';
                                        }
                                        echo '
                                            <a href="'.Url::post($post[0]->id)."\">
                                            <div class=\"vertical-list\">
                                                {$im}
                                            </div>
                                            <div class=\"\">
                                                <h4 >{$title}</h4>
                                            </div>
                                            </a>
                                        ";
                                        unset($post[0]);
                                    } ?>
                                    </div>
                                    <div class="col-md-12">
                                    <ul class="list-unstyled">
                                        foreach ($post as $p => $v) {
                                            <li>
                                            <h5><a href="'.Url::post($v->id).'">'.$v->title.'</a></h5>
                                            </li>
                                            ';
                                        } ?> 
                                    </ul>
                                    
                                
                </div>

                    echo '<div class="row"><div class="col-md-12">'.Gneex::opt('adsense').'</div></div><hr />';
        
                    $post = Posts::getPostCat($cat, 4);
                    echo '<h4>'.Categories::name($cat).'</h4>'; ?>
                <hr />
                
                <ul class="list-featured">
                    <?php


                    foreach ($post as $p) {
                        $content = Posts::content($p->content);
                        $title = Posts::title($p->id);
                        $img = Gneex::getImage($content);
                        if ($img != '') {
                            $im = '<img src="'.Url::thumb($img).'" class="img-responsive">';
                        } else {
                            $im = '<img src="'.Url::thumb('assets/images/noimage.png').'" class="img-responsive">';
                        }

                        echo '<li class="col-sm-3">
                                    <a href="'.Url::post($p->id)."\">
                                    {$im}
                                    <div class=\"featured-text\">
                                        <h4 >{$title}</h4>
                                    </div>
                                    </a>
                                </li>";
                    } ?>
                    
                </ul>
                </div>
                
                    $post = Posts::getPostCat($cat, 8);
                    $postig = $post[0]; ?>
                
                    <h3 class="panel-title"><?=Categories::name($cat); ?></h3>
                            <ul class="list-unstyled">
                                <?php
                                unset($post[0]);
                                foreach ($post as $p => $v) {
                                    echo '
                                    <li>
                                    <h5><a href="'.Url::post($v->id).'">'.$v->title.'</a></h5>
                                    </li>
                                    ';
                                } ?> 
                            </ul>
                            
                            <?php
                            if (!isset($post['error'])) {
                                $content = Posts::content($postig->content);
                                $title = Posts::title($postig->id);
                                $img = Gneex::getImage($content);
                                if ($img != '') {
                                    $im = '<img src="'.Url::thumb($img, 'large').'" class="img-responsive">';
                                } else {
                                    $im = '<img src="'.Url::thumb('assets/images/noimage.png', 'large').'" class="img-responsive">';
                                }
                                echo '
                                    <a href="'.Url::post($postig->id)."\">
                                    <div class=\"horizontal-list\">
                                        {$im}
                                    </div>
                                    <div class=\"\">
                                        <h4 >{$title}</h4>
                                    </div>
                                    </a>
                                ";
                            } ?>
                            
                        
                
                
                
                <?php
                } else {
                    
                    <!-- start blog layout -->

                    <div class=" blog-lists clearfix">
                    <?php
                    if ($data['num'] > 0) {
                        foreach ($data['posts'] as $p) {
                            echo '
                            <article class="blog-post col-md-12">
                                <h2><a href="'.Url::post($p->id)."\">$p->title</a></h2>
                                <hr />
                                ".Posts::format($p->content, $p->id).'
                                <div class="blog-footer">posted in '.Categories::name($p->cat).', at '.Date::format($p->date, 'd M Y H:i')." by <a href=\"#\">{$p->author}</a></div>
                            </article>
                                ";
                        }
                    } else {
                        echo 'No Post to Show';
                    } ?>
                    
                    </div>
                    <?=$data['paging']; ?>
                    <!-- end blog layout -->
                    <?php
                }
            ?>
            <?php Theme::theme('rightside', $data); ?>
                
    </section>
        $o = [];
            
                <div class="col-md-8">
                                    <span class=\"meta\">posted in <a href=\"".Url::cat($p->cat).'">'.Categories::name($p->cat).'</a>, at '.Date::format($p->date).' by '.$p->author.'</span>
                                    '.Posts::content($p->content, $p->id).'<hr />';
                <?php Theme::theme('rightside', $data); ?>
<?php

echo phpinfo();
    if (!User::isExist($_POST['userid'])) {

Fixed code:
                        elfinderDialog($(this).closest('.note-editor').parent().children('.summernote'));

        <div id="elfinder"></div>

                    Hooks::run('page_param_form', $data);

                Hooks::run('post_param_form', $data);
                $where .= '';
                if ($vars['type'] == 'tag') {
                    $where .= " `type` = '{$vars['type']}' AND ";
                } else {
                    $where .= " `type` = '{$vars['type']}' AND `type` != 'tag' AND ";
                }

                $where .= " `type` != 'tag' AND ";
            $where .= '1 ';
                if ($vars['type'] == 'tag') {
                    $where .= " `type` = '{$vars['type']}' AND ";
                } else {
                    $where .= " `type` = '{$vars['type']}' AND `type` != 'tag' AND ";
                }

            } else {
                $where .= " `type` != 'tag' AND ";
        $sql = "SELECT `id` FROM `cat` WHERE `id` = '{$cat}'";

                $url = isset($v->url) ? $v->url : '#';
        $arr = array('ajax', 'post', 'page', 'cat', 'mod', 'sitemap', 'rss',
                    'account', 'search', 'author', 'tag', 'thumb', 'default');
$data = Router::scrap($param);
$token = (SMART_URL) ? $data['token'] : Typo::cleanX($_GET['token']);
if (isset($token) && Token::isExist($token) ) {
$data = Router::scrap($param);
$token = (SMART_URL) ? $data['token'] : Typo::cleanX($_GET['token']);
if (isset($token) && Token::isExist($token) ) {
        $term = Typo::cleanX($_GET['term']);
            "SELECT * FROM `cat` WHERE `type` = 'tag' AND `name` LIKE '".$term."%' ORDER BY `name` ASC"
$data = Router::scrap($param);
$token = (SMART_URL) ? $data['token'] : Typo::cleanX($_GET['token']);
if (isset($token) && Token::isExist($token) ) {
$mod = Typo::cleanX($_GET['mod']);
$data['sitetitle'] = Mod::title($mod);
Mod::options($mod);
                        if (isset($_POST['param'])){
                            foreach ($_POST['param'] as $k => $v) {
                                Posts::addParam($k, $v, $post_id);
                            }
                        }

                        if (isset($_POST['param'])){
                            foreach ($_POST['param'] as $k => $v) {
                                if (!Posts::existParam($k, $_GET['id'])) {
                                    Posts::addParam($k, $v, $_GET['id']);
                                } else {
                                    Posts::editParam($k, $v, $_GET['id']);
                                }
                            }
                        }

        $theme = Options::v('themes');
        $data['sitetitle'] = Theme::title($theme);
        Theme::options($theme);
                    if (User::isExist($_POST['userid'])) {
                        if (User::isExist($_POST['userid'])) {
<?php

defined('GX_LIB') or die('Direct Access Not Allowed!');
/*
 * GeniXCMS - Content Management System
 *
 * PHP Based Content Management System and Framework
 *
 * @since 0.0.1 build date 20141006
 *
 * @version 1.0.0
 *
 * @link https://github.com/semplon/GeniXCMS
 * @link http://genixcms.org
 *
 * @author Puguh Wijayanto <psw@metalgenix.com>
 * @copyright 2014-2016 Puguh Wijayanto
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */

$post = '';
$data = Router::scrap($param);
$data['p_type'] = 'author';

//$cat = Db::escape(Typo::Xclean($_GET['cat']));
$author = (SMART_URL) ? $data['author'] : Typo::cleanX(Typo::strip($_GET['author']));
$data['max'] = Options::v('post_perpage');
//echo User::isExist($author);
if (User::isExist($author)) {
    if (SMART_URL) {
        if (isset($data['paging'])) {
            $paging = $data['paging'];
        }
        $type = isset($data['type']) ? $data['type']: '';
    } else {
        if (isset($_GET['paging'])) {
            $paging = Typo::int($_GET['paging']);
        }
        $type = isset($_GET['type']) ? $_GET['type']: '';
    }

    if ($type != '') {
        $where = " AND `type` = '{$type}' ";
    } else {
        $where = '';
    }
    //$paging = (SMART_URL) ? $data['paging'] : Typo::int(is_int($_GET['paging']));
    if (isset($paging) && $paging != '') {
        if ($paging > 0) {
            $offset = ($paging - 1) * $data['max'];
        } else {
            $offset = 0;
        }
//        echo $offset;
        $pagingtitle = " - Page {$paging}";
    } else {
        $offset = 0;
        $paging = 1;
        $pagingtitle = '';
    }
//    echo $paging;
    $data['sitetitle'] = 'Post by : '.$author.$pagingtitle;
    $data['posts'] = Db::result(
        sprintf(
            "SELECT * FROM `posts`
                        WHERE `author` = '%s' %s
                        AND `status` = '1'
                        ORDER BY `date`
                        DESC LIMIT %d, %d",
            $author,
            $where,
            $offset,
            $data['max']
        )
    );
    $data['num'] = Db::$num_rows;
//    echo $data['num'];
    $data['posts'] = Posts::prepare($data['posts']);
    // print_r($data['posts']);
    $url = Url::author($author, $type);
    $paging = array(
                    'paging' => $paging,
                    'table' => 'posts',
                    'where' => '`author` = \''.$author.'\' AND `status` = \'1\' '.$where,
                    'max' => $data['max'],
                    'url' => $url,
                    'type' => Options::v('pagination'),
                );
    $data['paging'] = Paging::create($paging, SMART_URL);
    Theme::theme('header', $data);
    Theme::theme('author', $data);
    Theme::footer($data);
    exit;
} else {
    Control::error('404');
    exit;
}
/* End of file cat.control.php */
/* Location: ./inc/lib/Control/Frontend/cat.control.php */
                    'where' => '`type` = \''.$type.'\' AND `cat` = \''.$cat.'\' AND `status` = \'1\' ',
    $theme = Theme::exist($data['p_type']) ? $data['p_type']: 'single';
    Theme::footer($data);
$data['name'] = $name;
$data['tag'] = $tag;

                'where' => '`type` = \''.$type.'\' AND `status` = \'1\' ',
    Theme::footer($data);
} else {
    $thumb = '';
    $type = '';
    $size = '';
    $align = '';
            'init' => array(), // init the system
            'header_pre_action' => array(), // action before load header
            'site_title_filter' => array(), // filter website title
            'site_desc_filter' => array(),
            'site_key_filter' => array(),
            'header_load_meta' => array(),
            'footer_load_lib' => array(),
            'post_title_filter' => array(),
            'post_meta_filter' => array(),
            'post_content_filter' => array(),
            'post_author_filter' => array(),
            'post_date_filter' => array(),
            'post_category_filter' => array(),
            'post_submit_add_action' => array(), // on submit
            'post_sqladd_action' => array(), // on sql add
            'post_submit_edit_action' => array(), // on submit
            'post_sqledit_action' => array(), // on sql add
            'post_submit_title_filter' => array(),
            'post_submit_content_filter' => array(),
            'post_submit_category_filter' => array(),
            'post_delete_action' => array(), // on delete
            'post_sqldel_action' => array(), // on sql delete
            'post_param_form' => array(),
            'page_param_form' => array(),
            'user_submit_add_action' => array(),
            'user_sqladd_action' => array(),
            'user_submit_edit_action' => array(),
            'user_sqledit_action' => array(),
            'user_delete_action' => array(),
            'user_sqldel_action' => array(),
            'user_reg_action' => array(),
            'user_login_action' => array(),
            'user_logout_action' => array(),
            'user_activation_action' => array(),
            'admin_page_notif_action' => array(),
            'admin_page_top_action' => array(),
            'admin_page_bottom_action' => array(),
            'admin_page_dashboard_action' => array(),
            'admin_page_dashboard_statslist_action' => array(),
            'admin_footer_action' => array(),
            'module_install_action' => array(),
            'theme_install_action' => array(),
            'mod_control' => array(),
        $mod = array();
    public static function title($mod)
    {
        $data = self::data($mod);

        return $data['name'];
    }

    public static function related($id, $num, $cat, $mode = 'list')
                        AND A.`type` = '%s'
                $post_type,
            if ($mode == 'list') {
            } elseif ($mode == 'box') {
                        $title = (strlen($p->title) > 34) ? substr($p->title, 0, 34).'...' : $p->title;
                        <img src="'.$img.'" class="img-responsive center-block">'.$title.'</a></li>';
            'thumb/type/(.*)/size/([0-9]+)/align/(.*)/(.*)' => array('thumb' => '4', 'type' => '1', 'size' => '2', 'align' => '3'),
            'thumb/type/(.*)/size/([0-9]+)/(.*)' => array('thumb' => '3', 'type' => '1', 'size' => '2'),
            'thumb/size/([0-9]+)/align/(.*)/(.*)' => array('thumb' => '3', 'size' => '1', 'align' => '2'),
            'category/([0-9]+)/(.*)/paging/([0-9]+)/' => array('cat' => '1', 'paging' => '3'),
            'category/([0-9]+)/(.*)/' => array('cat' => '1'),
            'tag/(.*)/paging/([0-9]+)/' => array('tag' => '1', 'paging' => '3'),
            'tag/(.*)/' => array('tag' => '1'),
            '([a-z]+)/mod/(.*)'.GX_URL_PREFIX => array('mod' => '2', 'lang' => '1'),
            // '/(.[a-z]+)/(.+)'.GX_URL_PREFIX => array('page' => '2', 'lang' => '1'),
            'mod/(.*)'.GX_URL_PREFIX => array('mod' => '1'),
            // '/(.+)'.GX_URL_PREFIX => array('page' => '1'),
            'paging/([0-9]+)/' => array('default', 'paging' => '1'),
            'error/([0-9]+)/' => array('error' => '1'),
            '([a-z]+)/(.*)'.GX_URL_PREFIX => array('post' => '2', 'lang' => '1'),
            '(.*)'.GX_URL_PREFIX => array('post' => '1'),
            'ajax/(.*)/(.*)' => array('ajax' => '1', 'token' => '2'),
            'thumb/size/([0-9]+)/(.*)' => array('thumb' => '2', 'size' => '1'),
            'thumb/type/(.*)/(.*)' => array('thumb' => '2', 'type' => '1'),
            'thumb/align/(.*)/(.*)' => array('thumb' => '2', 'align' => '1'),
            'thumb/(.*)' => array('thumb' => '1'),
            'author/(.*)/(.*)/paging/([0-9]+)/' => array('author' => '1', 'type' => '2', 'paging' => '3'),
            'author/(.*)/paging/([0-9]+)/' => array('author' => '1', 'paging' => '2'),
            'author/(.*)/(.*)/' => array('author' => '1', 'type' => '2'),
            'author/(.*)/' => array('author' => '1'),
            'error/' => array('error'),
            'sitemap/' => array('sitemap'),
            'rss/' => array('rss'),
            '/' => array('default'),
        $va = array();

    public static function title($mod)
    {
        $data = self::data($mod);

        return $data['name'];
    }

    public static function author($vars, $type='')
    {
        switch (SMART_URL) {
            case true:
                $type = ($type != '') ? $type.'/': '';
                $inFold = (Options::v('permalink_use_index_php') == 'on') ? 'index.php/' : '';
                $url = Site::$url.$inFold.'author/'.$vars.'/'.$type;
                break;

            default:
                $type = ($type != '') ? '&type='.$type: '';
                $url = Site::$url."?author={$vars}$type";
                break;
        }

        return $url;
    }
    public static function isExist($user, $except='')
        if ($except != '') {
            $id = Typo::int($except);
            $where = "AND `userid` != '{$id}' ";
        } else {
            return false;
                $o = array();
<?php
$gneex = Gneex::$opt;
?>
    <section id="innerslide">
        
        <div class="bg-slide">
            
        </div>

    </section>

    <section id="blog">
        <div class="container">
            
            <div class="col-md-8">
                <h2 class="category-title"><?=$data['author'];?></h2>
                <hr />
                <div class=" blog-lists clearfix">
                <?php
                if (Gneex::opt('adsense') != '') {
                    echo '<div class="row"><div class="col-md-12">'.Gneex::opt('adsense').'</div></div><hr />';
                } else {
                    echo '<div class="col-md-12">&nbsp;</div>';
                }
                ?>
                <?php
                if ($data['num'] > 0) {
                    foreach ($data['posts'] as $p) {
                        if ($gneex['category_layout'] == 'magazine') {
                            # code...
                            $img = Posts::getImage(Posts::content($p->content));
                            if ($img != '') {
                                $im = '<img src="'.Url::thumb($img, '', 300).'" class="img-responsive">';
                            } else {
                                $im = '<img src="'.Url::thumb('assets/images/noimage.png', '', 300).'" class="img-responsive">';
                            }
                            echo '
                            <article class="blog-post magazine col-md-12 clearfix">
                            <div class="col-sm-4 col-md-4">
                            '.$im.'
                            </div>
                            <div class="col-sm-8 col-md-8">
                                <h3><a href="'.Url::post($p->id).'">'.$p->title.'</a></h3>
                                <div class="blog-meta"><small>published at '.Date::format($p->date, 'd M Y')."
                                 in <a href=\"".Url::cat($p->cat)."\">".Categories::name($p->cat)."</a>
                                by <a href=\"".Url::author($p->author)."\">{$p->author}</a></small><br /><br /></div>
                                ".substr(Typo::strip(Posts::content($p->content)), 0, 350).'
                            </div>
                            <div class="col-sm-12 col-md-12 clearfix">
                                <hr />
                            </div>
                            </article>
                                ';
                        } else {
                            echo '
                            <article class="blog-post col-md-12">
                                <h2><a href="'.Url::post($p->id)."\">$p->title</a></h2>
                                <hr />
                                ".Posts::format($p->content, $p->id).'
                                <div class="blog-footer">posted in '.Categories::name($p->cat).', 
                                at '.Date::format($p->date)." by <a href=\"".Url::author($p->author)."\">{$p->author}</a></div>
                            </article>
                                ";
                        }
                    }
                } else {
                    echo 'No Post to Show';
                }
                ?>
                <?php
                if (Gneex::opt('adsense') != '') {
                    echo '<div class="row"><div class="col-md-12">'.Gneex::opt('adsense').'</div></div><hr />';
                }
                ?>
                </div>
                <?=$data['paging'];?>
            </div>
            <?php Theme::theme('rightside', $data); ?>
                

        </div>
    </section>
                                <div class="blog-meta"><small>published at '.Date::format($p->date, 'd M Y')." 
                                in <a href=\"".Url::cat($p->cat)."\">".Categories::name($p->cat)."</a>
                                by <a href=\"".Url::author($p->author)."\">{$p->author}</a></small><br /><br /></div>
                                <div class="blog-footer">posted in '.Categories::name($p->cat).', 
                                at '.Date::format($p->date)." by <a href=\"".Url::author($p->author)."\">{$p->author}</a></div>
article .content img {
    box-shadow: 1px 1px 3px rgba(0,0,0,.4);
}
.related {
    text-align: left;
    font-size: .9em;
}
.circle {
    -webkit-border-radius: 50%!important;
    -moz-border-radius: 50%!important;
    border-radius: 50%!important;
    text-align: center;
    vertical-align: middle;
    color: #fefefe;
    padding: 11%;
    background-color: #aaa;
    width: 150px;
    height: 150px;
    float: none;
    margin-left: auto;
    margin-right: auto;
    font-size: 4em;
}
<?php
    $gneex = Gneex::$opt;;
    $post = Gneex::getPost($gneex['fullwidth_page']);
    echo(Typo::Xclean($post));
?>

            Hooks::attach('post_param_form', array('Gneex', 'postParam'));
        $o = array();
    public static function optionPost($type, $post='')
    {
        $sql = "SELECT * FROM `posts` WHERE `type` = '{$type}' ORDER BY `title` ASC";
        $q = Db::result($sql);
        $opt = '<option></option>';
        foreach ($q as $k => $v) {
            $sel = ($post != '' && $post == $v->id) ? 'selected': '';
            $opt .= "<option value='{$v->id}' {$sel}>{$v->title}</option>";
        }

        return $opt;
    }

                \'fullwidth\' : $(\'#fullwidth\'),

    public static function postParam($data)
    {
//        print_r($data);
        $bar = Posts::getParam('sidebar', $data[0]['post'][0]->id);
//        echo $bar;
        $yes = ($bar == 'yes') ? 'selected': '';
        $no = ($bar == 'no') ? 'selected': '';
        $form = '<div class="row">
                <div class="col-sm-4">
                    <label>Show/Hide Sidebar</label>
                    <select name="param[sidebar]" class="form-control">
                        <option value="yes" '.$yes.'>Show Sidebar</option>
                        <option value="no" '.$no.'>Hide Sidebar</option>
                    </select>
                </div>
                </div>';
        echo $form;
    }

<?php
if ($gneex['front_layout'] == 'magazine') {
    # code...
    ?>
                $cat = $gneex['panel_1'];
                if (isset($cat) && $cat != ''){
                $post = Posts::getPostCat($cat, 8); ?>
                        <h3 class="panel-title"><?= Categories::name($cat); ?></h3>
                                if (!isset($post['error'])) {
                                    $content = Posts::content($post[0]->content);
                                    $title = Posts::title($post[0]->id);
                                    $img = Gneex::getImage($content);
                                    if ($img != '') {
                                        $im = '<img src="' . Url::thumb($img, 'large') . '" class="img-responsive">';
                                    } else {
                                        $im = '<img src="' . Url::thumb('assets/images/noimage.png', 'large') . '" class="img-responsive">';
                                    }
                                <a href="' . Url::post($post[0]->id) . "\">
                                <div class=\"horizontal-list\">
                                    {$im}
                                </div>
                                <div class=\"\">
                                    <h4 >{$title}</h4>
                                </div>
                                </a>
                            ";
                                    unset($post[0]);
                                } ?>
                            </div>
                            <div class="col-sm-8">
                                <ul class="list-unstyled">
                                    <?php
                                    foreach ($post as $p => $v) {
                                        echo '
                                <li>
                                <h5><a href="' . Url::post($v->id) . '">' . $v->title . '</a></h5>
                                </li>
                                ';
                                    } ?>
                                </ul>


                <?php }?>
                    echo '<div class="row"><div class="col-md-12">' . Gneex::opt('adsense') . '</div></div><hr />';


                <?php
                $cat = $gneex['panel_2'];
                if (isset($cat) && $cat != ''){
                    $col2 = !empty($gneex['panel_3']) ? '6': '12';
                    $post = Posts::getPostCat($cat, 6); ?>
                    <div class="col-sm-<?=$col2;?>">
                                <h3 class="panel-title"><?= Categories::name($cat); ?></h3>
                                        if (!isset($post['error'])) {
                                            $content = Posts::content($post[0]->content);
                                            $title = Posts::title($post[0]->id);
                                            $img = Gneex::getImage($content);
                                            if ($img != '') {
                                                $im = '<img src="' . Url::thumb($img, 'large') . '" class="img-responsive">';
                                            } else {
                                                $im = '<img src="' . Url::thumb('assets/images/noimage.png', 'large') . '" class="img-responsive">';
                                            }
                                        <a href="' . Url::post($post[0]->id) . "\">
                                        <div class=\"vertical-list\">
                                            {$im}
                                        </div>
                                        <div class=\"\">
                                            <h4 >{$title}</h4>
                                        </div>
                                        </a>
                                    ";
                                            unset($post[0]);
                                        } ?>
                                    </div>
                                    <div class="col-md-12">
                                        <ul class="list-unstyled">
                                            <?php
                                            foreach ($post as $p => $v) {
                                                echo '
                                        <li>
                                        <h5><a href="' . Url::post($v->id) . '">' . $v->title . '</a></h5>
                                        </li>
                                        ';
                                            } ?>
                                        </ul>


                <?php } ?>

                <?php
                $cat = $gneex['panel_3'];
                if (isset($cat) && $cat != ''){
                    $col3 = !empty($gneex['panel_2']) ? '6': '12';
                    $post = Posts::getPostCat($cat, 6); ?>
                    <div class="col-sm-<?=$col3;?>">
                                <h3 class="panel-title"><?= Categories::name($cat); ?></h3>
                                        if (!isset($post['error'])) {
                                            $content = Posts::content($post[0]->content);
                                            $title = Posts::title($post[0]->id);
                                            $img = Gneex::getImage($content);
                                            if ($img != '') {
                                                $im = '<img src="' . Url::thumb($img, 'large') . '" class="img-responsive">';
                                            } else {
                                                $im = '<img src="' . Url::thumb('assets/images/noimage.png', 'large') . '" class="img-responsive">';
                                            }
                                        <a href="' . Url::post($post[0]->id) . "\">
                                        <div class=\"vertical-list\">
                                            {$im}
                                        </div>
                                        <div class=\"\">
                                            <h4 >{$title}</h4>
                                        </div>
                                        </a>
                                    ";
                                            unset($post[0]);
                                        } ?>
                                    </div>
                                    <div class="col-md-12">
                                        <ul class="list-unstyled">
                                            <?php
                                            foreach ($post as $p => $v) {
                                                echo '
                                        <li>
                                        <h5><a href="' . Url::post($v->id) . '">' . $v->title . '</a></h5>
                                        </li>
                                        ';
                                            } ?>
                                        </ul>


                <?php } ?>
                </div>
                    echo '<div class="row"><div class="col-md-12">' . Gneex::opt('adsense') . '</div></div><hr />';

                if (isset($cat) && $cat != ''){
                $post = Posts::getPostCat($cat, 4);
                echo '<h4>' . Categories::name($cat) . '</h4>'; ?>
                <hr/>
                    <ul class="list-featured">
                        <?php
                        foreach ($post as $p) {
                            $content = Posts::content($p->content);
                            $title = Posts::title($p->id);
                            $img = Gneex::getImage($content);
                            if ($img != '') {
                                $im = '<img src="' . Url::thumb($img) . '" class="img-responsive">';
                            } else {
                                $im = '<img src="' . Url::thumb('assets/images/noimage.png') . '" class="img-responsive">';
                            }

                            echo '<li class="col-sm-3">
                                <a href="' . Url::post($p->id) . "\">
                                {$im}
                                <div class=\"featured-text\">
                                    <h4 >{$title}</h4>
                                </div>
                                </a>
                            </li>";
                        } ?>

                    </ul>
                </div>
                <?php } ?>
                if (isset($cat) && $cat != ''){
                $post = Posts::getPostCat($cat, 8);
                $postig = $post[0]; ?>

                        <h3 class="panel-title"><?= Categories::name($cat); ?></h3>
                                <ul class="list-unstyled">
                                    <?php
                                    unset($post[0]);
                                    foreach ($post as $p => $v) {
                                        echo '
                                <li>
                                <h5><a href="' . Url::post($v->id) . '">' . $v->title . '</a></h5>
                                </li>
                                ';
                                    } ?>
                                </ul>

                                <?php
                                if (!isset($post['error'])) {
                                    $content = Posts::content($postig->content);
                                    $title = Posts::title($postig->id);
                                    $img = Gneex::getImage($content);
                                    if ($img != '') {
                                        $im = '<img src="' . Url::thumb($img, 'large') . '" class="img-responsive">';
                                    } else {
                                        $im = '<img src="' . Url::thumb('assets/images/noimage.png', 'large') . '" class="img-responsive">';
                                    }
                                    echo '
                                <a href="' . Url::post($postig->id) . "\">
                                <div class=\"horizontal-list\">
                                    {$im}
                                </div>
                                <div class=\"\">
                                    <h4 >{$title}</h4>
                                </div>
                                </a>
                            ";
                                } ?>


                <?php } ?>
            </div> <!-- col-md-8 blog-lists end -->
            <?php Theme::theme('rightside', $data); ?>


        </div>
    </section>
        <?php
    } elseif ($gneex['front_layout'] == 'fullwidth') {
        Theme::inc('fullwidth', $data);
    } else {
    <section id="blog">
        <div class="container">
            <div class="col-md-8">
                <!-- start blog layout -->
                <div class=" blog-lists clearfix">
                <?php
                if ($data['num'] > 0) {
                    foreach ($data['posts'] as $p) {
                        echo '
                        <article class="blog-post col-md-12">
                            <h2><a href="'.Url::post($p->id)."\">$p->title</a></h2>
                            <hr />
                            ".Posts::format($p->content, $p->id).'
                            <div class="blog-footer">posted in '.Categories::name($p->cat).', at '.Date::format($p->date, 'd M Y H:i')." by <a href=\"#\">{$p->author}</a></div>
                        </article>
                            ";
                    }
                } else {
                    echo 'No Post to Show';
                } ?>
                </div>
                <?=$data['paging']; ?>
        <?php Theme::theme('rightside', $data); ?>

    </section>

        <!-- end blog layout -->
        <?php
    }
?>
        $o = array();
                                            <option value="fullwidth" <?=($o['front_layout'] == 'fullwidth') ? 'selected' : ''; ?>>Full Width</option>
                        <div id="fullwidth">
                            <div class="col-md-12">
                                <select name="fullwidth_page" class="form-control">
                                    <?=Gneex::optionPost('page', $o['fullwidth_page']);?>
                                </select>
                            </div>
                        </div>
            <?php
            $bar = Posts::getParam('sidebar', $data['posts'][0]->id);
            $cols = ($bar == 'yes'|| $bar == '') ? '8': '12';
            ?>
                <div class="col-md-<?=$cols;?>">
                                    <span class=\"meta\">posted in <a href=\"".Url::cat($p->cat).'">'.Categories::name($p->cat).'</a>, 
                                    at '.Date::format($p->date).' by <a href="'.Url::author($p->author).'">'.$p->author.'</a></span>
                                    <div class="content">'.Posts::content($p->content, $p->id).'</div><hr />';
                <?php if($bar == 'yes'|| $bar == '') Theme::theme('rightside', $data); ?>
    if (User::isExist($_POST['userid'])) {