Example #1
0
function modulesetting_get($name)
{
    global $MODULE_SETTINGS;
    $value = get_arg($MODULE_SETTINGS, $name);
    LOG_MSG('INFO', "modulesetting_get(): name=[{$name}] value=[{$value}]");
    return $value;
}
Example #2
0
 function go_page_list()
 {
     // Update the shopsetting to indicate this step is complete
     global $ROW, $TEMPLATE;
     LOG_MSG('INFO', "go_page_list(): START ");
     // Do we have a search string?
     // Get all the args from $_GET
     $name = get_arg($_GET, "name");
     $title = get_arg($_GET, "title");
     $type = get_arg($_GET, "type");
     LOG_MSG('DEBUG', "go_page_list(): Got args");
     // Validate parameters as normal strings
     LOG_MSG('DEBUG', "go_page_list(): Validated args");
     // Rebuild search string for future pages
     $search_str = "name={$name}&title={$title}&type={$type}";
     $ROW = $this->admin_model->db_page_select("", $name, $title, '', $type);
     if ($ROW[0]['STATUS'] != "OK") {
         add_msg("ERROR", "There was an error loading the Pages. Please try again later. ");
         return;
     }
     $this->data['rows'] = $ROW;
     $this->load->view('theme1/nav/header', $this->data, '');
     $this->load->view('theme1/nav/topbar', $this->data, '');
     $this->load->view('theme1/index', $this->data);
     $this->load->view('theme1/nav/footer', $this->data);
     LOG_MSG('INFO', "go_page_list(): END");
 }
Example #3
0
 /**
  *
  * 返回URL
  * @param $c
  * @param $m
  * @param $args
  */
 function manager_site_url($c = 'index', $m = 'index', $args = '')
 {
     if (!empty($args) && is_array($args)) {
         $args = http_build_query($args);
     }
     $require_args = array('db' => get_arg('db', 0, 'intval'), 'prefix' => (string) get_arg('prefix', ''), 'server_id' => get_arg('server_id', 0, 'intval'));
     return site_url('c=' . $c . '&m=' . $m . '&' . http_build_query($require_args) . (!empty($args) ? '&' . $args : ''));
 }
Example #4
0
function do_login($auto_login = 0)
{
    global $GO;
    global $ROW;
    // Are we already logged in?
    do_logout();
    // Everybody goes home after login
    $GO = "Home";
    // Auto login?
    if ($auto_login) {
        // Happens after registration
        session_regenerate_id(true);
        $_SESSION['logged_in'] = 1;
        $_SESSION['user_id'] = $auto_login;
        $_SESSION['fname'] = $ROW["fname"];
        // This is the row used for registration
        $_SESSION['email_id'] = $ROW["email_id"];
    } else {
        if (get_arg($_POST, "lemail_id") && get_arg($_POST, "lpassword")) {
            // Get parameters
            $_email_id = get_arg($_POST, "lemail_id");
            $_password = get_arg($_POST, "lpassword");
            // Validate ALL parameters
            if (!validate("Email ID", $_email_id, 5, 100, "EMAIL") || !validate("Password", $_password, 5, 100, "PASSWORD")) {
                add_msg('ERROR', "The email ID or password you entered is incorrect</br>");
                return;
            }
            ##################################################
            #                  DB LOGIN                      #
            ##################################################
            $ROW = db_do_login($_email_id, $_password);
            if ($ROW[0]['STATUS'] == "OK" && $ROW[0]["NROWS"] == 1) {
                session_regenerate_id(true);
                $_SESSION['email_id'] = $_email_id;
                $_SESSION['logged_in'] = 1;
                $_SESSION['user_id'] = $ROW[0]["user_id"];
                $_SESSION['fname'] = $ROW[0]["fname"];
                add_msg('SUCCESS', "Welcome " . $ROW[0]["fname"] . "! </br>");
                if ($ROW[0]["type"] == "E") {
                    $_SESSION['employee'] = 1;
                    // For employees store a backup of their details since they
                    // switch roles often
                    $_SESSION['e_user_id'] = $ROW[0]["user_id"];
                    $_SESSION['e_fname'] = $ROW[0]["fname"];
                    $_SESSION['e_email_id'] = $_email_id;
                }
            }
        }
    }
    // logged_in will not be set if we failed anywhere above
    if (!isset($_SESSION['logged_in']) || !$_SESSION['logged_in']) {
        add_msg('ERROR', "1The email ID or password you entered is incorrect</br>");
    }
}
Example #5
0
 public function index()
 {
     $key = get_arg('key');
     if ($key === NULL) {
         show_error('没有找到参数Key');
     }
     $redis = $this->redis_model->get_redis_instance();
     $page_data = $this->get_default_page_data();
     $key_type = $this->redis_model->get_key_type($key);
     $key_exists = $redis->exists($key);
     $page_data['exists'] = $key_exists;
     $page_data['key'] = $key;
     $template = 'view_string';
     if ($key_exists) {
         $redis_types = $this->redis_model->get_redis_types();
         $type = $redis_types[$key_type];
         $ttl = $redis->ttl($key);
         $encoding = $redis->object('encoding', $key);
         switch ($type) {
             case 'string':
                 $values = $redis->get($key);
                 $size = strlen($values);
                 $template = 'view_string';
                 break;
             case 'hash':
                 $values = $redis->hGetAll($key);
                 $size = count($values);
                 $template = 'view_hash';
                 break;
             case 'list':
                 $size = $redis->lSize($key);
                 $values = $redis->lRange($key, 0, -1);
                 $template = 'view_list';
                 break;
             case 'set':
                 $values = $redis->sMembers($key);
                 $size = count($values);
                 $template = 'view_set';
                 break;
             case 'zset':
                 $values = $redis->zRange($key, 0, -1, 1);
                 $size = count($values);
                 $template = 'view_zset';
                 break;
         }
         $page_data['type'] = $type;
         $page_data['values'] = $values;
         $page_data['size'] = $size;
         $page_data['ttl'] = $ttl;
         $page_data['encoding'] = $encoding;
     }
     $page_data['title'] = '查看Key[' . $key . ']';
     $this->load->view($template, $page_data);
 }
