function isset_user($id)
{
    global $hmuser;
    hook_action('isset_user');
    $return = $hmuser->isset_user($id);
    $return = hook_filter('isset_user', $return);
    return $return;
}
/** Đăng ký dashboard box */
function register_dashboard_box($args = array())
{
    hook_filter('before_register_dashboard_box', $args);
    hook_action('register_dashboard_box');
    global $dashboard_box;
    if (is_array($args)) {
        $dashboard_box[] = $args;
    }
}
function total_module($args = array())
{
    hook_filter('before_total_module', $args);
    global $hmmodule;
    hook_action('total_module');
    $return = $hmmodule->total_module($args);
    $return = hook_filter('total_module', $return);
    return $return;
}
    hook_filter('before_register_menu_location', $args);
    global $hmmenu;
    hook_action('register_menu_location');
    $return = $hmmenu->register_menu_location($args);
    $return = hook_filter('register_menu_location', $return);
    return $return;
}
function menu_location($menu_location_name = NULL)
{
    hook_filter('before_menu_location', $menu_location_name);
    global $hmmenu;
    hook_action('menu_location');
    $menu_location = $hmmenu->menu_location;
    if (isset($menu_location[$menu_location_name])) {
function chapter_show_data($id)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('chapter_show_data');
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "content WHERE `status` = 'chapter' AND `parent` = '{$id}' ORDER BY id DESC")) {
        $hmdb->Kill();
    }
    $array_cha = array();
    while ($row = $hmdb->Row()) {
        $data_cha = content_data_by_id($row->id);
        $array_cha[] = array('id' => $row->id, 'name' => $row->name, 'slug' => $row->slug, 'public_time' => date('d-m-Y H:i', $data_cha['field']['public_time']));
    }
    $array['chapter'] = $array_cha;
    return hook_filter('chapter_show_data', json_encode($array, TRUE));
}
    <center><a href="index.php"><img src="images/headerlogo.png"></a></center>
        <div class="menu">
            <div class="menu-wrap">
                <ul id="main_menu">
                    <?php 
if (!isset($data)) {
    ?>
                    <li><a href="register.php">Register</a></li>
                    <?php 
} else {
    ?>
                    <li>
                        <a href="#">Earn Coins</a>
                        <ul>
                            <?php 
    $menu = hook_filter('top_menu_earn', "");
    echo $menu;
    ?>
                        </ul>
                    </li>
                    <?php 
}
?>
                    <li><a href="faq.php">FAQ</a></li>
                    <li><a href="contact.php">Contact</a></li>
                    <li><a href="stats.php">Stats</a></li>
                    <?php 
if (isset($data) && $data->admin == 1) {
    ?>
                    <li><a href="admin-panel/settings.php">Admin Panel</a></li>
                    <?php 
    ?>
</div>
        <?php 
}
?>
        <form class="sideform" method="post">
            CPC (Cost Per Click) (2 - infinite)<br/>
            <input name="cpc" type="text" value="<?php 
echo $site->cpc;
?>
"/><br/><br/>
            Referral Bonus (0 - 1)<br/>
            <input name="refbonus" type="text" value="<?php 
echo $site->refbonus;
?>
"/><br/><br/>
            Coins Discount (0 - 1)<br/>
            <input name="sale" type="text" value="<?php 
echo $site->sale;
?>
"/><br/><br/>
            <?php 
$settings = hook_filter('admin_settings', "");
echo $settings;
?>
            <input style="width:100%;" type="Submit"/>
        </form>
    </div>
</div>
<?php 
include 'footer.php';
        <?php 
    }
    if (isset($warning)) {
        ?>
        <div class="warning">WARNING: <?php 
        echo $warning;
        ?>
</div>
        <?php 
    }
    ?>
        
        <form class="contentform" method="post">
            Type<br/>
            <select name="type"><?php 
    $select = hook_filter('add_site_select', "");
    echo $select;
    ?>
</select><br/><br/>
            Link<br/>
            <input name="url" type="text" value="<?php 
    if (isset($posts["url"])) {
        echo $posts["url"];
    }
    ?>
