Example #1
0
 public function get_meter_z136_z138()
 {
     $year = $this->input->post('year');
     $rs = $this->dash->get_meter_z136_z138($year);
     $json = '{"success": true, "rows": ' . json_encode($rs) . '}';
     render_json($json);
 }
Example #2
0
 public function get_top10()
 {
     $year = $this->input->post('year');
     $code = $this->input->post('code');
     $rs = $this->reports->get_top10($year, $code);
     $json = '{"success": true, "rows": ' . json_encode($rs) . '}';
     render_json($json);
 }
Example #3
0
 public function del_village_base()
 {
     //$password = $this->encode($this->input->post('password'));
     //$id=$this->session->userdata('user_id');
     $villid = $this->input->post('villid');
     $rs = $this->setting->del_village_base($villid);
     if ($rs) {
         $json = '{"success": true}';
     } else {
         $json = '{"success": false}';
     }
     render_json($json);
 }
Example #4
0
function require_admin($who = false)
{
    if (!$who) {
        $who = get_loggedin_info();
    }
    require_authenticated($who);
    // Pass $who as a parameter so it doesn't need to be requested again.
    if (array_key_exists("user", $who)) {
        if ($who['user']['IsAdmin']) {
            return true;
        }
    }
    // If any of those if statements above fail, and the function does not return, the user must not be an admin.
    $app = \Slim\Slim::getInstance();
    $app->response->setStatus(401);
    render_json(array("error" => true, "message" => "Endpoint is for administrators only."));
    return false;
}
Example #5
0
 public function send_mail_add_order($email)
 {
     //$username=$this->input->post('username');
     //$url=site_url('users/login');
     $url = 'http://203.157.185.18/mis/kpi/index.php/users/login';
     //$email=$this->input->post('email');
     $sys_name = $this->users->get_sys_name($this->input->post('sys_id'));
     $email_from = '*****@*****.**';
     $email_name = 'ระบบ Orders';
     $to_list = $email;
     $replay_to = '*****@*****.**';
     $subject = 'มีการสั่งซื้อใหม่';
     //$message='ccc';
     $message = "<b>ท่านได้รับ อนุมัติ ให้ใช้ระบบ " . $sys_name . " แล้ว</b><br>";
     $message .= "ท่านสามารถเข้าสู่ระบบได้ที่  <a href='" . $url . "'>" . $url . "</a>";
     $message .= "<br><br> Admin User Center Mahasarakham <br> thait-rex@hotmail.com";
     $this->send($email_from, $email_name, $to_list, $replay_to, $subject, $message);
     $json = '{"success": true, "msg":" ส่ง Email เรียบร้อยแล้ว กรุณาตรวจสอบ " }';
     render_json($json);
 }
Example #6
0
 public function check_person_audit()
 {
     $cid = $this->input->post('cid');
     $hospcode = $this->input->post('hospcode');
     $rs = $this->audit->get_person_audit($cid, $hospcode);
     if ($rs) {
         $json = '{"success": true,"check":true}';
     } else {
         $json = '{"success": true,"check":false}';
     }
     render_json($json);
 }
Example #7
0
 public function check_person_off_id()
 {
     $cid = $this->input->post('cid');
     $off_id = $this->input->post('off_id');
     $rs = $this->basic->get_person_off_id($cid, $off_id);
     if ($rs) {
         $json = '{"success": true,"check":true}';
     } else {
         $json = '{"success": true,"check":false}';
     }
     render_json($json);
 }
include(COMMON_DIR.'content.php');  //Class to represent content items in the system


if($_REQUEST['select'] == 'system'){
    system_info();
} else {
    $criteria = validation($_REQUEST);
    $contents = content_selection($criteria);
    if($criteria['format'] == 'raw'){
        render_raw($contents, $criteria);
    }elseif($criteria['format'] == 'html'){
        render_html($contents, $criteria);
    }elseif($criteria['format'] == 'rss'){
        render_rss($contents, $criteria);
    }elseif($criteria['format'] == 'json'){
        render_json($contents, $criteria);
    }
}

