Exemplo n.º 1
0
 protected function _set_display(&$value, $mode)
 {
     // "print_d"
     // "print_r"
     // "var_dump"
     // "var_export"
     $mode = isset($mode) ? strtolower(@(string) $mode) : null;
     switch ($mode) {
         case 'print_d':
             $value = print_d($value, true);
             break;
         case 'print_r':
             $value = print_r($value, true);
             break;
         case 'var_dump':
             ob_start();
             var_dump($value);
             $result = ob_get_clean();
             $value = $result;
             break;
         case 'var_export':
             $value = var_export($value, true);
             break;
     }
 }
Exemplo n.º 2
0
Arquivo: Welcome.php Projeto: New7/3w
 public function my_excel_read()
 {
     $this->load->library('Excel');
     //导出excel
     $data = $this->excel->readExcel('excelFiles\\xxx.xlsx');
     print_d($data);
 }
Exemplo n.º 3
0
 public function do_login()
 {
     $username = '******';
     $password = md5('3126615');
     $this->load->library('uums', array('api' => 'login', 'username' => $username, 'password' => $password));
     $response = $this->uums->execute();
     //echo isset($response->msg)?$response->msg:$response->base_info->username;
     print_d($response);
     //判断是否登录成功
     //登陆成功,写入session
     //跳转
 }
Exemplo n.º 4
0
    public function index()
    {
        $code = '    private function ci_rest($user_id) {

        $this->load->library(\'rest\', array(
            \'server\' => site_url(\'playground/rest/server-api-example/\'),
            //\'http_user\' => \'admin\',
            //\'http_pass\' => \'1234\',
            //\'http_auth\' => \'basic\' // or \'digest\'
        ));

        $result = $this->rest->get(\'users/id/\'.$user_id.\'/format/json\');

        return $result;
    }
';
        $result = $this->ci_rest(1);
        ob_start();
        echo print_d($result, true);
        $result = ob_get_contents();
        ob_end_clean();
        $this->template->set('code', $code)->set('result', $result);
        $this->template->build('rest/client');
    }
Exemplo n.º 5
0
 /**
  * Format data as HTML - debug preview.
  *
  * @param mixed|NULL $data Optional data to pass, so as to override the data passed
  * to the constructor
  * @return string
  */
 public function to_debug($data = NULL)
 {
     // If no data is passed as a parameter, then use the data passed
     // via the constructor
     if ($data === NULL && func_num_args() === 0) {
         $data = $this->_data;
     }
     // Cast as an array if not already
     if (is_array($data) === FALSE) {
         $data = (array) $data;
     }
     return print_d($data);
 }
Exemplo n.º 6
0
    ?>

                        <div class="clearfix"></div>

                        <h3>Status Code:</h3>

                        <?php 
    echo print_d($status_code);
    ?>

                        <div class="clearfix"></div>

                        <h3>Content Type:</h3>

                        <?php 
    echo print_d($content_type);
    ?>

<?php 
} else {
    ?>

                        <div class="alert alert-warning">PHP <?php 
    echo $php_required;
    ?>
 is required for this demo to work.</div>
<?php 
}
?>

                    </div>
Exemplo n.º 7
0
                        <p>
                            <img class="img-thumbnail" src="<?php 
    echo $gravatar;
    ?>
" />
                        </p>

                        <?php 
    echo print_d($profile);
    ?>

                        <div class="clearfix"></div>

                        <?php 
    echo print_d($last_error);
    ?>

                        <div class="clearfix"></div>

<?php 
}
?>


                    </div>

                </div>

            </div>
Exemplo n.º 8
0
                    <div class="col-md-12">

                        <p>
                            See the article
                            <a href="http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/" target="_blank">
                                http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
                            </a>
                        </p>

                        <h3>Code:</h3>

                        <pre><code><?php 
echo html_escape($code_example);
?>
</code></pre>

                        <h3>Result:</h3>

                        <?php 
echo print_d($result);
?>

                    </div>

                </div>

            </div>

        </section>