"/><br/><br/>
            Title<br/>
            <input name="title" type="text" value="<?php 
    if (isset($posts["title"])) {
        echo $posts["title"];
    }
 $id = $id[count($id) - 1];
 $key = rand(10000, 20000);
 $url = "http://services.digg.com/1.0/endpoint?method=fan.getAll&username="******"&count=" . $key;
 $page = get_data($url);
 $plused1 = mysql_query("SELECT * FROM `dugg` WHERE `site_id`='{$posts['him']}' AND `user_id`='{$posts['me']}'");
 $plused = mysql_num_rows($plused1);
 $x = $data3->digg;
 if ($page == FALSE) {
     echo "Error: Keine Verbindung zu Digg! Bitte versuchen sie es später!";
 } else {
     if ($plused > 0) {
         echo "Error: Sie haben diesen Benutzer bereits geDiggt!";
     } else {
         if (preg_match("/{$x}/i", $page)) {
             $coins = number_format($site2->cpc - 1);
             $bonuscoins = hook_filter('bonus_coins', $coins);
             mysql_query("UPDATE `users` SET `coins`=`coins`+'{$bonuscoins}' WHERE `id`='{$posts['me']}'");
             mysql_query("UPDATE `digg` SET `exchanges`=`exchanges`+'1' WHERE `id`='{$posts['him']}'");
             mysql_query("UPDATE `users` set `coins`=`coins`-'{$site2->cpc}' WHERE `id`='{$site2->user}'");
             mysql_query("INSERT INTO `dugg` (user_id, site_id) VALUES('{$posts['me']}', '{$posts['him']}')");
             $aff1 = mysql_query("SELECT ref FROM `users` WHERE `id`='{$posts['me']}'");
             $aff = mysql_fetch_object($aff1);
             if ($aff->ref > 0) {
                 $coins = $coins * $site->refbonus;
                 mysql_query("UPDATE `users` SET `coins`=`coins`+'{$coins}' WHERE `id`='{$aff->ref}'");
             }
             echo "Sie haben den Digg abgeschlossen.Sie erhalten {$coins} Coins!";
         } else {
             echo "ERROR: Digg meldet: Sie haben den Digg nicht abgeschlossen. Bitte schließen sie den Digg erst ab!";
         }
     }
/** Cắt ảnh theo cỡ tùy chọn */
function create_image($args)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_filter('before_create_image', $args);
    hook_action('create_image');
    if (!is_array($args)) {
        parse_str($args, $args);
    }
    $file_id = $args['file'];
    if (isset_image($file_id)) {
        $row = get_file_data($file_id);
        $file_info = json_decode($row->file_info);
        $file_dst_name_body = $file_info->file_dst_name_body;
        $file_dst_name_ext = $file_info->file_dst_name_ext;
        $source_file = get_file_location($file_id);
        $crop_name = $file_dst_name_body . '-' . $args['w'] . 'x' . $args['h'] . '.' . $file_dst_name_ext;
        if (file_exists(get_file_location($file_id, FALSE) . $crop_name)) {
            return get_file_url($file_id, FALSE) . $crop_name;
        } else {
            /** resize file */
            /* fix func exif_imagetype not avaiable */
            $type = getimagesize($source_file);
            $type = $type['mime'];
            switch ($type) {
                case 'image/png':
                    $type = IMAGETYPE_PNG;
                    break;
                case 'image/jpeg':
                    $type = IMAGETYPE_JPEG;
                    break;
                case 'image/gif':
                    $type = IMAGETYPE_GIF;
                    break;
                case 'image/bmp':
                    $type = IMAGETYPE_BMP;
                    break;
                case 'image/x-ms-bmp':
                    $type = IMAGETYPE_BMP;
                    break;
            }
            /* fix func exif_imagetype not avaiable */
            switch ($type) {
                case 1:
                    $source = imageCreateFromGif($source_file);
                    break;
                case 2:
                    $source = imageCreateFromJpeg($source_file);
                    break;
                case 3:
                    $source = imageCreateFromPng($source_file);
                    break;
                case 6:
                    $source = imageCreateFromBmp($source_file);
                    break;
            }
            /** resize file gốc về cùng 1 cỡ */
            $size = getimagesize($source_file);
            $source_width = $size[0];
            $source_height = $size[1];
            $fix_width = $args['w'];
            $fix_height = $args['h'];
            $thumb = imagecreatetruecolor($fix_width, $fix_height);
            /* Fix black background */
            $white = imagecolorallocate($thumb, 255, 255, 255);
            imagefill($thumb, 0, 0, $white);
            /* Fix black background */
            /* fix quality with imagecopyresampled , repalce imagecopyresized */
            imagecopyresampled($thumb, $source, 0, 0, 0, 0, $fix_width, $fix_height, $source_width, $source_height);
            $saveto = get_file_location($file_id, FALSE) . $crop_name;
            imagejpeg($thumb, $saveto, 100);
            return get_file_url($file_id, FALSE) . $crop_name;
        }
    } else {
        return FALSE;
    }
}
Beispiel #11
0
if (isset($_SESSION["id"])) {
    $loggedIn = true;
    $result = $connection->query('SELECT * FROM users WHERE id = "' . $_SESSION["id"] . '";');
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $username = $row["name"];
            $id = $row['id'];
        }
    } else {
        $cannotFind = true;
    }
} else {
    $loggedIn = false;
}
$isAdmin = false;
if (isset($_SESSION['privledge']) && $_SESSION['privledge'] == 10) {
    $isAdmin = true;
}
$loader = new Twig_Loader_Filesystem(__DIR__ . '/../template');
$twig = new Twig_Environment($loader, array('debug' => true));
$twig->addExtension(new Twig_Extension_Debug());
$twig->addExtension(new Twig_Extensions_Extension_I18n());
$navbar_links = array();
$additional_g_navbar_content = array();
$additional_g_navbar_content = hook_filter('add_guest_navbar_content', $additional_g_navbar_content);
$additional_l_navbar_content = array();
$additional_l_navbar_content = hook_filter('add_loggedin_navbar_content', $additional_l_navbar_content);
$additional_sitename_content = array();
$additional_sitename_content = hook_filter('add_sitename_navbar_content', $additional_sitename_content);
hook_action('before_render');
echo $twig->render('header.twig', array('root_url' => ROOT_URL, 'site_name' => BOARD_NAME, 'user' => array('id' => $id, 'name' => $username), 'isAdmin' => $isAdmin, 'isLoggedIn' => $loggedIn, 'additional_guest_navbar_content' => $additional_g_navbar_content, 'additional_loggedin_navbar_content' => $additional_l_navbar_content, 'additional_sitename_content' => $additional_sitename_content));
function taxonomy_checkbox_list($args = array())
{
    hook_action('taxonomy_checkbox_list');
    hook_filter('taxonomy_checkbox_list_before', $args);
    global $hmtaxonomy;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    @($key = $args['key']);
    @($parent = $args['parent'] ? $args['parent'] : 0);
    @($default_value = $args['default_value']);
    @($object_id = $args['object_id']);
    if (is_numeric($object_id)) {
        $tableName = DB_PREFIX . "relationship";
        $whereArray = array('object_id' => MySQL::SQLValue($object_id), 'relationship' => MySQL::SQLValue('contax'));
        $hmdb->SelectRows($tableName, $whereArray);
        while ($row = $hmdb->Row()) {
            $default_value[] = $row->target_id;
        }
    }
    if (!is_array($default_value)) {
        $default_value = array();
    }
    $tax = $hmtaxonomy->hmtaxonomy;
    if (isset($tax[$key])) {
        $tableName = DB_PREFIX . "taxonomy";
        $whereArray = array('key' => MySQL::SQLValue($key), 'parent' => MySQL::SQLValue($parent), 'status' => MySQL::SQLValue('public'));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            if ($parent != 0) {
                echo '<ul class="taxonomy_tree_sub_group taxonomy_tree_sub_group_of_' . $parent . '">';
            }
            while ($row = $hmdb->Row()) {
                $taxs[] = $row;
            }
            foreach ($taxs as $tax) {
                if (in_array($tax->id, $default_value)) {
                    $checked = 'checked';
                } else {
                    $checked = '';
                }
                echo '<li data-id="' . $tax->id . '" data-slug="' . $tax->slug . '" class="tax_tree_item tax_tree_item_' . $tax->id . '">';
                echo '<input type="checkbox" name="taxonomy[]" value="' . $tax->id . '" ' . $checked . ' /> ';
                echo '<label>' . $tax->name . '</label>';
                taxonomy_checkbox_list(array('key' => $key, 'parent' => $tax->id, 'default_value' => $default_value));
                echo '</li>';
            }
            if ($parent != 0) {
                echo '</ul>';
            }
        }
    }
}
    <div class="head"><center>Welcome to <?php 
    echo $site->site_name;
    ?>