//Grab and check user values
function validation($request){
    //Default Values
    $criteria['select'] = 'feed';
    $criteria['format'] = 'rss';
    $criteria['orderby'] = 'id';
    $criteria['range'] = 'live';
    //End default values

    //Define acceptable values
    $select_av = array('content', 'feed', 'user');
    $format_av = array('raw','html','rss','json');
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['discipline_id', 'gender', 'term']);
$player_rows = Discipline::suggest_player_rows_with_clubs_by_id($_GET['discipline_id'], $_GET['term'], $_GET['gender']);
render_json(['players' => $player_rows]);
Example #10
0
 public function get_y96_age()
 {
     $year = $this->input->post('year');
     $prov = $this->input->post('prov');
     $amp = $this->input->post('amp');
     $code = 'y96';
     if (!empty($year) && empty($prov) && empty($amp)) {
         $rs = $this->reports->get_disease_age_by_year($year, $code);
     } else {
         if (!empty($year) && !empty($prov) && empty($amp)) {
             $rs = $this->reports->get_disease_age_by_prov($year, $code, $prov);
         } else {
             if (!empty($year) && !empty($prov) && !empty($amp)) {
                 $rs = $this->reports->get_disease_age_by_amp($year, $code, $prov, $amp);
             }
         }
     }
     $arr_result = array();
     foreach ($rs as $r) {
         $obj = new stdClass();
         $obj->code = $r->code;
         $obj->name = $this->basic->get_diseasename($r->code);
         $obj->total = $r->total;
         $obj->male = $r->male;
         $obj->female = $r->female;
         $arr_result[] = $obj;
     }
     $rows = json_encode($arr_result);
     $json = '{"success": true, "rows": ' . $rows . '}';
     render_json($json);
 }
function render_error_json()
{
    return render_json(['success' => false]);
}
Example #12
0
 public function set_del_user()
 {
     $id = $this->input->post('id');
     $sys_id = $this->input->post('sys_id');
     $rs = $this->users->del_user_system($sys_id, $id);
     if ($rs) {
         $json = '{"success": true, "msg":" ลบเรียบร้อย " }';
     } else {
         $json = '{"success": false, "msg": "ไม่สามารถ ลบ ได้"}';
     }
     render_json($json);
 }
Example #13
0
function main()
{
    $parameters = process_query_uri();
    if (empty($parameters) || empty($parameters[0])) {
        render_html('main');
    } else {
        if ($parameters[0] == 'available_objects') {
            $js_object_listing = array();
            $js_dir_content = scandir(JS_DATABASE_DIRECTORY);
            foreach ($js_dir_content as $each_js_object) {
                if (empty($each_js_object) || $each_js_object[0] == '.') {
                    continue;
                }
                $path_infos = pathinfo($each_js_object);
                if ($path_infos['extension'] == 'js') {
                    $js_object_listing[] = $path_infos['filename'];
                }
            }
            render_json($js_object_listing);
        } else {
            if ($parameters[0] == 'process_obj') {
                // test: http://localhost:8080/process_obj/ahstray
                if (empty($parameters[1])) {
                    error("error: missing obj parameter");
                }
                $obj_name = $parameters[1];
                $obj_filepath = OBJ_DATABASE_DIRECTORY . "/{$obj_name}.obj";
                if (!file_exists($obj_filepath)) {
                    error("error: can't find {$obj_filepath}");
                }
                $loader = new WavefrontObjLoader();
                $loader->parse($obj_filepath, $obj_name);
                $loader->log();
                $loader->save_js(JS_DATABASE_DIRECTORY . "/{$obj_name}.js");
            } else {
                if ($parameters[0] == 'obj_name' && empty($parameters[1]) == false) {
                    $obj_name = $parameters[1];
                    //dump($obj_name);
                    header("Content-Type: text/javascript");
                    //header("Cache-Control: public");
                    header("Cache-Control: no-cache");
                    $obj_filepath = JS_DATABASE_DIRECTORY . "/{$obj_name}.js";
                    $ajax_error = false;
                    if (!file_exists($obj_filepath)) {
                        $ajax_error = "unknown object {$obj_name}";
                    } else {
                        // TODO: activer la compression au niveau du server apache
                        ini_set("zlib.output_compression", "On");
                        readfile($obj_filepath);
                    }
                    $js_error_var = $ajax_error === false ? 'false' : "'" . addslashes($ajax_error) . "'";
                    echo "\nvar ajax_error = {$js_error_var};";
                } else {
                    if ($parameters[0] == 'phpinfo') {
                        phpinfo();
                    } else {
                        header("HTTP/1.0 404 Not Found");
                        // or FastCGI you must use the following for a 404 response:
                        header("Status: 404 Not Found");
                        render_html('page_404');
                    }
                }
            }
        }
    }
}
Example #14
0
 public function search()
 {
     $query = $this->input->post('q');
     if (empty($query) || strlen($query) < 2) {
         $json = '{"success": false, "msg": "กรุณาระบุคำค้นหา"}';
     } else {
         $rs = $this->patient->search($this->hospcode, $query);
         if ($rs) {
             $arr_result = array();
             foreach ($rs as $r) {
                 $obj = new stdClass();
                 $obj->e0 = $r->e0_hosp;
                 $obj->e1 = $r->e1_hosp;
                 $obj->id = $r->id;
                 $obj->name = $r->name;
                 $obj->hn = $r->hn;
                 $obj->cid = $r->cid;
                 $obj->datesick = to_thai_date($r->datesick);
                 $obj->address = $r->address . ' ' . get_address($r->addrcode);
                 $obj->diag = $r->icd10 . ' ' . $this->basic->get_diagname($r->icd10);
                 $obj->code506 = $r->disease . ' ' . $this->basic->get_code506name($r->disease);
                 $obj->nation = get_nation_nhso_name($r->nation);
                 $obj->ptstatus = $r->result;
                 $arr_result[] = $obj;
             }
             $rows = json_encode($arr_result);
             $json = '{"success": true, "rows": ' . $rows . '}';
         } else {
             $json = '{"success": false, "msg": "ไม่มีข้อมูล."}';
         }
     }
     render_json($json);
 }
