Exemplo n.º 1
0
 public function index()
 {
     $this->auth(array('user' => 'login_check'));
     $this->datatables_code();
     $page['q'] = \cx\app\main_functions::get_globals(array('route', 'm'));
     // Get pagination vars
     $this->load_view('app' . DS . 'users' . DS . 'index', $page);
 }
Exemplo n.º 2
0
 /**
  * Purpose: To generate a group of checkboxes.
  * @param type $name - The name for the group of checkboxes.
  * @param $htmlOptions - <options> - Array of checkbox data.
  */
 private function frm_checkboxes($name, $htmlOptions)
 {
     $checkboxes = isset($htmlOptions['options']) ? $htmlOptions['options'] : array();
     $c = count($checkboxes);
     $input_name = $c > 1 ? $name . '[]' : $name;
     foreach ($checkboxes as $value => $label) {
         $selected = array('');
         if (isset($this->model[$name])) {
             if (is_array($this->model[$name])) {
                 $selected = $this->model[$name];
             } elseif (main_fn::is_serialized($this->model[$name]) === true) {
                 $selected = main_fn::safe_unserialize($this->model[$name]);
             } elseif (!empty($this->model[$name])) {
                 $selected = array($this->model[$name]);
             }
         }
         if ($c == 1) {
             $checkit = isset($htmlOptions['checked']) && main_fn::get_bool_value($htmlOptions['checked']) === true ? ' checked="checked"' : '';
         } else {
             $checkit = isset($htmlOptions['checked'][$value]) && main_fn::get_bool_value($htmlOptions['checked'][$value]) === true ? ' checked="checked"' : '';
         }
         $req = $this->get_request($name, $selected, $this->method);
         if (is_array($req)) {
             $select = in_array($value, $req) ? ' checked="checked"' : $checkit;
         } else {
             $select = $value == $req ? ' checked="checked"' : $checkit;
         }
         $this->input('checkbox', $input_name, $value, $label, $select, $htmlOptions);
     }
     // end foreach
     if ($c == '0') {
         $err = "Form Command - checkboxes - Named: {$name} - Missing Options!";
         $this->report_form_error($err);
     }
 }
Exemplo n.º 3
0
 public function cookie_var($var)
 {
     if (isset($_COOKIE[CX_SES . $var])) {
         $c = $_COOKIE[CX_SES . $var];
         if (main_fn::is_base64_encoded($c) === true) {
             $decoded = base64_decode($c, true);
             if (main_fn::is_serialized($decoded) === true) {
                 return main_fn::safe_unserialize($decoded);
                 // returns array
             }
             return $decoded;
             // return decoded cookie
         } else {
             return $c;
             // my cookie
         }
     } else {
         return false;
         // No cookie, found
     }
 }
Exemplo n.º 4
0
 public function run($sql, $bind = "", $fetch_mode = "all")
 {
     $this->sql = trim($sql);
     $this->bind = $this->cleanup($bind);
     $this->error = "";
     try {
         $pdostmt = $this->prepare($this->sql);
         if (is_array($this->ssp_bind)) {
             \ssp_do_bindings($pdostmt, $this->ssp_bind);
         }
         if (count($this->bind) > 0) {
             $exec = $pdostmt->execute($this->bind);
         } else {
             $exec = $pdostmt->execute();
         }
         if ($exec !== false) {
             if (preg_match("/^(" . implode("|", array("select", "describe", "pragma")) . ") /i", $this->sql)) {
                 if ($fetch_mode == 'all') {
                     if (\cx\app\main_functions::found($this->sql, "SQL_CALC_FOUND_ROWS")) {
                         $ret = $pdostmt->fetchAll(PDO::FETCH_ASSOC);
                         $fsql = "SELECT FOUND_ROWS() AS totalRows";
                         $totalRows = $this->query($fsql)->fetch();
                         $this->count = $totalRows[0];
                         return $ret;
                     } else {
                         $this->count = $pdostmt->rowCount();
                         return $pdostmt->fetchAll(PDO::FETCH_ASSOC);
                     }
                 } else {
                     return $pdostmt->fetch(PDO::FETCH_ASSOC);
                 }
             } elseif (preg_match("/^(" . implode("|", array("delete", "insert", "update")) . ") /i", $this->sql)) {
                 return $pdostmt->rowCount();
             }
         }
     } catch (PDOException $e) {
         $this->error = $e->getMessage();
         $this->debug();
         return false;
     }
 }