</center></div>
    <div class="contentinside">
        <center>
            <b><?php 
    echo $site->site_name;
    ?>
 is a system that will help you increase your social presence for FREE.  We allow you to pick and choose who you want to exchange with and skip those who you're not interested in.</b></font><br><br>
            <br/>
            <font size="2" color="blue"><b>You Like Hits helps you to increase all of the following:</b></font><br/><br/>
            <table width="100%">
                <tr style="font-size:13px;">
                    <?php 
    $icons = hook_filter('index_icons', "");
    echo $icons;
    ?>
                    <!--<td align="center" width="14%" valign="top"><img src="60/newsvine.png" alt="And MORE"><br><b>And MORE</b></td>-->
                </tr>
            </table>
            <br/>
            <br/>
            
        </center>
        <br/><center>
        <p><b>Only exchange who and what you're interested in!</b></p>
        <ul>
        <li><font><b> We don't sell exchanges.</b></font></li>
        <li><font><b> We abide by all Social Network Policies.</li>
        <li><font><b> We don't ask for your account passwords.</b></font></li>
function input_editor($field_array = array())
{
    hook_action('input_editor');
    $field_array = hook_filter('input_editor_input', $field_array);
    $return = '';
    if ($field_array['addClass'] != NULL) {
        $addClass = $field_array['addClass'];
    } else {
        $addClass = 'wysiwyg';
    }
    $default_value = $field_array['default_value'];
    $default_value = str_replace('&lt;', '&amp;lt;', $default_value);
    $default_value = str_replace('&gt;', '&amp;gt;', $default_value);
    $default_value = str_replace('<pre>', '&lt;pre&gt;', $default_value);
    $default_value = str_replace('</pre>', '&lt;/pre&gt;', $default_value);
    $return = $return . '<div class="form-group">' . "\n";
    if ($field_array['handle']) {
        $return = $return . '	<div class="form-group-handle"></div>';
    }
    $return = $return . '	<label for="' . $field_array['name'] . '">' . $field_array['nice_name'] . '</label>' . "\n";
    $return = $return . '	<button id="' . $field_array['name'] . '" multi="false" imageonly="true" type="button" class="btn btn-default media_btn btn-xs" data-toggle="modal" data-target="#media_box_modal">' . "\n";
    $return = $return . '		<span class="glyphicon glyphicon-picture"></span> ' . _('Thư viện') . "\n";
    $return = $return . '	</button>' . "\n";
    $return = $return . '	<p class="input_description">' . $field_array['description'] . '</p>' . "\n";
    $return = $return . '	<textarea ' . $field_array['required'] . ' name="' . $field_array['name'] . '" class="' . $addClass . '" id="' . $field_array['name'] . '">' . $default_value . '</textarea>' . "\n";
    $return = $return . '</div>' . "\n";
    $return = hook_filter('input_editor_output', $return);
    return $return;
}
Beispiel #15
0
    $category = null;
}
$page2 = $page - 1;
$page3 = $page + 1;
$result = $connection->query('SELECT * FROM topic WHERE category_id = ' . $connection->real_escape_string($_GET['id']) . ' ORDER BY id DESC LIMIT ' . $page2 * PAGE_LIMIT . ',' . $page * PAGE_LIMIT . ' ;') or die("error: " . $connection->error);
if ($result->num_rows > 0) {
    $rows = $result->num_rows;
    while ($row = $result->fetch_assoc()) {
        $topics[$row['id']] = $row;
        $topics[$row['id']]['preview'] = $bbcode->stripBBCodeTags(strlen($row['content']) > SMALL_DESC_LIMIT ? substr($row['content'], 0, SMALL_DESC_LIMIT - 3) . '...' : $row['content']);
        $topics[$row['id']]['last_updated'] = date('d/m/y G:i', strtotime($row['last_updated']));
        $result2 = $connection->query('SELECT * FROM users WHERE id = ' . $row['author_id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $topics[$row['id']]['author_name'] = $row2['name'];
            }
        }
    }
} else {
    $topics = null;
}
$additional_cat_admin_buttons = array();
$additional_cat_admin_buttons = hook_filter('add_category_admin_buttons', $additional_cat_admin_buttons);
$additional_cat_user_buttons = array();
$additional_cat_user_buttons = hook_filter('add_category_user_buttons', $additional_cat_user_buttons);
$additional_stuff_before_topics = array();
$additional_stuff_before_topics = hook_filter('add_stuff_before_topics', $additional_stuff_before_topics);
$additional_stuff_before_pages = array();
$additional_stuff_before_pages = hook_filter('add_stuff_before_pages', $additional_stuff_before_pages);
echo $twig->render('category.twig', array('siteName' => BOARD_NAME, 'isAdmin' => $isAdmin, 'isLoggedIn' => $loggedIn, 'category' => $category, 'topics' => $topics, 'additional_category_admin_buttons' => $additional_cat_admin_buttons, 'additional_category_user_buttons' => $additional_cat_user_buttons, 'before_topics' => $additional_stuff_before_topics, 'before_pages' => $additional_stuff_before_pages));
include_once 'include/footer.php';
/** bảng danh sách thành viên */
function user_show_data($user_group, $perpage)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('user_show_data');
    $request_paged = hm_get('paged', 1);
    $paged = $request_paged - 1;
    $offset = $paged * $perpage;
    $limit = "LIMIT {$perpage} OFFSET {$offset}";
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ORDER BY id DESC {$limit}")) {
        $hmdb->Kill();
    }
    if ($hmdb->HasRecords()) {
        /* Trả về các user */
        while ($row = $hmdb->Row()) {
            $array_use[] = array('id' => $row->id, 'user_nicename' => $row->user_nicename, 'user_role' => user_role_id_to_nicename($row->user_role));
        }
        $array['user'] = $array_use;
        /* Tạo pagination */
        $hmdb->Query(" SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ");
        $total_item = $hmdb->RowCount();
        $total_page = ceil($total_item / $perpage);
        $first = '1';
        if ($request_paged > 1) {
            $previous = $request_paged - 1;
        } else {
            $previous = $first;
        }
        if ($request_paged < $total_page) {
            $next = $request_paged + 1;
        } else {
            $next = $total_page;
        }
        $array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged);
    } else {
        $array['user'] = array();
        $array['pagination'] = array();
    }
    return hook_filter('user_show_data', json_encode($array, TRUE));
}
function taxonomy_get_content_key($tax_id)
{
    hook_filter('taxonomy_get_content_key', $tax_id);
    global $hmtaxonomy;
    hook_action('taxonomy_get_content_key');
    $return = $hmtaxonomy->taxonomy_get_content_key($tax_id);
    return $return;
}
    echo $menu;
    ?>
                </div>
            </div>
            <div class="sidebox">
                <div class="head">Coins</div>
                <div class="contentinside coins">
                    <center><font size="5"><b id="coins"><?php 
    echo $data->coins;
    ?>
 Coins</b></font><br/>
                    <a href="buy.php">[Buy Coins]</a></center>
                </div>
            </div>
            <?php 
    $sidebox = hook_filter('sidebox_loggedin', "");
    echo $sidebox;
    ?>
            <?php 
}
?>
        </div>
        <div class="footer">
            Copyright &copy; 2012 <a class="footername" href="<?php 