Example #15
0
<?php

// TODO: Only allow for ajax requests.
// TODO: Turn the DBAccess into an associative fetch instead of DB_BOTH type.
// Check login to allow for information.
// Recent mails.
// Recent events.
// Check chats.
$type = in('type', null);
$jsoncallback = in('jsoncallback');
echo render_json($type, $jsoncallback);
// Make sure to default to private, just as a security reminder.
/**
 * Determine which function to call to get the json for.
**/
function render_json($type, $jsoncallback)
{
    $valid_type_map = array('player' => 'json_player', 'latest_event' => 'json_latest_event', 'chats' => 'json_chats', 'latest_message' => 'json_latest_message', 'index' => 'json_index');
    $res = null;
    if ($valid_type_map[$type]) {
        $res = $jsoncallback . '(' . $valid_type_map[$type]() . ')';
    }
    return $res;
}
function json_latest_message()
{
    $sql = new DBAccess();
    $user_id = (int) get_user_id();
    $messages = $sql->FetchAll("select message_id, message, date, send_to, send_from, unread, uname as sender from messages join players on player_id = send_from where send_to = '" . sql($user_id) . "' and send_from != '" . sql($user_id) . "' order by date desc limit 1");
    // Skips message sent by self, i.e. clan send messages.
    return '{"message":' . json_encode(reset($messages)) . '}';
Example #16
0
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
if (isset($_GET['autocomplete']) && $_GET['autocomplete'] == 'json') {
    render_json(array_map(function ($c) {
        return ['id' => $c->id, 'name' => $c->name, 'text' => '(' . $c->id . ') ' . $c->name];
    }, User::get_all()));
    exit;
}
$u = user\check_current();
$u->require_perm('admin');
render('club_list', ['user' => $u, 'breadcrumbs' => [['name' => 'Vereine', 'path' => 'club/']], 'clubs' => User::get_all('ORDER BY ID ASC')]);
Example #17
0
 public function get_service()
 {
     $items = $this->input->post('items');
     $cid = $items['cid'];
     $s = to_mysql_date_dash($items['date_start']);
     $e = to_mysql_date_dash($items['date_end']);
     $op = $items['op'];
     $rs = $this->patient->get_service($cid, $s, $e);
     $arr_result = array();
     foreach ($rs as $r) {
         $obj = new stdClass();
         $obj->date_serv = to_thai_date($r->DATE_SERV);
         $obj->hospname = $this->basic->get_off_name($r->HOSPCODE);
         $arr_result[] = $obj;
     }
     $rows = json_encode($arr_result);
     $json = '{"success": true, "rows": ' . $rows . '}';
     render_json($json);
 }