function admin_menu_command()
{
    hook_action('admin_menu_command_before');
    echo '<li><a href="?run=command.php">' . _('Sử dụng lệnh') . '<span class="sub_icon fa fa-terminal"></span></a>' . "\n";
    echo '</li>' . "\n";
    hook_action('admin_menu_command_after');
}
/** Đăng nhập admin cp */
function admin_cp_login()
{
    global $hmuser;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('admin_cp_login');
    $user_login = hm_post('login');
    $password = hm_post('password');
    $logmein = hm_post('log-me-in');
    if (is_numeric($logmein)) {
        $tableName = DB_PREFIX . "users";
        $whereArray = array('user_login' => MySQL::SQLValue($user_login));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            $row = $hmdb->Row();
            $salt = $row->salt;
            $user_pass = $row->user_pass;
            $password_encode = hm_encode_str(md5($password . $salt));
            if ($password_encode == $user_pass) {
                $time = time();
                $ip = hm_ip();
                $cookie_array = array('time' => $time, 'ip' => $ip, 'user_login' => $user_login, 'admincp' => 'yes');
                $cookie_user = hm_encode_str($cookie_array);
                setcookie('admin_login', $cookie_user, time() + COOKIE_EXPIRES, '/');
                $_SESSION['admin_login'] = $cookie_user;
                return json_encode(array('status' => 'success', 'mes' => _('Đăng nhập thành công')));
            } else {
                return json_encode(array('status' => 'error', 'mes' => _('Sai mật khẩu')));
            }
        } else {
            return json_encode(array('status' => 'error', 'mes' => _('Không có tài khoản này')));
        }
    }
}
Esempio n. 3
0
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;
    }
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
    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));
}
Esempio n. 8
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_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;
}
Esempio n. 10
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
$host = "localhost";
// your mysql server address
$user = "******";
// your mysql username
$pass = "******";
// your mysql password
$tablename = "SQLDATABASENAME";
// your mysql table
session_start();
$data = null;
if (!(@mysql_connect("{$host}", "{$user}", "{$pass}") && @mysql_select_db("{$tablename}"))) {
    ?>
    <html>
    MSQL ERROR
    <?php 
    exit;
}
include_once 'functions.php';
require_once "includes/pluggable.php";
foreach (glob("plugins/*/index.php") as $plugin) {
    require_once $plugin;
}
hook_action('initialize');
$site = mysql_fetch_object(mysql_query("SELECT * FROM settings"));
/** 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));
}
Esempio n. 12
0
/** Hiển thị giao diện dashboard */
function admin_content_page()
{
    hook_action('admin_our_team_before');
    require_once BASEPATH . HM_ADMINCP_DIR . '/' . LAYOUT_DIR . '/' . 'our_team.php';
    hook_action('admin_our_team_after');
}
Esempio n. 13
0
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;
}
/** Đăng xuất admin cp */
function admin_cp_logout()
{
    hook_action('admin_cp_logout');
    $back = hm_get('back', SITE_URL);
    setcookie('admin_login', $_SESSION['admin_login'], 1);
    unset($_SESSION['admin_login']);
    header('Location: ' . $back);
    hm_edit('Đang thoát tài khoản');
}
Esempio n. 15
0
 */
if (!defined('BASEPATH')) {
    exit('403');
}
/**
 * Khởi tạo 1 taxonomy mặc định có tên là "Danh mục bài viết" và key là "category" 
 * cho dạng nội dung "post" và định nghĩa các trường nhập vào
 * Lưu ý : Luôn phải có 1 trường có key là primary_name_field, trường này sẽ được dùng là tên của
 * content, taxonomy và trường này có 'create_slug'=>TRUE để tạo slug - đường dẫn tĩnh cho content, taxonomy này
 */