Exemplo n.º 9
0
 public function cache_initialize()
 {
     if (!($data = $this->cache->get('admin_user_list'))) {
         $this->load->model('admin_user_model', 'admin_user');
         $admin_user_list = $this->admin_user->get_all();
         $data = array();
         foreach ($admin_user_list as $admin) {
             $data[$admin['user_id']] = $admin;
         }
         $this->cache->save('admin_user_list', $data, 28800);
     }
     if (!($data = $this->cache->get('new7_system_list'))) {
         $this->load->model('new7_system_model', 'new7_system');
         $new7_system_list = $this->new7_system->get_all();
         $data = array();
         foreach ($new7_system_list as $system) {
             $data[$system['sys_code']] = $system;
         }
         $this->cache->save('new7_system_list', $data, 28800);
     }
     if (!($data = $this->cache->get('privilege_list'))) {
         $this->load->model('privilege_model', 'privilege');
         $privilege_list = $this->privilege->get_all();
         $data = array();
         foreach ($privilege_list as $privilege) {
             $data[$privilege['privilege_id']] = $privilege;
         }
         $this->cache->save('privilege_list', $data, 28800);
     }
     print_d($data);
 }
$result_delete = ci()->cache->delete('records', $records);
echo print_d($result_delete);
echo '<div style="clear: both;"/>';
echo '<br />';
echo '<br />';
echo 'Reading deleted "records" and showing the result.';
echo '<br />';
$records_read = ci()->cache->get('records', $records);
echo print_d($records_read);
echo '<div style="clear: both;"/>';
echo '<br />';
echo '<br />';
echo 'Reading metadata of non-existing "records" and showing the result.';
echo '<br />';
$records_read = ci()->cache->get_metadata('records');
echo print_d($records_read);
echo '<div style="clear: both;"/>';
echo '<br />';
echo '<hr />';
echo '<br />';
?>

    <p style="margin-top: 25px;">
        <a href="<?php 
echo site_url('playground');
?>
">Back to the playground</a>
    </p>