Example #6
0
function do_check_rooms()
{
    global $ROW, $TEMPLATE;
    LOG_MSG('INFO', "do_check_rooms(): START GET=" . print_r($_GET, true));
    // Get all the args from $_GET
    $room_name = get_arg($_GET, "room_name");
    $room_id = get_arg($_GET, "room_id");
    $ROW = db_room_select($room_id, $room_name);
    if ($ROW[0]['STATUS'] != "OK") {
        add_msg("ERROR", "There was an error loading the wallet. Please try again later. <br/>");
        return;
    }
    LOG_MSG('INFO', "do_check_rooms() : END");
}
Example #7
0
function emailer()
{
    LOG_MSG('INFO', "do_confirm_order(): START");
    $htmldata = file_get_contents("php://input");
    echo "***************do_confirm_order() start *************************";
    echo "----GET----\n" . print_r($_GET, true);
    //echo "----RAW----\n [$htmldata]";
    echo "***************do_confirm_order() end   *************************";
    $to = get_arg($_GET, 'to');
    $from = get_arg($_GET, 'from');
    $subject = get_arg($_GET, 'sub');
    $message = $htmldata;
    send_email($to, $subject, $message, $from);
    LOG_MSG('INFO', "do_confirm_order(): END");
}
Example #8
0
 private function _do_index()
 {
     $type = get_arg('type', 'redis', 'trim');
     $key = get_arg('key', NULL);
     if ($type == 'redis') {
         $ext = 'redis';
         $ct = 'text/plain';
     } else {
         $ext = 'js';
         $ct = 'application/json';
     }
     header('Content-type: ' . $ct . '; charset=utf-8');
     header('Content-Disposition: inline; filename="export.' . $ext . '"');
     $redis = $this->redis_model->get_redis_instance();
     $key = $key === NULL ? '*' : $key;
     if ($type == 'redis') {
         //导出Redis命令
         if (substr($key, -1) == '*') {
             //导出所有KEY 或 部分KEY
             $keys = $redis->keys($key);
             $values = array();
             foreach ($keys as $k) {
                 $values[] = $this->_export_redis($k);
             }
             echo implode(PHP_EOL, $values);
         } else {
             //导出单个KEY
             echo $this->_export_redis($key);
         }
     } else {
         //导出json格式
         if (substr($key, -1) == '*') {
             //导出所有KEY 或 部分KEY
             $keys = $redis->keys($key);
             $values = array();
             foreach ($keys as $k) {
                 $values[$k] = $this->_export_json($k);
             }
             echo json_encode($values);
         } else {
             //导出单个KEY
             echo json_encode($this->_export_json($key));
         }
     }
     die;
 }
Example #9
0
 private function _info()
 {
     $redis = $this->redis_model->get_redis_instance();
     $reset = get_arg('reset', 0, 'intval');
     $can_reset = method_exists($redis, 'resetStat');
     if ($reset && $can_reset) {
         $redis->resetStat();
         $url = manager_site_url('info', 'index');
         header('Location: ' . $url);
         exit;
     }
     $info = $redis->info();
     $page_data = $this->get_default_page_data();
     $page_data['info'] = $info;
     $page_data['can_reset'] = $can_reset;
     $page_data['title'] = '统计信息';
     $this->load->view('info', $page_data);
 }
Example #10
0
 private function _delete_key($type, $key)
 {
     $redis = $this->redis_model->get_redis_instance();
     switch ($type) {
         default:
             //如果传空,即是整key删除
         //如果传空,即是整key删除
         case 'string':
             $redis->delete($key);
             break;
         case 'hash':
             $hkey = get_arg('hkey');
             if ($hkey !== NULL) {
                 $redis->hDel($key, $hkey);
             }
             break;
         case 'list':
             $index = get_arg('index');
             if ($index !== NULL) {
                 /*
                  * 说明:
                  * List本身并不具备单独移除单个值的操作
                  * 目前的操作方式为:将此index的值设置为一个很特殊的随机值,然后将此值移出list
                  * 此操作是一个风险点,我们是假定这个随机值是不存在于list中的,而事实上出现相同的机率很低
                  */
                 $value = str_rand(69);
                 $redis->lSet($key, $index, $value);
                 $redis->lRem($key, $value, 1);
             }
             break;
         case 'set':
             $value = get_arg('value');
             if ($value !== NULL) {
                 $redis->sRem($key, $value);
             }
             break;
         case 'zset':
             $value = get_arg('value');
             if ($value !== NULL) {
                 $redis->zDelete($key, $value);
             }
             break;
     }
 }