hook_action('before_web_setup');
$field_array = array('primary_name_field' => array('nice_name' => 'Tên danh mục', 'description' => 'Tên là cách nó xuất hiện trên trang web của bạn', 'name' => 'name', 'create_slug' => TRUE, 'input_type' => 'text', 'default_value' => '', 'placeholder' => 'Nhập tiêu đề tại đây', 'required' => TRUE), array('nice_name' => 'Mô tả danh mục', 'description' => 'Một đoạn văn bản ngắn mô tả về danh mục này, tất nhiên nó chỉ hiện thị nếu giao diện bạn dùng có hỗ trợ', 'name' => 'description', 'input_type' => 'textarea', 'default_value' => '', 'placeholder' => '', 'required' => FALSE));
$args = array('taxonomy_name' => 'Danh mục bài viết', 'taxonomy_key' => 'category', 'content_key' => 'post', 'all_items' => 'Tất cả danh mục', 'edit_item' => 'Sửa danh mục', 'view_item' => 'Xem danh mục', 'update_item' => 'Cập nhật danh mục', 'add_new_item' => 'Thêm danh mục mới', 'new_item_name' => 'Tên danh mục mới', 'parent_item' => 'Danh mục cha', 'no_parent' => 'Không có danh mục cha', 'search_items' => 'Tìm kiếm danh mục', 'popular_items' => 'Danh mục dùng nhiều', 'taxonomy_field' => $field_array, 'primary_name_field' => $field_array['primary_name_field']);
register_taxonomy($args);
/**
 * Khởi tạo 1 content mặc định là "Bài viết" sử dụng kiểu taxonomy là "Danh mục bài viết" 
 * đã khởi tạo ở trên, vì ở trên taxonomy "Danh mục bài viết" đã đăng ký content_key là "post"
 * nên dạng nội dung này sẽ có content_key là "post" để dùng được trong "Danh mục bài viết"
 */
$field_array = array('primary_name_field' => array('nice_name' => 'Tên bài viết', 'name' => 'name', 'create_slug' => TRUE, 'input_type' => 'text', 'default_value' => '', 'placeholder' => 'Tiêu đề bài viết', 'required' => TRUE), array('nice_name' => 'Mô tả bài viết', 'description' => 'Mô tả ngắn gọn về nội dung của bài viết này', 'name' => 'description', 'input_type' => 'textarea', 'default_value' => '', 'placeholder' => '', 'required' => FALSE), array('nice_name' => 'Nội dung bài viết', 'name' => 'content', 'input_type' => 'wysiwyg', 'default_value' => '', 'placeholder' => '', 'required' => FALSE));
$args = array('content_name' => 'Bài viết', 'taxonomy_key' => 'category', 'content_key' => 'post', 'all_items' => 'Tất cả bài viết', 'edit_item' => 'Sửa bài viết', 'view_item' => 'Xem bài viết', 'update_item' => 'Cập nhật bài viết', 'add_new_item' => 'Thêm bài viết mới', 'new_item_name' => 'Tên bài viết mới', 'chapter' => FALSE, 'search_items' => 'Tìm kiếm bài viết', 'content_field' => $field_array, 'primary_name_field' => $field_array['primary_name_field']);
register_content($args);
/**
 * Trong quản trị ngoài việc khai báo các trường bắt buộc cho thành viên như
 * tên đăng nhập, mật khẩu ... Bạn có thể bổ sung thêm các trường cần cho website của bạn
 * như skype, email, số điện thoại ... như dưới đây
 */