<?php 
echo js_jquery_extra_selectors();
Exemplo n.º 11
0
function print_d($var, $options = false)
{
    if (is_bool($options)) {
        $options = array('methods' => $options);
    }
    $options['recursive'] = isset($options['recursive']) ? $options['recursive'] : false;
    $ret = '';
    $css = array('holder' => 'border: 1px solid #ddd; padding: 6px; background: #fff; float: left; margin: 3px; font-size: 11px; font-family:Lucida Console, Monaco, monospace;', 'table' => 'border: 1px solid #ddd; border-collapse:collapse;', 'table-methods' => 'margin-top: 4px; width: 100%;', 'td' => 'border: 1px solid #ddd; font-size: 11px; vertical-align: top; padding: 2px 4px 2px 4px; word-wrap: break-word;', 'method' => 'color: #00d;', 'attributes' => 'padding: 2px;', 'table-attributes' => 'width: 100%; border-collapse:collapse;', 'required' => 'text-align: center; color: #d00; width: 16px;', 'attribute' => 'width:120px;', 'pre' => 'font-size: 11px !important; margin: 0; padding: 0; background: none; border: 0;', 'type' => 'color: #bbb;', 'type-array' => '', 'type-object' => '', 'type-' => '', 'type-integer' => 'font-weight: bold; max-width: 250px; color: #00d; text-align: right;', 'type-float' => 'font-weight: bold; max-width: 250px; color: #00d; text-align: right;', 'type-double' => 'font-weight: bold; max-width: 250px; color: #00d; text-align: right;', 'type-string' => 'font-weight: bold; max-width: 250px; color: #d00;', 'type-boolean' => 'font-weight: bold; max-width: 250px; color: #bbb;', 'type-null' => 'font-weight: bold; max-width: 250px; color: #bbb;', 'void' => 'font-style: italic; color: #bbb;', 'emptystring' => 'color: #bbb; font-style: italic; font-weight: normal;');
    if (!$options['recursive']) {
        $t = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
        if (file_exists($t[0]['file'])) {
            $s = file($t[0]['file']);
            $s = $s[$t[0]['line'] - 1];
            $t = explode('print_d(', $s, 2);
            if (count($t) > 1) {
                $t = trim(preg_replace('/\\s+/', ' ', $t[1]));
                $t2 = '';
                $len = strlen($t);
                $prev = false;
                $quotes_open = false;
                $brackets = 0;
                for ($i = 0; $i < $len; ++$i) {
                    $c = $t[$i];
                    if ($quotes_open) {
                        if ($c === $quotes_open && $prev !== '\\') {
                            $quotes_open = false;
                        }
                    } else {
                        if ($c === '\'' || $c === '"') {
                            $quotes_open = $c;
                        } else {
                            if ($c === '(') {
                                ++$brackets;
                            } else {
                                if ($brackets > 0 && $c === ')') {
                                    --$brackets;
                                } else {
                                    if ($brackets === 0 && ($c === ',' || $c === ')')) {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    $t2 .= $t[$i];
                    $prev = $t[$i];
                }
                $t = trim(preg_replace('/\\s+/', ' ', $t2));
                if (strpos($t, '(')) {
                    if (strtolower(substr($t, 0, 6)) !== 'array(') {
                        $func_name = $t;
                    }
                } else {
                    if ($t[0] === '$') {
                        $name = $t;
                        $name = trim(preg_replace('/\\s+/', '', $name));
                    }
                }
            }
        }
    }
    $type = strtolower(gettype($var));
    if (!$options['recursive']) {
        $ret .= '<div style="' . $css['holder'] . '">';
    }
    if ($type === 'array' || $type === 'object' || isset($func_name)) {
        if (isset($name)) {
            $ret .= '<strong>' . $name . '</strong>';
        } else {
            if (isset($func_name)) {
                $ret .= '<strong>' . $func_name . '</strong>';
            }
        }
        if ($type === 'object') {
            $ret .= ' ' . get_class($var);
        }
    }
    $ret .= '<table style="' . $css['table'] . '">';
    switch ($type) {
        case 'array':
        case 'object':
            $count = 0;
            if ($var) {
                foreach ($var as $i => $v) {
                    ++$count;
                    $v_type = strtolower(gettype($v));
                    if ($v_type === 'object' || $v_type === 'array') {
                        $v = print_d($v, array('recursive' => true));
                    } else {
                        if ($v_type === 'boolean') {
                            $v = $v ? 'TRUE' : 'FALSE';
                        } else {
                            if ($v_type === 'string' && $v === '') {
                                $v = '<span style="' . $css['emptystring'] . '">empty string</span>';
                            } else {
                                if ($v_type === 'null') {
                                    $v = 'NULL';
                                }
                            }
                        }
                    }
                    $ret .= '<tr>';
                    $ret .= '<td style="' . $css['td'] . $css['type'] . '">' . $v_type . '</td>';
                    $ret .= '<td style="' . $css['td'] . '">' . $i . '</td>';
                    $ret .= '<td style="' . $css['td'] . $css['type-' . $v_type] . '">' . $v . '</td>';
                    $ret .= '</tr>';
                }
            }
            if ($count === 0) {
                $ret .= '<tr>';
                $ret .= '<td style="' . $css['td'] . '"><span style="' . $css['emptystring'] . '">empty ' . ($type === 'array' ? 'array' : 'class') . '</span></td>';
                $ret .= '</tr>';
            }
            if ($type === 'object' && ($options === true || isset($options['methods']) && $options['methods'] === true)) {
                $methods = get_class_methods($var);
                if ($methods) {
                    $ret .= '</table>';
                    $ret .= '<table style="' . $css['table'] . $css['table-methods'] . '">';
                    foreach ($methods as $m) {
                        $r = new ReflectionMethod($var, $m);
                        $params = $r->getParameters();
                        $ret .= '<tr>';
                        $ret .= '<td style="' . $css['td'] . $css['method'] . '">' . $m . '</td>';
                        $ret .= '<td style="' . $css['td'] . $css['attributes'] . '">';
                        if ($params) {
                            $ret .= '<table style="' . $css['table-attributes'] . '">';
                            foreach ($params as $p) {
                                if ($p->isDefaultValueAvailable()) {
                                    $value = $p->getDefaultValue();
                                    $v_type = strtolower(gettype($value));
                                    if ($v_type === 'string' && $value === '') {
                                        $value = '<span style="' . $css['emptystring'] . '">empty string</span>';
                                    } else {
                                        if ($v_type === 'boolean') {
                                            $value = $value ? 'TRUE' : 'FALSE';
                                        } else {
                                            if ($v_type === 'null') {
                                                $value = 'NULL';
                                            }
                                        }
                                    }
                                } else {
                                    $value = '<span style="' . $css['emptystring'] . '">n/a</span>';
                                    $v_type = '';
                                }
                                $ret .= '<tr>';
                                $ret .= '<td style="' . $css['td'] . $css['required'] . '">' . ($p->isOptional() ? '' : '*') . '</td>';
                                $ret .= '<td style="' . $css['td'] . $css['attribute'] . '">' . $p->getName() . '</td>';
                                $ret .= '<td style="' . $css['td'] . $css['type-' . $v_type] . '">' . $value . '</td>';
                                $ret .= '</tr>';
                            }
                            $ret .= '</table>';
                        } else {
                            $ret .= '<span style="' . $css['void'] . '">void</span>';
                        }
                        $ret .= '</td>';
                        $ret .= '</tr>';
                    }
                }
            }
            break;
        default:
            if ($type === 'boolean') {
                $var = $var ? 'TRUE' : 'FALSE';
            } else {
                if ($type === 'null') {
                    $var = 'NULL';
                }
            }
            $ret .= '<tr>';
            $ret .= '<td style="' . $css['td'] . $css['type'] . '">' . $type . '</td>';
            if (isset($name)) {
                $ret .= '<td style="' . $css['td'] . '">' . $name . '</td>';
            }
            $ret .= '<td style="' . $css['td'] . $css['type-' . $type] . '">' . $var . '</td>';
            $ret .= '</tr>';
            break;
    }
    $ret .= '</table>';
    if (!$options['recursive']) {
        $ret .= '</div>';
    }
    return $ret;
}
Exemplo n.º 12
0
 public function exampleRetrieveComponentData()
 {
     $storage = $this->container->get('core.service.theme.user.data.storage.db');
     print_d($storage->retrieveComponentValue(1, 1, 'link_763476tr73fg763476f38487375'));
 }
Exemplo n.º 13
0
 /**
  * execute SELECT
  * @param $table
  * @param $cols
  * @param array $options
  * @param bool $distinct
  * @param bool $total_rows
  * @return bool|\PDOStatement
  * @throws \ErrorException
  */
 private function select($table, $cols, $options = array(), $distinct = false, $total_rows = false)
 {
     // empty cols
     if (empty($cols)) {
         throw new \ErrorException('SQL Error: Can\'t select nothing.');
     }
     if (is_array($table) && count($table) <= 0) {
         throw new \ErrorException('SQL Error: Can\'t select from nothing.');
     }
     // Table list
     if (is_array($table)) {
         // Computes to FROM `table1` ONE, `table2` TWO ...
         $table_list = array();
         foreach ($table as $as => $name) {
             $table_list[] = '`' . $this->pref . $name . '` ' . $as;
         }
         $table_list = implode(', ', $table_list);
     } else {
         $table_list = '`' . $this->pref . $table . '`';
     }
     // prepare data
     if (is_array($cols)) {
         $cols_list = array();
         foreach ($cols as $col) {
             if (is_array($col)) {
                 $cols_list[] = $this->select_expr($col);
             } else {
                 $cols_list[] = '`' . $col . '`';
             }
         }
         $cols_list = implode(', ', $cols_list);
         // error
     } elseif ($cols == '*') {
         $cols_list = $cols;
     } else {
         throw new \ErrorException('SQL Error: Cannot select because of bad data.');
     }
     // DISTINCT or not
     $select = $distinct ? 'SELECT DISTINCT ' : 'SELECT ';
     // Total Rows?
     $select .= $total_rows ? ' SQL_CALC_FOUND_ROWS' : '';
     // build query string...
     $qrystr = $select . $cols_list . ' FROM ' . $table_list . $this->opt($options);
     try {
         return $this->doQuery($qrystr);
         // ... and execute
     } catch (\Exception $e) {
         print_d($e->getMessage());
         return null;
     }
 }