Example #11
0
 public function index()
 {
     if ($this->is_post()) {
         $this->_do_index();
     }
     if (!AUTH) {
         Header('Location:' . manager_site_url('index', 'index'));
         exit;
     }
     $goto = get_arg('goto');
     if (!empty($goto)) {
         set_cookie('goto', $goto, 0);
     }
     $page_data = array();
     $page_data['title'] = '登录 - ' . PROJECT_NAME;
     $page_data['error'] = (int) $this->input->get_post('error');
     $page_data['seccode_enable'] = (bool) SECCODE_ENABLE;
     $this->load->view('login', $page_data);
 }
Example #12
0
 public function index()
 {
     if ($this->is_post()) {
         $this->_do_index();
         return;
     }
     $key = get_arg('key');
     if ($key === NULL) {
         show_error('没有找到参数Key');
     }
     $redis = $this->redis_model->get_redis_instance();
     $key_exists = $redis->exists($key);
     if (!$key_exists) {
         show_error('Key[' . $key . ']不存在');
     }
     $page_data = $this->get_default_page_data();
     $page_data['key'] = $key;
     $page_data['title'] = '重命名Key[' . $key . ']';
     $this->load->view('rename', $page_data);
 }
Example #13
0
 public function index()
 {
     if (empty($this->server_list) || !is_array($this->server_list)) {
         show_error('Server List Invaild');
     }
     $view_all = get_arg('viewall', 0, 'intval');
     if ($view_all) {
         //查看全部服务器
         $this->_overview_all();
         return;
     } elseif (!CLUSTER_MODE) {
         //只看当前服务器
         //普通redis服务器
         $this->_overview_single();
         return;
     } else {
         //只看当前服务器
         //集群服务器
         $this->_overview_cluster();
         return;
     }
 }
Example #14
0
 public function index()
 {
     $sub_key = get_arg('key', '', 'trim');
     $this->_sub_key = $sub_key;
     $ks = $sub_key !== '' ? explode(SEPERATOR, $sub_key) : array();
     $this->_auto_build_tree_level = count($ks) + 1;
     $redis_keys = $this->redis_model->get_all_keys($sub_key);
     $namespaces = array();
     $this->keys_to_tree($redis_keys, $namespaces);
     $key_name = '';
     if (!empty($ks) && !empty($namespaces)) {
         foreach ($ks as $k) {
             $key_name = $k;
             $namespaces = $namespaces[$key_name];
         }
     }
     $is_end = 1;
     $step = 1;
     $key_tree = array();
     if (!empty($namespaces) && is_array($namespaces)) {
         $step = get_arg('step', 1, 'intval');
         $step = $step >= 1 ? $step : 1;
         $offset = ($step - 1) * TREE_KEY_PAGE_SIZE;
         $cnt = count($namespaces);
         if ($offset + TREE_KEY_PAGE_SIZE >= $cnt) {
             $is_end = 1;
         } else {
             $step += 1;
             $is_end = 0;
         }
         $namespaces = array_slice($namespaces, $offset, TREE_KEY_PAGE_SIZE, TRUE);
         $this->_create_key_tree($namespaces, $key_name, $sub_key, empty($namespaces), $key_tree);
     }
     $key_tree = implode(PHP_EOL, $key_tree);
     $ret_arr = array('html' => $key_tree, 'isEnd' => $is_end, 'step' => $step);
     show_message(0, '', $ret_arr);
 }
Example #15
0
 public function build_report()
 {
     if (!$this->is_post()) {
         header('Location:' . manager_site_url(strtolower(__CLASS__), 'index'));
         exit;
     }
     $cnt = get_arg('cnt', 10, 'intval');
     $cnt = $cnt <= 0 ? 10 : $cnt;
     $redis = $this->redis_model->get_redis_instance();
     $keys = $redis->keys('*');
     $head = IdleQueue::factory(-1, $cnt);
     foreach ($keys as $key) {
         if ($key == $this->_idle_key) {
             continue;
         }
         $d = $redis->object('idletime', $key);
         $tmp =& $head;
         while ($tmp !== NULL && $d >= $tmp->idle_time) {
             $tmp =& $tmp->next;
         }
         if ($tmp === $head) {
             continue;
         }
         $head->idle_time = $d;
         $head->key = $key;
         if ($tmp != $head->next) {
             $t = $head;
             $head = $head->next;
             $t->next = is_null($tmp) ? NULL : $tmp;
             $tmp = $t;
         }
     }
     $report = IdleQueue::result($head);
     $this->_set_idle_report($report);
     die('操作已完成! <a href="' . manager_site_url('idle', 'index') . '">返回</a>');
 }