Exemplo n.º 5
0
 /**
  * Purpose: To group related elements in a form with a box.
  * @param type $name - to specify a form name.
  * @param type $options [legend] or [label] - to set the label for the legend.
  * @param type $options [form] - Specifies one or more forms the fieldset belongs to.
  */
 private function alias_frm_start_fieldset($name, $options)
 {
     $legend = isset($options['legend']) ? $options['legend'] : $name;
     $legend = isset($options['label']) ? $options['label'] : $legend;
     $fieldset_options = '';
     if (isset($options['disabled']) && main_fn::get_bool_value($options['disabled']) === true) {
         $fieldset_options .= " disabled";
     }
     $fieldset_options .= isset($options['class']) ? " class=\"{$options['class']}\"" : '';
     $fieldset_options .= isset($options['form']) ? " form=\"{$options['form']}\"" : '';
     $fieldset_options .= !empty($name) ? " name=\"{$name}\"" : '';
     $this->set_html("<fieldset{$fieldset_options}>");
     $this->set_html("<legend>{$legend}</legend>\r\n");
 }
Exemplo n.º 6
0
 public function get_dyn_local_time($input)
 {
     if (strpos($input, ':') !== false) {
         $settings = array('format' => 'normal', 'time' => $input);
         return main_fn::convert_time_zone($settings);
     } else {
         return false;
     }
 }
Exemplo n.º 7
0
function ssp_output($numrows, $obj_model, $columns)
{
    $draw = isset($_GET['draw']) ? $_GET['draw'] : 1;
    echo '{
      "draw": ' . intval($draw) . ',
      "recordsTotal": ' . $numrows . ',
      "recordsFiltered": ' . $numrows . ',			
      ';
    if ($numrows > 0) {
        echo '"data":[';
        $first = true;
        $Column = array();
        $allow_html = true;
        $rows = $obj_model->get_members($allow_html);
        foreach ($rows as $row) {
            if ($first) {
                $first = false;
            } else {
                echo ',';
            }
            foreach ($columns as $column) {
                $db_col = \cx\app\main_functions::get_db_column($column['db']);
                if (isset($column['fn_results']) && function_exists($column['fn_results'])) {
                    $funct = $column['fn_results'];
                    $out = $funct($row[$db_col]);
                } else {
                    $out = $row[$db_col];
                }
                if (isset($column['textsize']) && strlen($row[$db_col]) > $column['textsize']) {
                    $out = substr(strip_tags($out), 0, $column['textsize']);
                }
                if (isset($column['hyper'])) {
                    $hyper = $column['hyper'];
                    if (isset($column['id'])) {
                        $db_id_col = \cx\app\main_functions::get_db_column($column['id']);
                        $hlink = $hyper . $row[$db_id_col];
                    } else {
                        $hlink = $hyper;
                    }
                    $Column[] = "<a href='{$hlink}'>{$out}</a>";
                } else {
                    $Column[] = $out;
                }
            }
            echo json_encode($Column);
            $Column = '';
            $Column = array();
        }
        echo ']}';
    } else {
        echo '"data":[]}';
    }
}
Exemplo n.º 8
0
 /**
  * Purpose: To report errors to Chrome console...
  * @param type $err
  */
 private function report_form_error($err)
 {
     $this->set_html("<!-- {$err} -->");
     $this->set_html(main_fn::inline_js("log('{$err}');"));
 }
Exemplo n.º 9
0
 public function hash()
 {
     echo \cx\app\main_functions::get_large_random_hash();
 }
Exemplo n.º 10
0
<h1>Generic Pagination</h1>
<div class="wrapper"><div class="container"><div class="row">

<div class="panel panel-default top20">
<div class="panel-body">

<?php 
/**
 * @copyright (c) 2015
 * @author Chris Allen, Robert Strutts
 */
if ($no_results === true) {
    $fade = true;
    echo \cx\app\main_functions::do_alert('No results!', 'info', $fade);
} else {
    echo $paginator_items . "<br><br>";
    foreach ($rows as $row) {
        echo "ID#{$row['id']} : {$row['data']} <br>";
    }
    echo $paginator_links;
    echo $paginator_entries;
}
?>
    
</div></div></div>
</div>
</div>
Exemplo n.º 11
0
 public function get_settings($find, $save = false)
 {
     if (file_exists($this->settings_file)) {
         $settings = file_get_contents($this->settings_file);
         $settings_pos = stripos($settings, 'a:');
         // make sure we have serial data
         if ($settings_pos !== false) {
             $a_settings = main_fn::safe_unserialize($settings);
             if (is_array($find)) {
                 if (is_array($a_settings)) {
                     $ret = '';
                     foreach ($a_settings as $key => $value) {
                         if ($save === false && !in_array($key, $find)) {
                             continue;
                         }
                         if ($save === true && in_array($key, $find)) {
                             continue;
                         }
                         $ret[$key] = $value;
                     }
                     return $ret;
                 }
             }
         }
     }
     return array();
 }