echo $site->site_url;
?>
"><?php 
echo $site->site_name;
?>
</a>
        </div>
        ?>
        <div class="warning">WARNING: <?php 
        echo $warning;
        ?>
</div>
        <?php 
    }
    ?>
        <form class="contentform" method="post">
            Email<br/>
            <input type="text" name="email" value="<?php 
    echo $data->email;
    ?>
"><br/><br/>
            <?php 
    $settings = hook_filter('settings', "");
    echo $settings;
    ?>
            Password (optional)<br/>
            <input type="password" name="password"><br/><br/>
            Verify Password<br/>
            <input type="password" name="password2"><br/><br/>
            <input style="width:100%;" type="submit" value="Update"/><br/><br/><br/><br/>
        </form>
    </div>
</div>
<?php 
} else {
    echo "Please login to view this page!";
}
include 'footer.php';
function hm_title()
{
    hook_action('before_hm_title');
    global $hmcontent;
    global $hmtaxonomy;
    $request = get_current_uri();
    $request_data = get_uri_data(array('uri' => $request));
    if ($request == '') {
        $home_title = get_option(array('section' => 'system_setting', 'key' => 'website_name', 'default_value' => 'Một trang web sử dụng HoaMaiCMS'));
        if ($home_title != '') {
            $title = '<title>' . $home_title . '</title>' . "\n\r";
        } else {
            $title = FALSE;
        }
        return hook_filter('hm_title', $title);
    } else {
        if ($request_data != FALSE) {
            $object_type = $request_data->object_type;
            $object_id = $request_data->object_id;
            switch ($object_type) {
                case 'content':
                    $content_data = content_data_by_id($object_id);
                    $title = $content_data['content']->name;
                    $title = '<title>' . $title . '</title>' . "\n\r";
                    return hook_filter('hm_title', $title);
                    break;
                case 'taxonomy':
                    $taxonomy_data = taxonomy_data_by_id($object_id);
                    $title = $taxonomy_data['taxonomy']->name;
                    $title = '<title>' . $title . '</title>' . "\n\r";
                    return hook_filter('hm_title', $title);
                    break;
            }
        } else {
            return FALSE;
        }
    }
    hook_action('after_hm_title');
}
function query_content($args = array())
{
    global $hmcontent;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_filter('before_query_content', $args);
    hook_action('query_content');
    if (!is_array($args)) {
        parse_str($args, $args);
    }
    /** Lọc theo content_key */
    if (isset($args['content_key'])) {
        /** Nếu yêu cầu content key thì lấy các id có key như query yêu cầu */
        $content_key = $args['content_key'];
        /** Nếu content key là một mảng */
        if (is_array($content_key)) {
            $where_key = '';
            $i = 0;
            foreach ($content_key as $key) {
                if ($i == 0) {
                    $where_key .= " `key` = '" . $key . "' ";
                } else {
                    $where_key .= " OR `key` = '" . $key . "' ";
                }
                $i++;
            }
            $where_content_key = "WHERE " . $where_key;
        } else {
            $where_content_key = "WHERE `key` = '" . $content_key . "'";
        }
    } else {
        /** Không yêu cầu content key, kiểm tra xem có đang ở template taxonomy không */
        if (is_taxonomy() == TRUE) {
            $taxonomy_id = get_id();
            $content_key = taxonomy_get_content_key($taxonomy_id);
            if ($content_key != FALSE) {
                $where_content_key = "WHERE `key` = '" . $content_key . "'";
            }
        } else {
            $where_content_key = '';
        }
    }
    $hmdb->Release();
    $query_content_key = "SELECT `id` FROM `" . DB_PREFIX . "content` " . $where_content_key;
    /** Lọc theo taxonomy */
    $where_taxonomy = '';
    if (isset($args['taxonomy'])) {
        /** Nếu yêu cầu trong một taxonomy nhất định thì lấy các object_id có relationship như query yêu cầu */
        $taxonomy_id = $args['taxonomy'];
        /** Nếu taxonomy là một mảng */
        if (is_array($taxonomy_id)) {
            $implode = implode($taxonomy_id, ',');
            if ($implode != '') {
                $where_taxonomy = ' WHERE `target_id` IN (' . $implode . ') ';
            }
        } else {
            $where_taxonomy = 'WHERE `target_id` = ' . $taxonomy_id;
        }
    } else {
        /** Không yêu cầu taxonomy nhất định, kiểm tra xem có đang ở template taxonomy không */
        if (is_taxonomy() == TRUE) {
            $taxonomy_id = get_id();
            $where_taxonomy = 'WHERE `target_id` = ' . $taxonomy_id;
        }
    }
    if ($where_taxonomy != '') {
        $hmdb->Release();
        $query_in_taxonomy = "SELECT `object_id` FROM `" . DB_PREFIX . "relationship` " . $where_taxonomy . " AND `relationship` = 'contax'";
    }
    /** Lọc theo field */
    if (isset($args['field_query'])) {
        $field_query = $args['field_query'];
    } else {
        $field_query = array(array('field' => 'status', 'compare' => '=', 'value' => 'public'), array('field' => 'public_time', 'compare' => '<=', 'value' => time()));
    }
    $all_field_query = array();
    foreach ($field_query as $item) {
        /** check đủ điều kiện tạo field query */
        if (isset($item['field']) and isset($item['compare']) and isset($item['value'])) {
            $field = $item['field'];
            $compare = $item['compare'];
            $value = $item['value'];
            $numerically = FALSE;
            /** build query */
            if (is_numeric($value)) {
                $value_query = $value;
            } else {
                $value_query = "'{$value}'";
            }
            if ($compare == 'like%') {
                $all_field_query[$field] = " ( `name` = '{$field}' AND `val` LIKE '%{$value}%' )";
            } else {
                $all_field_query[$field] = " ( `name` = '{$field}' AND `val` {$compare} {$value_query} )";
            }
        }
    }
    /** nếu size của mảng chứa các kết quả của các field query >= 2 */
    $size = sizeof($all_field_query);
    $query_field = "SELECT `object_id` FROM `" . DB_PREFIX . "field` WHERE";
    if ($size > 1) {
        if (isset($args['field_query_relation'])) {
            $field_query_relation = $args['field_query_relation'];
        } else {
            $field_query_relation = 'and';
        }
        switch ($field_query_relation) {
            case 'or':
                $i = 0;
                foreach ($all_field_query as $single_field_query) {
                    if ($i == 0) {
                        $query_field .= " " . $single_field_query . " ";
                    } else {
                        $query_field .= " OR " . $single_field_query . " ";
                    }
                    $i++;
                }
                break;
            case 'and':
                $i = 0;
                foreach ($all_field_query as $single_field_query) {
                    if ($i == 0) {
                        $query_field .= " " . $single_field_query . " ";
                    } else {
                        $query_field .= " OR " . $single_field_query . " ";
                    }
                    $i++;
                }
                $query_field .= " GROUP BY  `object_id`  HAVING COUNT(*) = {$size} ";
                break;
        }
        /** 
         * Đưa ra kết quả dựa trên mối quan hệ giữa các field query ( field_query_relation )
         * ( thỏa mãn tất cả các field query hay chỉ cần đáp ứng được 1 trong những field query )
         */
    } else {
        $query_field = $query_field . array_shift(array_values($all_field_query));
    }
    /** Kiểm tra yêu cầu kết hợp kết quả từ content key, in taxonomy, field query là tất cả hay chỉ 1 */
    if (isset($args['join'])) {
        $join = $args['join'];
    } else {
        $join = 'and';
    }
    $query_join = '';
    switch ($join) {
        case 'or':
            if ($query_content_key) {
                $query_join .= " AND `object_id` IN (" . $query_content_key . ") ";
            }
            if ($query_in_taxonomy) {
                $query_join .= " OR `object_id` IN (" . $query_in_taxonomy . ") ";
            }
            $query_join .= " OR `object_id` IN (" . $query_field . ") ";
            break;
        case 'and':
            if ($query_content_key) {
                $query_join .= " AND `object_id` IN (" . $query_content_key . ") ";
            }
            if ($query_in_taxonomy) {
                $query_join .= " AND `object_id` IN (" . $query_in_taxonomy . ") ";
            }
            $query_join .= " AND `object_id` IN (" . $query_field . ") ";
            break;
        default:
            if ($query_content_key) {
                $query_join .= " AND `object_id` IN (" . $query_content_key . ") ";
            }
            if ($query_in_taxonomy) {
                $query_join .= " AND `object_id` IN (" . $query_in_taxonomy . ") ";
            }
            $query_join .= " AND `object_id` IN (" . $query_field . ") ";
    }
    /** Kết thúc các query lấy các content id thỏa mãn yêu cầu */
    /** Order theo 1 field  và limit */
    if (isset($args['order'])) {
        $order_by = $args['order'];
    } else {
        $order_by = 'public_time,desc,number';
    }
    if (isset($args['limit'])) {
        $limit = $args['limit'];
    } else {
        $limit = get_option(array('section' => 'system_setting', 'key' => 'post_per_page', 'default_value' => '12'));
    }
    if (isset($args['offset']) and is_numeric($args['offset'])) {
        $offset = $args['offset'];
    } else {
        $offset = 0;
    }
    if (isset($args['paged'])) {
        $paged = $args['paged'];
    } else {
        $paged = get_current_pagination();
    }
    $paged = $paged - 1;
    if ($paged < 0) {
        $paged = 0;
    }
    /** Tạo query ORDER */
    $ex = explode(',', $order_by);
    $ex = array_map("trim", $ex);
    $order_field = $ex[0];
    $order = strtoupper($ex[1]);
    if (isset($ex[2])) {
        $numerically = $ex[2];
    } else {
        $numerically = FALSE;
    }
    if ($numerically == 'number') {
        $order_query = " AND `name` = '" . $order_field . "' ORDER BY CAST(val AS unsigned) " . $order . " ";
    } else {
        $order_query = " AND `name` = '" . $order_field . "' ORDER BY `val` " . $order . " ";
    }
    /** Tạo query LIMIT */
    if (is_numeric($limit)) {
        $limit_query = " LIMIT {$limit} ";
    } else {
        $limit_query = '';
    }
    /** Tạo query OFFSET */
    if ($limit == FALSE) {
        $offset_query = '';
    } else {
        $offset_query_page = $paged * $limit;
        $offset_query_page = $offset_query_page + $offset;
        $offset_query = " OFFSET {$offset_query_page} ";
    }
    /** Tạo câu lệnh select từ chuỗi các id thỏa mãn */
    $result = array();
    $sql = "SELECT `object_id`" . " FROM `" . DB_PREFIX . "field`" . " WHERE `object_type` = 'content'" . " " . $query_join . " " . " " . $order_query . " ";
    $hmdb->Query($sql);
    $total_result = $hmdb->RowCount();
    $sql = "SELECT `object_id`" . " FROM `" . DB_PREFIX . "field`" . " WHERE `object_type` = 'content'" . " " . $query_join . " " . " " . $order_query . " " . $limit_query . " " . $offset_query . " ";
    $hmdb->Query($sql);
    $base = get_current_uri();
    if ($base == '') {
        $base = '/';
    }
    $hmcontent->set_val(array('key' => 'total_result', 'val' => $total_result));
    $hmcontent->set_val(array('key' => 'paged', 'val' => $paged + 1));
    $hmcontent->set_val(array('key' => 'perpage', 'val' => $limit));
    $hmcontent->set_val(array('key' => 'base', 'val' => $base));
    while ($row = $hmdb->Row()) {
        $result[] = $row->object_id;
    }
    return $result;
}
?>
<div class="contentbox">
    <div class="head">Stats</div>
    <div class="contentinside">
        <h2>Members</h2>
        <table cellpadding="5" class="siteslist">
            <tr><td width="60">Users</td><td width="200">Banned</td><td width="200">Total</td></tr>
            <tr><td><?php 