Example #16
0
 public function page($go = 'list', $_id = '')
 {
     $this->data['title'] = "Admin";
     $do = get_arg($_POST, 'do');
     $id = get_arg($_POST, 'id');
     switch ($go) {
         case 'list':
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/list', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'add':
             $this->data['do'] = 'save';
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/record', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'modify':
             $this->data['do'] = 'update';
             $this->data['id'] = $_id;
             $this->data['rows'] = $this->admin_model->page_list($_id);
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/record', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'diet':
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/diet', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'diet_print':
             $morning = get_arg($_POST, "morning");
             $this->data['diet']['morning'] = $morning;
             $dc1 = get_arg($_POST, "dc1");
             $this->data['diet']['dc1'] = $this->admin_model->get_diet($dc1);
             $dc2 = get_arg($_POST, "dc2");
             $this->data['diet']['dc2'] = $this->admin_model->get_diet($dc2);
             $dc3 = get_arg($_POST, "dc3");
             $this->data['diet']['dc3'] = $this->admin_model->get_diet($dc3);
             $dc4 = get_arg($_POST, "dc4");
             $this->data['diet']['dc4'] = $this->admin_model->get_diet($dc4);
             $dc5 = get_arg($_POST, "dc5");
             $this->data['diet']['dc5'] = $this->admin_model->get_diet($dc5);
             //print_r($this->data['diet']);exit;
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/page/diet_print', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
     }
 }
Example #17
0
 protected function _create_key_tree_head(&$item, $name, $full_key, $is_last, &$return_html)
 {
     if (isset($item[TREE_END_SIGN])) {
         //需要unset掉,否则会影响到节点的判断
         unset($item[TREE_END_SIGN]);
         $class = array();
         $len = FALSE;
         $current = get_arg('key');
         if ($current && $full_key == $current) {
             $class[] = 'current';
         }
         if ($is_last) {
             $class[] = 'last';
         }
         $redis = $this->redis_model->get_redis_instance();
         if (!FAST_MODEL) {
             $type = $this->redis_model->get_key_type($full_key);
             if (!isset($this->_redis_types[$type])) {
                 return;
             }
             $type = $this->_redis_types[$type];
             switch ($type) {
                 case 'hash':
                     $len = $redis->hLen($full_key);
                     break;
                 case 'list':
                     $len = $redis->lSize($full_key);
                     break;
                 case 'set':
                     $len = count($redis->sMembers($full_key));
                     break;
                 case 'zset':
                     $len = count($redis->zRange($full_key, 0, -1));
                     break;
             }
         }
         $tree_sub1 = array();
         $tree_sub1[] = '<li' . (empty($class) ? '' : ' class="' . implode(' ', $class) . '"') . '>';
         $tree_sub1[] = '<a href="' . manager_site_url('view', 'index', 'key=' . urlencode($full_key)) . '" target="iframe">' . format_html($name);
         $tree_sub1[] = $len !== FALSE ? '<span class="info">(' . $len . ')</span>' : '';
         $tree_sub1[] = '</a></li>';
         $return_html[] = implode(PHP_EOL, $tree_sub1);
     }
 }
Example #18
0
 private function _do_index()
 {
     $key = get_post_arg('key', NULL, 'trim');
     if ($key === FALSE || $key === '') {
         show_error('Key不能为空');
     }
     if (strlen($key) > MAX_KEY_LEN) {
         show_error('Key长度[' . strlen($key) . ']超过限制,当前限制为[' . MAX_KEY_LEN . ']');
     }
     $type = strtolower(get_post_arg('type', NULL, 'trim'));
     $allow_type = array('string', 'list', 'hash', 'set', 'zset');
     if (!in_array($type, $allow_type)) {
         show_error('未知的数据类型');
     }
     $value = get_post_arg('value');
     $redis = $this->redis_model->get_redis_instance();
     if ($type == 'string') {
         //string
         $result = $redis->set($key, $value);
         if (!$result) {
             show_error('操作失败');
         }
     } elseif ($type == 'hash') {
         //hash
         $hkey = get_post_arg('hkey');
         //只有当hkey存在的时候才操作
         if ($hkey !== NULL) {
             if (strlen($hkey) > MAX_KEY_LEN) {
                 show_error('Hash Key长度[' . strlen($key) . ']超过限制,当前限制为[' . MAX_KEY_LEN . ']');
             }
             //指定读取$_GET中的hkey
             $old_hkey = get_arg('hkey', NULL, 'trim', 'get');
             if ($old_hkey !== NULL && !$redis->hExists($key, $hkey)) {
                 //如果新的hkey不存在的话
                 //删掉用来的旧KEY
                 $redis->hDel($key, $old_hkey);
             }
             $redis->hSet($key, $hkey, $value);
         }
     } elseif ($type == 'list') {
         //list
         $size = $redis->lSize($key);
         $index = get_post_arg('index', NULL, 'trim');
         $index === NULL && ($index = '');
         if ($index == '' || $index == $size) {
             //加到list最后面
             $redis->rPush($key, $value);
         } elseif ($index == '-1') {
             //加到list最前面
             $redis->lPush($key, $value);
         } elseif ($index >= 0 && $index < $size) {
             //直接修改原list的值
             $redis->lSet($key, $index, $value);
         } else {
             show_error('index值越界(Out of bounds index)');
         }
     } elseif ($type == 'set') {
         //set
         $old_value = get_post_arg('oldvalue');
         if ($value != $old_value) {
             $redis->sRem($key, $old_value);
             $redis->sAdd($key, $value);
         }
     } elseif ($type == 'zset') {
         //zset
         $old_value = get_post_arg('oldvalue');
         $old_score = get_post_arg('oldscore');
         $score = get_post_arg('score');
         $score === NULL && ($score = '');
         if ($value != $old_value || $score != $old_score) {
             $redis->zDelete($key, $old_value);
             $redis->zAdd($key, $score, $value);
         }
     }
     $url = manager_site_url('view', 'index', 'key=' . urlencode($key));
     Header('Location:' . $url);
     exit;
 }