$args = array(array('nice_name' => 'Email', 'name' => 'name', 'input_type' => 'email', 'default_value' => '', 'placeholder' => 'Email của người dùng', 'required' => FALSE), array('nice_name' => 'Skype', 'name' => 'skype', 'input_type' => 'text', 'default_value' => '', 'placeholder' => 'Skype của người dùng', 'required' => FALSE), array('nice_name' => 'Yahoo', 'name' => 'yahoo', 'input_type' => 'text', 'default_value' => '', 'placeholder' => 'Yahoo của người dùng', 'required' => FALSE), array('nice_name' => 'Số điện thoại', 'name' => 'phone', 'input_type' => 'text', 'default_value' => '', 'placeholder' => 'Nhập số điện thoại', 'required' => FALSE), array('nice_name' => 'Thông tin cá nhân', 'name' => 'bio', 'input_type' => 'textarea', 'default_value' => '', 'placeholder' => 'Giới thiệu về bản thân', 'required' => FALSE));
register_user_field($args);
hook_action('after_web_setup');
/** Load template media box */
function ajax_media_box()
{
    hook_action('ajax_media_box');
    require_once BASEPATH . HM_ADMINCP_DIR . '/' . TEMPLATE_DIR . '/' . 'ajax_media_box.php';
}
Esempio n. 17
0
function get_admin_setting_page()
{
    hook_action('get_admin_setting_page');
    global $setting_page;
    return $setting_page;
}
Esempio n. 18
0
/** 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;
    }
}
function taxonomy_delete_permanently($id)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('taxonomy_delete_permanently');
    if (isset_taxonomy_id($id) == TRUE) {
        $tableName = DB_PREFIX . "taxonomy";
        /* update lại parent các sub taxonomy */
        $valuesArray = array('parent' => MySQL::SQLValue(0));
        $whereArray = array('parent' => MySQL::SQLValue($id));
        $hmdb->UpdateRows($tableName, $valuesArray, $whereArray);
        /* xóa bảng taxonomy */
        $whereArray = array('id' => MySQL::SQLValue($id));
        $hmdb->DeleteRows($tableName, $whereArray);
        /* xóa bảng field */
        $tableName = DB_PREFIX . "field";
        $whereArray = array('object_id' => MySQL::SQLValue($id), 'object_type' => MySQL::SQLValue('taxonomy'));
        $hmdb->DeleteRows($tableName, $whereArray);
        /* xóa bảng relationship */
        $tableName = DB_PREFIX . "relationship";
        $whereArray = array('object_id' => MySQL::SQLValue($id));
        $hmdb->DeleteRows($tableName, $whereArray);
        /* xóa bảng request uri */
        $tableName = DB_PREFIX . "request_uri";
        $whereArray = array('object_id' => MySQL::SQLValue($id), 'object_type' => MySQL::SQLValue('taxonomy'));
        $hmdb->DeleteRows($tableName, $whereArray);
    }
}
        $i++;
    }
}
/** cập nhật menu cha của menu item */
function update_menu_item_children($id, $children)
{
    hook_action('update_menu_item_children');
    global $hmdb;
    $tableName = DB_PREFIX . "object";
    $i = 1;
    foreach ($children as $children_array) {
        $children_id = $children_array['id'];
        /** cập nhật thứ tự và menu cha */
        $valuesArray = array('order_number' => MySQL::SQLValue($i), 'parent' => MySQL::SQLValue($id));
        $whereArray = array('key' => MySQL::SQLValue('menu_item'), 'id' => MySQL::SQLValue($children_id));
        $hmdb->UpdateRows($tableName, $valuesArray, $whereArray);
        if (isset($children_array['children'])) {
            $sub_children = $children_array['children'];
            update_menu_item_children($children_id, $sub_children);
        }
Esempio n. 21
0
function hm_footer()
{
    hook_action('before_hm_footer');
    hook_action('after_hm_footer');
}
Esempio n. 22
0
require_once dirname(__FILE__) . '/admin.php';
/** gọi model xử lý dashboard */
require_once dirname(__FILE__) . '/dashboard/dashboard_model.php';
/** Hiển thị giao diện dashboard */
function admin_content_page()
{
    hook_action('admin_content_page_dashboard_before');
function content_delete_permanently($id)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('content_delete_permanently');
    if (is_numeric($id)) {
        /* xóa bảng content */
        $tableName = DB_PREFIX . "content";
        $whereArray = array('id' => MySQL::SQLValue($id));
        $hmdb->DeleteRows($tableName, $whereArray);
        /** Tìm các sub content */
        $whereArray = array('parent' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        $ids = array();
        while ($row = $hmdb->Row()) {
            $ids[] = $row->id;
        }
        foreach ($ids as $delete_id) {
            /** xóa các sub content */
            $tableName = DB_PREFIX . "content";
            $whereArray = array('id' => MySQL::SQLValue($delete_id));
            $hmdb->DeleteRows($tableName, $whereArray);
            /** xóa các sub content field */
            $tableName = DB_PREFIX . "field";
            $whereArray = array('object_id' => MySQL::SQLValue($delete_id), 'object_type' => MySQL::SQLValue('content'));
            $hmdb->DeleteRows($tableName, $whereArray);
            /* xóa các relationship */
            $tableName = DB_PREFIX . "relationship";
            $whereArray = array('object_id' => MySQL::SQLValue($delete_id));
            $hmdb->DeleteRows($tableName, $whereArray);
            /** xóa các sub request */
            $tableName = DB_PREFIX . "request_uri";
            $whereArray = array('object_id' => MySQL::SQLValue($delete_id));
            $hmdb->DeleteRows($tableName, $whereArray);
        }
        /* xóa bảng field */
        $tableName = DB_PREFIX . "field";
        $whereArray = array('object_id' => MySQL::SQLValue($id), 'object_type' => MySQL::SQLValue('content'));
        $hmdb->DeleteRows($tableName, $whereArray);
        /* xóa bảng relationship */
        $tableName = DB_PREFIX . "relationship";
        $whereArray = array('object_id' => MySQL::SQLValue($id));
        $hmdb->DeleteRows($tableName, $whereArray);
        /* xóa bảng request uri */
        $tableName = DB_PREFIX . "request_uri";
        $whereArray = array('object_id' => MySQL::SQLValue($id), 'object_type' => MySQL::SQLValue('content'));
        $hmdb->DeleteRows($tableName, $whereArray);
    }
}