echo $users - $banned;
?>
</td><td><?php 
echo $banned;
?>
</td><td><?php 
echo $users;
?>
</td></tr>
        </table>
        <br/>
        <h2>Websites</h2>
        <table cellpadding="5" class="siteslist">
            <tr><td width="60">Type</td><td width="200">Website</td><td width="200">Clicks</td></tr>
            <?php 
$stats = hook_filter('stats', "");
echo $stats;
?>
        </table>
    </div>
</div>
<?php 
include 'footer.php';
    $gets[$key] = filter($value);
}
?>
<div class="contentbox">
    <div class="head">Sites</div>
    <div class="contentinside">
        <div class="site_menu">
            <?php 
$menu = hook_filter('site_menu', "");
echo $menu;
?>
        </div>
        <?php 
if (isset($gets["p"])) {
    echo '<div class="site_content">';
    $db = hook_filter($gets["p"] . '_info', "db");
    $sites = mysql_query("SELECT * FROM `{$db}`");
    ?>
            <table cellpadding="5" class="siteslist"><tr><td width="60">User</td><td>Title</td><td width="60">CPC</td><td width="60">Status</td><td width="60">Edit</td></tr>
            <?php 
    for ($x = 1; $mysite = mysql_fetch_object($sites); $x++) {
        $status = $mysite->active;
        if ($status == 0) {
            $status = "Enabled";
        } else {
            $status = "Disabled";
        }
        echo "<tr><td>{$mysite->user}</td><td>{$mysite->title}</td><td>{$mysite->cpc}</td><td>{$status}</td><td><a href='editsite.php?x={$mysite->id}&y={$gets['p']}'>Edit</a></td></tr>";
    }
    ?>
            </table>
function content_show_data($key, $status, $perpage)
{
    global $hmcontent;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('content_show_data');
    $request_paged = hm_get('paged', 1);
    $paged = $request_paged - 1;
    $offset = $paged * $perpage;
    $limit = "LIMIT {$perpage} OFFSET {$offset}";
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "content WHERE `key` = '{$key}' AND status = '{$status}' ORDER BY id DESC {$limit}")) {
        $hmdb->Kill();
    }
    if ($hmdb->HasRecords()) {
        /* Trả về các content */
        while ($row = $hmdb->Row()) {
            $array_con[] = array('id' => $row->id, 'name' => $row->name, 'slug' => $row->slug);
        }
        $array['content'] = $array_con;
        /* Tạo pagination */
        $hmdb->Query(" SELECT * FROM " . DB_PREFIX . "content WHERE `key` = '{$key}' AND status = '{$status}' ");
        $total_item = $hmdb->RowCount();
        $total_page = ceil($total_item / $perpage);
        $first = '1';
        if ($request_paged > 1) {
            $previous = $request_paged - 1;
        } else {
            $previous = $first;
        }
        if ($request_paged < $total_page) {
            $next = $request_paged + 1;
        } else {
            $next = $total_page;
        }
        $array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged);
        $all_content = $hmcontent->hmcontent;
        if (isset($all_content[$key]['chapter']) and $all_content[$key]['chapter'] == TRUE) {
            $array['chapter'] = TRUE;
        } else {
            $array['chapter'] = FALSE;
        }
    } else {
        $array['content'] = array();
        $array['pagination'] = array();
        $array['chapter'] = FALSE;
    }
    return hook_filter('content_show_data', json_encode($array, TRUE));
}
Beispiel #25
0
        $result2 = $connection->query('SELECT * FROM category WHERE id = ' . $row['category_id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $topic[$row['id']]['category_name'] = $row2['name'];
            }
        }
        $result2 = $connection->query('SELECT * FROM comments WHERE topic_id = ' . $row['id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $comments[$row2['id']] = $row2;
                $comments[$row2['id']]['content'] = $bbcode->parseCaseInsensitive(nl2br($row2['content']));
                $comments[$row2['id']]['raw_content'] = javascript_escape($row2['content']);
                $result3 = $connection->query('SELECT * FROM users WHERE id = ' . $row2['author_id']);
                if ($result3->num_rows > 0) {
                    while ($row3 = $result3->fetch_assoc()) {
                        $comments[$row2['id']]['author_name'] = $row3['name'];
                        $comments[$row2['id']]['author_name_safe'] = javascript_escape($row3['name']);
                    }
                }
            }
        }
    }
}
$additional_topic_admin_buttons = array();
$additional_topic_admin_buttons = hook_filter('add_topic_admin_buttons', $additional_topic_admin_buttons);
$additional_stuff_before_comments = array();
$additional_stuff_before_comments = hook_filter('add_stuff_before_comments', $additional_stuff_before_comments);
$additional_stuff_before_topiccontent = array();
$additional_stuff_before_topiccontent = hook_filter('add_stuff_before_topic_content', $additional_stuff_before_topiccontent);
echo $twig->render('topic.twig', array('site_name' => BOARD_NAME, 'isAdmin' => $isAdmin, 'isLoggedIn' => $loggedIn, 'topic' => $topic, 'comments' => $comments, 'additional_topic_admin_buttons', $additional_topic_admin_buttons, 'before_comments' => $additional_stuff_before_comments, 'additional_stuff_before_topiccontent' => $additional_stuff_before_topiccontent, 'currentURL' => "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"));
include_once 'include/footer.php';
<?php

include 'header.php';
foreach ($_GET as $key => $value) {
    $gets[$key] = filter($value);
}
foreach ($_POST as $key => $value) {
    $posts[$key] = filter($value);
}
$id = $gets["x"];
$db = $gets["y"];
$type = hook_filter($db . '_info', "type");
$db = hook_filter($db . '_info', "db");
if (isset($posts["title"])) {
    mysql_query("UPDATE `{$db}` SET `title` = '{$posts['title']}', `cpc` = '{$posts['cpc']}', `active` = '{$posts['active']}' where `id` = '{$id}'");
    $success = "Your site has been updated!";
}
if (isset($gets["f"])) {
    mysql_query("DELETE from `{$db}` where `id` = '{$id}'");
    ?>
<script>window.location = "sites.php";</script><?php 
    exit;
}
$mysite = mysql_query("SELECT * FROM `{$db}` WHERE `id`='{$id}'");
$mysite = mysql_fetch_object($mysite);
?>
<script>
function deletesite()
{
    if (confirm('Are you sure you would like to delete this site?'))
    {