Example #19
0
 public function page($go = 'list', $_id = '')
 {
     $this->data['title'] = "Admin";
     $do = get_arg($_POST, 'do');
     $id = get_arg($_POST, 'id');
     $diet_code = get_arg($_POST, "diet_code");
     $diet_name = get_arg($_POST, "diet_name");
     //print_r($_POST);exit;
     if ($do == 'save') {
         $add_more = get_arg($_POST, "add_more");
         $this->data['resp'] = $this->admin_model->page_save($id, $diet_code, $diet_name);
         if ($add_more == 'on') {
             $go = 'add';
         } else {
             $go = 'list';
         }
     } elseif ($do == 'update') {
         $this->data['resp'] = $this->admin_model->page_update($id, $diet_code, $diet_name);
         //print_r($this->data['resp']); exit;
         $go = 'list';
     } elseif ($do == 'diet') {
         //$this->data['resp'] = $this->admin_model->get_diet();
         //print_r($this->data['resp']); exit;
         $go = 'diet_print';
     }
     $this->data['page'] = $go;
     switch ($go) {
         case 'list':
             $this->data['rows'] = $this->admin_model->page_list();
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/list', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'add':
             $this->data['do'] = 'save';
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/record', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'modify':
             $this->data['do'] = 'update';
             $this->data['id'] = $_id;
             $this->data['rows'] = $this->admin_model->page_list($_id);
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/record', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'diet':
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/html/topbar', $this->data);
             $this->load->view('admin/html/leftnav', $this->data);
             $this->load->view('admin/page/diet', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
         case 'diet_print':
             $morning = get_arg($_POST, "morning");
             $this->data['diet']['morning'] = $morning;
             $dc1 = get_arg($_POST, "dc1");
             $this->data['diet']['dc1'] = $this->admin_model->get_diet($dc1);
             $dc2 = get_arg($_POST, "dc2");
             $this->data['diet']['dc2'] = $this->admin_model->get_diet($dc2);
             $dc3 = get_arg($_POST, "dc3");
             $this->data['diet']['dc3'] = $this->admin_model->get_diet($dc3);
             $dc4 = get_arg($_POST, "dc4");
             $this->data['diet']['dc4'] = $this->admin_model->get_diet($dc4);
             $dc5 = get_arg($_POST, "dc5");
             $this->data['diet']['dc5'] = $this->admin_model->get_diet($dc5);
             //print_r($this->data['diet']);exit;
             $this->load->view('admin/html/header', $this->data);
             $this->load->view('admin/page/diet_print', $this->data);
             $this->load->view('admin/html/footer', $this->data);
             break;
     }
 }
Example #20
0
define('TRAVEL_ID', 6);
db_connect();
$filename = 'vinayaka.csv';
$handle = fopen($filename, "r");
if ($handle === false) {
    echo 'Error opening the file';
    exit;
}
db_transaction_start();
$upload_count = 0;
while (($item = fgetcsv($handle, 65535, ',', '"')) !== FALSE) {
    // Get the vehicle details
    $reg_no = clean_csv_string(get_arg($item, 0));
    $vehicle_model = clean_csv_string(get_arg($item, 1));
    $client_name = clean_csv_string(get_arg($item, 3));
    $sticker_no = clean_csv_string(get_arg($item, 2));
    echo "[{$sticker_no}]";
    //upload the details into csv if sticker no is not empty
    if ($sticker_no == "") {
        continue;
    }
    // Check if the client is already available
    $client_row = db_client_select("", $client_name);
    if ($client_row[0]['STATUS'] != 'OK') {
        echo "Error getting client details for {$client_name}";
        exit;
    }
    // Insert new Client
    if ($client_row[0]['NROWS'] == 0) {
        $resp = db_client_insert($client_name, 'no_image.jpg', '', '');
        if ($resp['STATUS'] != 'OK') {
Example #21
0
function generate($report_mode, $row)
{
    global $ORDER_STATUS, $PAYMENT_TYPES, $PAYMENT_STATUS, $ERROR_MESSAGE;
    LOG_MSG('INFO', "generate(): START report_mode=[{$report_mode}], rows=[" . $row[0]['NROWS'] . "]");
    switch ($report_mode) {
        case 'HTML':
            include $row['filename'];
            break;
        case 'CSV':
            header("Content-type: application/csv");
            header("Content-Disposition: attachment; filename=" . SITE_NAME . '_' . $row['report_name'] . '_' . date("Y-m-d-h-i-s") . '.csv');
            header("Pragma: no-cache");
            header("Expires: 0");
            $nrows = $row[0]['NROWS'];
            unset($row[0]['NROWS']);
            unset($row[0]['STATUS']);
            if (isset($row[0]['IS_SEARCH'])) {
                unset($row[0]['IS_SEARCH']);
            }
            if ($row['report_name'] == 'attendance_report') {
                echo "Name,";
                for ($i = 0; $i < $row['date_row'][0]['NROWS']; $i++) {
                    if ($i > 0) {
                        echo $row['date_row'][$i]['date'] . ', ,';
                    } else {
                        echo ",";
                    }
                }
                echo "\n";
                for ($j = 0; $j < $row['date_row'][0]['NROWS']; $j++) {
                    if ($j > 0) {
                        echo "Morning,Evening,";
                    } else {
                        echo ",";
                    }
                }
                echo "\n";
                for ($i = 0; $i < $row['user_row'][0]['NROWS']; $i++) {
                    echo $row['user_row'][$i]['name'];
                    for ($j = 0; $j < $row['date_row'][0]['NROWS']; $j++) {
                        if ($j > 0) {
                            echo $row['attendance_arr'][$row['user_row'][$i]['student_id']][$row['date_row'][$j]['date']]['MORNING'] . ',';
                            echo $row['attendance_arr'][$row['user_row'][$i]['student_id']][$row['date_row'][$j]['date']]['EVENING'] . ',';
                        } else {
                            echo ",";
                        }
                    }
                    echo "\n";
                }
            } else {
                for ($i = 0; $i < $nrows; $i++) {
                    if (isset($row[$i]['payment_type'])) {
                        $row[$i]['payment_type'] = $PAYMENT_TYPES[$row[$i]['payment_type']];
                    }
                    if ($row['report_name'] == 'search_report') {
                        unset($row[$i]['order_by']);
                        unset($row[$i]['fuel_image']);
                        unset($row[$i]['odometer_image']);
                    }
                    if ($row['report_name'] == 'student_report') {
                        unset($row[$i]['check_in_image']);
                        unset($row[$i]['check_out_image']);
                    }
                    if ($row['report_name'] == 'Stock_Report') {
                        $row[$i]['product'] = encode_csv_field($row[$i]['product']);
                    }
                    // This loop will print headers
                    if ($i == 0) {
                        foreach ($row[0] as $key => $value) {
                            if ($row['report_name'] == 'Bluedart_Report') {
                                echo "{$key},";
                            } else {
                                echo make_clean_str($key) . ',';
                            }
                        }
                        echo "\r\n";
                    }
                    // This will print the values
                    //$row[$i]=encode_csv_field($row[$i]);
                    echo implode(',', $row[$i]) . "\r\n";
                }
            }
            break;
        case 'PDF':
            require_once "lib/dompdf/dompdf_config.inc.php";
            ob_start();
            include $row['filename'];
            $html = ob_get_contents();
            // Set mail content
            ob_get_clean();
            $dompdf = new DOMPDF();
            $dompdf->load_html($html);
            if (strlen($html) > 80000) {
                echo "Report is too large to generate PDF. Please download CSV instead";
                LOG_MSG('INFO', "Maximum memory reached. String Length=[" . strlen($html) . "bytes]");
                exit;
            }
            // For blue dart report,the table width is too large to fit into an A4-portrait
            if ($row['report_name'] == 'Bluedart_Report') {
                $dompdf->set_paper('a3', 'landscape');
            }
            $dompdf->render();
            $dompdf->stream($row['report_name'] . '.pdf');
            break;
        case 'EMAIL':
            // Get args from POST
            $from = get_arg($_GET, "from");
            $to = get_arg($_GET, "to");
            $subject = get_arg($_GET, "subject");
            $mail_mode = get_arg($_GET, 'mail_mode');
            $message = get_arg($_GET, 'message');
            // Validate parameters
            if (!validate("To address", $to, 5, 100, "EMAIL") || !validate("From address", $from, 5, 100, "EMAIL") || !validate("Subject", $subject, 1, 100, "varchar") || !validate("Message", $message, 0, 200, "varchar")) {
                LOG_MSG('ERROR', "generate(): VALIDATE ARGS FAILED! " . print_r($_POST, true));
                return false;
            }
            // Validate parameters
            if ($mail_mode != 'attachment' && $mail_mode != 'inline') {
                add_msg('ERROR', 'Invalid Mail mode');
                LOG_MSG('ERROR', "generate(): VALIDATE ARGS FAILED! Invalid Mail mode" . print_r($_POST, true));
                return false;
            }
            LOG_MSG('INFO', "generate(): Validated args");
            // Required for attachment
            $attachments_arr = array();
            if ($mail_mode == 'attachment') {
                require_once "lib/dompdf/dompdf_config.inc.php";
                ob_start();
                include $row['filename'];
                $html = ob_get_contents();
                // Set mail content
                ob_get_clean();
                $dompdf = new DOMPDF();
                $dompdf->load_html($html);
                LOG_MSG('INFO', "Maximum memory reached. String Length=[" . strlen($html) . "bytes]");
                // Due to the memory allocation error, send as html mail as a work around instead of attaching PDF
                if (strlen($html) > 80000) {
                    LOG_MSG('INFO', "Sending HTML mail instead of attachment as Maximum memoty reached. String Length=[" . strlen($html) . "bytes]");
                    $message .= "<br/> {$html}";
                    // Set mail content
                    $plain_message = '';
                    // the contents are already in $message
                } else {
                    // For blue dart report,the table width is too large to fit into an A4-portrait
                    if ($row['report_name'] == 'Bluedart_Report') {
                        $dompdf->set_paper('a3', 'landscape');
                    }
                    $dompdf->render();
                    $attachments_arr[0]['filename'] = $row['report_name'] . '.pdf';
                    $attachments_arr[0]['data'] = $dompdf->output();
                    $plain_message = $html;
                    // this will contain the attachment contents
                }
            } else {
                //Store in buffer and load to mail message
                ob_start();
                include $row['filename'];
                $message .= '<br/>' . ob_get_contents();
                // Set mail content
                ob_get_clean();
                $plain_message = '';
                // the contents are already in $message
            }
            send_email($to, $from, '', '', $subject, $message, $attachments_arr, $plain_message);
            // Send Mail
            break;
    }
    LOG_MSG('INFO', "generate(): END");
    return true;
}
Example #22
0
 function get_nav_menu($lists = array(), $args = array())
 {
     $out = '';
     if (count($args) > 0) {
         foreach ($args['list'] as $key => $arg) {
             if (get_arg('name', $arg)) {
                 $active = !Route::getCurrentRoute()->id ? 'class="active"' : '';
                 $out .= '<li ' . $active . '>
                           <a href="' . get_arg('url', $arg) . '" target="' . get_arg('target', $arg) . '"" >
                             ' . get_arg('name', $arg) . '
                           </a>
                     </li>';
             }
         }
     }
     if (count($lists) > 0) {
         $i = 0;
         foreach ($lists as $list) {
             $i++;
             $title = get_arg('title', $args) ? get_arg('title', $args) : 'title';
             $active = Route::getCurrentRoute()->id == $list->slug ? 'class="active"' : '';
             $out .= '<li ' . $active . '>
                           <a class="' . get_arg('a.class' . $i, $args) . '" href="' . action(get_arg('route', $args), $list->slug) . '" >
                             ' . $list->{$title} . '
                           </a>
                     </li>';
         }
     }
     return $out;
 }
Example #23
0
function has_user_permission($function, $mode = "")
{
    return true;
    $return = true;
    $user_id = get_arg($_SESSION, 'user_id');
    $user_permission_row = db_permission_select($user_id, $function, $mode);
    if ($user_permission_row[0]['STATUS'] != 'OK' || $user_permission_row[0]['NROWS'] != 1) {
        add_msg("ERROR", "Sorry! You do not have the permission to perform this action.<br />");
        $return = false;
    }
    LOG_MSG("INFO", "has_user_permission(): user_id=[{$user_id}] function=[{$function}] mode=[{$mode}] has_premission=[{$return}]");
    return $return;
}
Example #24
0
 <span style="float:left;" class="ui-icon ui-icon-person"></span> <?php 
    }
    ?>

						<?php 
    if (is_admin()) {
        ?>
<a style="font-weight:normal;" 
						href="index.php?mod=admin&ent=user&go=modify&user_id=<?php 
        echo $_SESSION['user_id'];
        ?>
"><?php 
    }
    ?>
								<?php 
    echo ucwords(strtolower(get_arg($_SESSION, 'name')));
    ?>
						<?php 
    if (is_admin()) {
        ?>
</a><?php 
    }
    ?>
|
						<a style="font-weight:normal;" href="javascript:void(0)" onclick='LogoutForm.submit();'>Logout</a>
						<form method="POST" action="index.php" name="LogoutForm">
							<input type="hidden" name="do" value="logout"/>
						</form>
					<?php 
}
?>
Example #25
0
db_connect();
$filename = 'vehicle.csv';
$handle = fopen($filename, "r");
if ($handle === false) {
    echo 'Error opening the file';
    exit;
}
define('TRAVEL_ID', 1);
db_transaction_start();
$upload_count = 0;
while (($item = fgetcsv($handle, 65535, ',', '"')) !== FALSE) {
    // Get the vehicle details
    $sticker_no = clean_csv_string(get_arg($item, 0));
    $reg_no = clean_csv_string(get_arg($item, 1));
    $vehicle_model = clean_csv_string(get_arg($item, 2));
    $client_name = clean_csv_string(get_arg($item, 3));
    // Check if the client is already available
    $client_row = db_client_select("", $client_name);
    if ($client_row[0]['STATUS'] != 'OK') {
        echo "Error getting client details for {$client_name}";
        exit;
    }
    // Insert new Client
    if ($client_row[0]['NROWS'] == 0) {
        $resp = db_client_insert($client_name, 'no_image.jpg', '', '');
        if ($resp['STATUS'] != 'OK') {
            echo "Error inserting client for {$client_name}";
            exit;
        }
        $client_id = $resp['INSERT_ID'];
    } else {
Example #26
0
                      <td><h4><?php 
echo get_arg($diet['dc3'][0], 'diet_name');
?>
</h4></td>
                    </tr>
					<tr class="gradeX">
                      <td><h2>Juice [4PM]</h2></td>
                      <td><h4><?php 
echo get_arg($diet['dc4'][0], 'diet_name');
?>
</h4></td>
                    </tr>
					<tr class="gradeX">
                      <td><h2>Dinner</h2></td>
                      <td><h4><?php 
echo get_arg($diet['dc5'][0], 'diet_name');
?>
</h4></td>
                    </tr>
                  </tfoot>
                </table>
				<div class="bottom center">
                  <button type="button" onClick="window.print();" class="btn btn-primary">Print</button>
                  <!-- <a href="<?php 
echo site_url();
?>
" type="button" class="btn btn-default">Cancel</a> -->
                </div>

              </div><!--/table-responsive-->
            </div><!--/porlets-content-->
Example #27
0
    echo " -r repository_name             Overwrites the repository name (optional)\n";
    echo " -m your_github_username        Sets up ssh:// instead of git:// for pushable repositories (optional)\n";
    echo " -d                             Outputs the commands instead of running them (optional)\n";
    echo " -h                             This help text\n";
    exit(1);
}
// Handle arguments
$opts = getopt('s:u:r:m:dh');
if (empty($opts) || isset($opts['h'])) {
    show_usage();
}
$scope = get_arg($opts, 's', '');
$username = get_arg($opts, 'u', 'phpbb');
$repository = get_arg($opts, 'r', 'phpbb3');
$developer = get_arg($opts, 'm', '');
$dry_run = !get_arg($opts, 'd', true);
run(null, $dry_run);
exit(work($scope, $username, $repository, $developer));
function work($scope, $username, $repository, $developer)
{
    // Get some basic data
    $forks = get_forks($username, $repository);
    $collaborators = get_collaborators($username, $repository);
    if ($forks === false || $collaborators === false) {
        echo "Error: failed to retrieve forks or collaborators\n";
        return 1;
    }
    switch ($scope) {
        case 'collaborators':
            $remotes = array_intersect_key($forks, $collaborators);
            break;
Example #28
0
function upload_image($html_img_name, $dest_img_file, $req_width = '', $req_height = '', $autocrop = 0)
{
    LOG_MSG("INFO", "upload_image():START html_img_name = [{$html_img_name}],\n\t\t\t\t\t\t\t\t\t\tdest_img_file = [{$dest_img_file}],\n\t\t\t\t\t\t\t\t\t\treq_width = [{$req_width}],\n\t\t\t\t\t\t\t\t\t\treq_height = [{$req_height}],\n\t\t\t\t\t\t\t\t\t\tautocrop = [{$autocrop}]");
    if (isset($_FILES[$html_img_name]) && validate_file($_FILES[$html_img_name])) {
        if ($_FILES[$html_img_name]['type'] != 'image/jpeg' && $_FILES[$html_img_name]['type'] != 'image/pjpeg' && $_FILES[$html_img_name]['type'] != 'image/png') {
            add_msg('ERROR', 'Sorry, you can only upload a jpg, jpeg or png image. Please try again.');
            LOG_MSG('ERROR', "upload_image(): Got file type=[" . $_FILES[$html_img_name]['type'] . "]");
            return false;
        }
        LOG_ARR('INFO', 'upload_image(): FILES', $_FILES);
        //Crop/Resize the image
        if ($req_width !== '' && $req_height !== '') {
            if (!image_resize(get_arg($_FILES[$html_img_name], 'tmp_name'), $req_width, $req_height, $autocrop)) {
                add_msg('ERROR', 'There was an error uploading the image. Please try later');
                LOG_MSG('ERROR', "upload_image(); Error resizing the file");
                return false;
            }
        }
        // Copy the file to the uploaded directory
        if (!copy(get_arg($_FILES[$html_img_name], 'tmp_name'), $dest_img_file)) {
            add_msg('ERROR', 'There was an error uploading the image. Please try later');
            LOG_ARR('INFO', 'upload_image(): FILES', $_FILES);
            LOG_MSG('ERROR', "upload_image(); Error copying file to the directory: [{$dest_img_file}]");
            return false;
        }
        LOG_MSG('INFO', "upload_image(): New File: is [{$dest_img_file}]");
        return true;
    }
    LOG_MSG("INFO", "upload_image():END");
    return false;
}