Example #1
0
 function do_manage($is_show = "")
 {
     global $ttH;
     $err = "";
     //update
     if (isset($ttH->input['do_action'])) {
         $up_id = isset($ttH->input["selected_id"]) ? $ttH->input["selected_id"] : array();
         switch ($ttH->input["do_action"]) {
             case "do_edit":
                 $arr_show_order = isset($ttH->post["show_order"]) ? $ttH->post["show_order"] : array();
                 $arr_is_show = isset($ttH->post["is_show"]) ? $ttH->post["is_show"] : array();
                 $mess = $ttH->lang['global']['edit_success'] . " ID: <strong>";
                 $str_mess = "";
                 for ($i = 0; $i < count($up_id); $i++) {
                     $dup = array();
                     //$dup['show_order'] = $arr_show_order[$up_id[$i]];
                     $dup['is_show'] = $arr_is_show[$up_id[$i]];
                     $ok = $ttH->db->do_update("user", $dup, "user_id=" . $up_id[$i]);
                     if ($ok) {
                         $str_mess .= $str_mess ? ", " : "";
                         $str_mess .= $up_id[$i];
                     } else {
                         $mess .= $ttH->lang["global"]['edit_false'] . " ID: <strong>" . $up_id[$i] . "</strong>";
                     }
                 }
                 $mess .= $str_mess . "</strong>";
                 $err = $ttH->html->html_alert($mess, "success");
                 break;
             case "do_del":
                 if (isset($ttH->input['id'])) {
                     $list_del = $ttH->input['id'];
                 } elseif (isset($ttH->post['selected_id']) && is_array($ttH->post['selected_id'])) {
                     $list_del = @implode(',', $ttH->post['selected_id']);
                 }
                 $err = $this->do_del($list_del);
                 break;
         }
     }
     $p = isset($ttH->input["p"]) ? $ttH->input["p"] : 1;
     $search_date_begin = isset($ttH->input["search_date_begin"]) ? $ttH->input["search_date_begin"] : "";
     $search_date_end = isset($ttH->input["search_date_end"]) ? $ttH->input["search_date_end"] : "";
     $search_group_id = isset($ttH->input["search_group_id"]) ? $ttH->input["search_group_id"] : 0;
     $search_title = isset($ttH->input["search_title"]) ? $ttH->input["search_title"] : "";
     $where = " where user_id>0 ";
     $ext = "";
     if ($search_date_begin || $search_date_end) {
         $tmp1 = @explode("/", $search_date_begin);
         $time_begin = @mktime(0, 0, 0, $tmp1[1], $tmp1[0], $tmp1[2]);
         $tmp2 = @explode("/", $search_date_end);
         $time_end = @mktime(23, 59, 59, $tmp2[1], $tmp2[0], $tmp2[2]);
         $where .= " AND (date_create BETWEEN {$time_begin} AND {$time_end} ) ";
         $ext .= "&date_begin=" . $search_date_begin . "&date_end=" . $search_date_end;
     }
     if (!empty($search_group_id)) {
         $where .= " and group_id='" . $search_group_id . "' ";
         $ext .= "&search_group_id=" . $search_group_id;
     }
     if (!empty($search_title)) {
         $where .= " and (\r\r\n\t\t\t\tuser_id='{$search_title}' \r\r\n\t\t\t\tor username like '%{$search_title}%'\r\r\n\t\t\t\tor nickname like '%{$search_title}%'\r\r\n\t\t\t\tor email like '%{$search_title}%'\r\r\n\t\t\t\tor address like '%{$search_title}%'\r\r\n\t\t\t) ";
         $ext .= "&search_title=" . $search_title;
     }
     $num_total = 0;
     $res_num = $ttH->db->query("select user_id from user " . $where . " ");
     $num_total = $ttH->db->num_rows($res_num);
     $n = $ttH->conf["n_list"] ? $ttH->conf["n_list"] : 30;
     $num_pages = ceil($num_total / $n);
     if ($p > $num_pages) {
         $p = $num_pages;
     }
     if ($p < 1) {
         $p = 1;
     }
     $start = ($p - 1) * $n;
     $link_action = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub);
     //Sort
     $arr_title = array("user_id" => array("title" => $ttH->lang["global"]["id"], "link" => $link_action . "&p=" . $p . $ext . "&sort=user_id-desc", "class" => ""), "username" => array("title" => $ttH->lang["user"]["username"], "link" => $link_action . "&p=" . $p . $ext . "&sort=username-desc", "class" => ""), "nickname" => array("title" => $ttH->lang["user"]["nickname"], "link" => $link_action . "&p=" . $p . $ext . "&sort=nickname-desc", "class" => ""), "is_show" => array("title" => $ttH->lang["user"]["status"], "link" => $link_action . "&p=" . $p . $ext . "&sort=is_show-desc", "class" => ""), "date_create" => array("title" => $ttH->lang["global"]["date_create"], "link" => $link_action . "&p=" . $p . $ext . "&sort=date_create-desc", "class" => ""));
     $sort = isset($ttH->input["sort"]) ? $ttH->input["sort"] : "";
     if ($sort) {
         $arr_allow_sort = array(1 => "asc", 2 => "desc");
         $tmp = explode("-", $sort);
         if (array_key_exists($tmp[0], $arr_title) && in_array($tmp[1], $arr_allow_sort)) {
             $order_tmp = $tmp[0] == "user_id" ? "a.user_id" : $tmp[0];
             $where .= " order by " . $order_tmp . " " . $tmp[1];
             $arr_title[$tmp[0]]["class"] = $tmp[1];
             $arr_title[$tmp[0]]["link"] = $link_action . "&p=" . $p . $ext . "&sort=" . $tmp[0] . "-" . $arr_allow_sort[3 - array_search($tmp[1], $arr_allow_sort)];
         } else {
             $sort = "";
         }
     }
     if ($sort == "") {
         $where .= " order by date_create DESC";
     }
     //End sort
     //Title row
     foreach ($arr_title as $k => $v) {
         $class = $v["class"] ? " class='" . $v["class"] . "'" : "";
         $data["f_" . $k] = '<a href="' . $v["link"] . '" ' . $class . '>' . $v["title"] . '</a>';
     }
     //End title row
     $sql = "select * from user " . $where . " limit {$start},{$n}";
     //echo $sql;
     $nav = $ttH->admin->admin_paginate($link_action, $num_total, $n, $ext, $p);
     $result = $ttH->db->query($sql);
     $i = 0;
     $html_row = "";
     if ($num = $ttH->db->num_rows($result)) {
         while ($row = $ttH->db->fetch_row($result)) {
             $i++;
             $row["link_edit"] = $ttH->admin->get_link_admin($this->modules, $this->action, "edit", array("id" => $row['user_id']));
             $row["link_trash"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_trash", "id" => $row['user_id']));
             $row["link_restore"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_restore", "id" => $row['user_id']));
             $row["link_del"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("do_action" => "do_del", "id" => $row['user_id']));
             $row["status"] = status_info($row["is_show"]);
             $row['is_show'] = list_status("is_show[" . $row['user_id'] . "]", $row['is_show'], "  onchange=\"do_check (" . $row['user_id'] . ")\" style=\"width:100%;\"");
             $ttH->temp_act->assign('row', $row);
             $ttH->temp_act->parse("manage.row_item");
         }
     } else {
         $ttH->temp_act->assign('row', array("mess" => $ttH->lang["global"]["no_have_data"]));
         $ttH->temp_act->parse("manage.row_empty");
     }
     $data['html_row'] = $html_row;
     $data['nav'] = $nav;
     $data['err'] = $err;
     $data['link_action_search'] = $link_action;
     $data['link_action'] = $link_action . "&p=" . $p . $ext;
     $data['search_date_begin'] = $search_date_begin;
     $data['search_date_end'] = $search_date_end;
     $data['search_title'] = $search_title;
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse("manage");
     return $ttH->temp_act->text("manage");
 }
Example #2
0
    exit;
}
if (isset($_GET["enable-service"])) {
    enable_service();
    exit;
}
if (isset($_GET["execute-wizard"])) {
    execute_wizard();
    exit;
}
if (isset($_GET["import"])) {
    import();
    exit;
}
if (isset($_GET["status-infos"])) {
    status_info();
    exit;
}
if (isset($_GET["delete-cache"])) {
    delete_cache();
    exit;
}
if (isset($_GET["sync-freewebs"])) {
    sync_freewebs();
    exit;
}
if (isset($_GET["www-events"])) {
    www_events();
    exit;
}
if (isset($_GET["mysqldb-restart"])) {