Example #1
0
function dbg_print($obj)
{
    global $is_debug;
    if ($is_debug) {
        print_r2($obj);
    }
}
Example #2
0
 function run($form, $actiondata)
 {
     echo "Data Array: <br />";
     print_r2($form->data);
     echo "Validation Errors: <br />";
     print_r2($form->validation_errors);
 }
 public function cargar_granjero()
 {
     $id = $this->get->id;
     $this->orm->connect();
     $options['granjero']['lvl2'] = "one";
     $options['finca']['lvl2'] = "all";
     $code['granjero']['id'] = $id;
     $components['granjero']['finca'] = array('g_f');
     $this->orm->read_data(array("granjero", "finca"), $options, $code);
     $granjero = $this->orm->get_objects("granjero", $components);
     print_r2($granjero);
     $this->engine->assign('granjero', $granjero[0]);
     $this->orm->close();
 }
 public function display()
 {
     $options["parque"]["lvl2"] = "by_nivel";
     $options["calificacion"]["lvl2"] = "all";
     $cod["parque"]["nivel"] = "alto";
     $components["parque"]["calificacion"] = array("p_c");
     $this->orm->connect();
     $this->orm->read_data(array("parque", "calificacion"), $options, $cod);
     $granjero = $this->orm->get_objects("parque", $components);
     print_r2($granjero);
     $this->engine->assign("granjero", $granjero);
     $this->engine->assign("title", "Datos Multiples");
     $this->engine->display("header.tpl");
     $this->engine->display("granjeros.tpl");
     $this->engine->display("footer.tpl");
 }
Example #5
0
    function sort_admin_navi()
    {
        $this->outer_template = null;

    // Require admin login
        if(!(isset($_SESSION['active_user']) && $_SESSION['active_user']['type'] == 'admin'))
            die;

        if(!isset($_POST['SortOrder']))
            die;

        $order = explode(',', $_POST['SortOrder']); 

        print_r2($order);

        $m_navi = instance_model('navigation');
        $m_navi->update_sort($order);
    }
Example #6
0
 public function display()
 {
     $options['finca']['lvl2'] = "especial_1";
     $this->orm->connect();
     $this->orm->read_data(array("finca"), $options, $code);
     $granjero = $this->orm->get_objects("finca");
     $this->engine->assign('finca', $finca);
     print_r2($finca);
     $id = $finca[0]['granjero'];
     $options['granjero']['lvl2'] = "one";
     $codes['granjero']['id'] = $id;
     $this->orm->read_data(array("granjero"), $options, $codes);
     $finca = $this->orm->get_objects("granjero");
     if (is_empty($finca)) {
         $mensaje = "No tiene fincas";
     }
     $this->engine->assign('mensaje', $mensaje);
     $this->engine->assign('finca', $finca);
     $this->engine->assign('title', 'Granjeros');
     $this->engine->display('header.tpl');
     $this->engine->display('mostrar2.tpl');
     $this->engine->display('footer.tpl');
     $this->orm->close();
 }
Example #7
0
 function debuginfo()
 {
     # this is debug info for developer
     if ($this->debuglevel == 0) {
         return;
     }
     $ret = print_r2($this->queries) . $this->clientip;
     return $ret;
 }
Example #8
0
<?php

require_once 'functions.php';
print_r2(mmc_array_values(DATA_MESSAGE_LIST));
Example #9
0
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 */
/*
 * Presents error.
 */
//========================================================================
// Includes
//========================================================================
include_once 'include/session.php';
// initializes session and provides
include 'include/utils.php';
//========================================================================
// Main
//========================================================================
?>
<!DOCTYPE html">
<html>
    <head>
        <link rel="stylesheet" href="css/homestyle.css" type="text/css">
    </head>
    <body>
    	<?php 
if (isset($_SESSION["errorMessage"])) {
    print_r2($_SESSION["errorMessage"]);
} else {
    echo "You shouldn't be on this page";
}
?>
    </body>
</html>
Example #10
0
<?php

function is_palindrome($str)
{
    if (strlen($str) <= 1) {
        return true;
    }
    $str_cleaned = preg_replace('/\\s|[[:punct:]]|_/', '', $str);
    if (strrev($str_cleaned) == $str_cleaned) {
        return "true";
    } else {
        return "false";
    }
}
function print_r2($val)
{
    echo '<pre>';
    print_r($val);
    echo '</pre>';
}
print_r2(is_palindrome("racecar"));
print_r2(is_palindrome("rac ecar  ."));
print_r2(is_palindrome("yolo"));
Example #11
0
 public function select($option, $data)
 {
     $info = array();
     switch ($option['lvl1']) {
         case "curso":
             switch ($option['lvl2']) {
                 case "all":
                     $this->escape_string($data);
                     $info = $this->get_data("SELECT * FROM curso");
                     break;
             }
             break;
         case "estudiante":
             switch ($option['lvl2']) {
                 case "all":
                     $this->escape_string($data);
                     $info = $this->get_data("SELECT * FROM curso");
                     break;
                 case "mayores":
                     $this->escape_string($data);
                     $info = $this->get_data("SELECT * FROM estudiante WHERE edad >20;");
                     break;
                 case "one":
                     $this->escape_string($data);
                     $id = $data['id'];
                     $info = $this->get_data("SELECT * FROM estudiante WHERE id='{$id}';");
                     break;
                 case "by_ingles":
                     $info = $this->get_data("SELECT e.id, e.nombre, e.edad FROM curso c,\n\t\t\t\t\t matricula m, estudiante e where c.id=m.curso and e.id=m.estudiante and\n\t\t\t\t\t  c.nombre='Ingles' and m.nota_final<3");
                     break;
             }
             break;
         case "matricula":
             switch ($option['lvl2']) {
                 case "all":
                     $info = $this->get_data("SELECT * FROM matricula");
                     break;
                 case "by_estudiante":
                     $estudiante = mysqli_real_escape_string($this->cn, $data['estudiante']);
                     $info = $this->get_data("SELECT * FROM matricula WHERE estudiante='{$estudiante}';");
                     break;
             }
             break;
         case "user":
             switch ($option['lvl2']) {
                 case "all":
                     //
                     break;
             }
             break;
         case "canal":
             switch ($option['lvl2']) {
                 case "all":
                     $this->escape_string($data);
                     $info = $this->get_data("SELECT * FROM canal;");
                     break;
                 case "one":
                     $this->escape_string($data);
                     $nombre = mysqli_real_escape_string($this->cn, $data['nombre']);
                     $info = $this->get_data("SELECT * FROM canal where canal.nombre='{$nombre}';");
                     break;
             }
         case "video":
             switch ($option['lvl2']) {
                 case "by_canal":
                     $this->escape_string($data);
                     $nombre = mysqli_real_escape_string($this->cn, $data['canal']);
                     $info = $this->get_data("SELECT * FROM video WHERE video.canal='{$nombre}'");
                     //print_r2($info);
                     break;
                 case "all_with_granjero_id":
                     $this->escape_string($data);
                     $id = $data['id'];
                     $granjero = $data['granjero'];
                     //$id=mysqli_real_escape_string($this->cn,$data['granjero']);
                     $info = $this->get_data("SELECT f.*, g.nombre as name FROM granjero g,finca f WHERE g.id=f.granjero AND f.id='{$id}';");
                     print_r2($info);
                     break;
                 case "by_boss":
                     $id = $data['granjero'];
                     $info = $this->get_data("SELECT * FROM finca WHERE granjero='{$id}';");
                     print_r2($info);
                     break;
             }
             break;
         case "clerk":
             switch ($option['lvl2']) {
                 case "all":
                     //
                     break;
                 case "by_boss":
                     $boss = mysqli_real_escape_string($this->cn, $data['boss']);
                     $info = $this->get_data("SELECT * FROM clerk WHERE boss='{$boss}';");
                     #print_r2($info);
                     break;
                 case "one":
                     $id = mysqli_real_escape_string($this->cn, $data['id']);
                     $info = $this->get_data("SELECT * FROM clerk WHERE id='{$id}';");
                     break;
             }
             break;
         case "boss":
             switch ($option['lvl2']) {
                 case "all":
                     $info = $this->get_data("SELECT * FROM boss");
                     break;
                 case "one":
                     $id = mysqli_real_escape_string($this->cn, $data['id']);
                     $info = $this->get_data("SELECT * FROM boss WHERE id='{$id}';");
                     break;
             }
             break;
         case "granjero":
             switch ($option['lvl2']) {
                 case "all":
                     $info = $this->get_data("SELECT * FROM granjero");
                     break;
                 case "one":
                     $id = mysqli_real_escape_string($this->cn, $data['id']);
                     $info = $this->get_data("SELECT * FROM granjero WHERE id='{$id}';");
                     break;
                 case "by_boss":
                     $id = mysqli_real_escape_string($this->cn, $data['id']);
                     $info = $this->get_data("SELECT * FROM finca WHERE granjero='{$id}';");
                     #print_r2($info);
                     break;
             }
             break;
         case "vendedor":
             switch ($option['lvl2']) {
                 case "all":
                     $this->escape_string($data);
                     $info = $this->get_data("SELECT * FROM vendedor");
                     break;
                 case "one":
                     $id = mysqli_real_escape_string($this->cn, $data['cedula']);
                     $info = $this->get_data("SELECT * FROM vendedor WHERE cedula='{$id}';");
                     #print_r2($info);
                     break;
             }
             break;
         case "producto":
             switch ($option['lvl2']) {
                 case "all":
                     $this->escape_string($data);
                     $info = $this->get_data("SELECT * FROM producto");
                     break;
                 case "one":
                     $id = mysqli_real_escape_string($this->cn, $data['nombre']);
                     $info = $this->get_data("SELECT * FROM producto WHERE nombre='{$id}';");
                     break;
             }
             break;
         case "venta":
             switch ($option['lvl2']) {
                 case "all":
                     $this->escape_string($data);
                     $info = $this->get_data("SELECT * FROM venta");
                     break;
                 case "one":
                     $id = mysqli_real_escape_string($this->cn, $data['nombre']);
                     $info = $this->get_data("SELECT * FROM producto WHERE nombre='{$id}';");
                     break;
                 case "by_vendedor":
                     $id = mysqli_real_escape_string($this->cn, $data['cedula']);
                     print_r2($id);
                     $info = $this->get_data("SELECT * FROM venta WHERE cedula='{$id}';");
                     print_r2($info);
                     break;
             }
             break;
         case "finca":
             switch ($option['lvl2']) {
                 case "all":
                     $info = $this->get_data("SELECT * FROM finca");
                     break;
                 case "one":
                     $id = mysqli_real_escape_string($this->cn, $data['id']);
                     $info = $this->get_data("SELECT * FROM finca WHERE id='{$id}';");
                     break;
                 case "by_granjero":
                     $this->escape_string($data);
                     //$id=mysqli_real_escape_string($this->cn,$data['granjero']);
                     $info = $this->get_data("SELECT * FROM finca WHERE granjero={$data['granjero']};");
                     //print_r2($info);
                     break;
                 case "all_with_granjero_id":
                     $this->escape_string($data);
                     $id = $data['id'];
                     $granjero = $data['granjero'];
                     //$id=mysqli_real_escape_string($this->cn,$data['granjero']);
                     $info = $this->get_data("SELECT f.*, g.nombre as name FROM granjero g,finca f WHERE g.id=f.granjero AND f.id='{$id}';");
                     print_r2($info);
                     break;
                 case "by_boss":
                     $id = $data['granjero'];
                     $info = $this->get_data("SELECT * FROM finca WHERE granjero='{$id}';");
                     print_r2($info);
                     break;
             }
             break;
         default:
             break;
     }
     return $info;
 }
Example #12
0
 function debuginfo()
 {
     # this is debug info for developer, me !
     if ($this->debuglevel == 0) {
         return;
     }
     #if($this->clientip<>'127.0.0.1' and $this->conf['adminemail']<>'*****@*****.**' and $this->clientip<>'78.187.86.112') return false;
     $ret = print_r2($this->queries) . $this->clientip;
     return $ret;
 }
Example #13
0
 /**
  * Round
  *
  * @param string $arg1
  * @param int $scale
  * @return string
  */
 public static function round($arg1, $scale = 0)
 {
     if (!is_int($scale)) {
         print_r2($scale);
         exit;
     }
     if ($arg1[0] != '-') {
         return bcadd($arg1, '0.' . str_repeat('0', $scale) . '5', $scale);
     } else {
         return bcsub($arg1, '0.' . str_repeat('0', $scale) . '5', $scale);
     }
 }
Example #14
0
    /**
     * Render debug toolbar
     *
     * @return string
     */
    public static function render()
    {
        $loaded_classes = application::get(['application', 'loaded_classes']);
        self::$data['session'] = [];
        if (!empty($_SESSION)) {
            self::$data['session'] = [$_SESSION];
        }
        $application = application::get();
        $result = '<div class="container" dir="ltr">';
        $result .= '<table cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<td>';
        $result .= '<table width="100%">';
        $result .= '<tr>';
        $result .= '<td nowrap>&nbsp;' . html::a(['value' => 'Hide All', 'href' => 'javascript:void(0);', 'onclick' => "\$('.debuging_toolbar_class').hide();"]) . '&nbsp;</td>';
        foreach (self::$data as $k => $v) {
            if ($k == 'errors') {
                $count = count(error_base::$errors);
            } else {
                if ($k == 'classes') {
                    $count = count($loaded_classes);
                } else {
                    if ($k == 'application') {
                        $count = count($application);
                    } else {
                        if ($k == 'phpinfo') {
                            $count = 1;
                        } else {
                            $count = count($v);
                        }
                    }
                }
            }
            $result .= '<td nowrap>&nbsp;' . html::a(['value' => ucwords($k) . ' (' . $count . ')', 'id' => "debuging_toolbar_{$k}_a", 'href' => 'javascript:void(0);', 'onclick' => "\$('#debuging_toolbar_{$k}').toggle();"]) . '&nbsp;</td>';
        }
        $result .= '<td width="50%" align="right">' . html::a(['href' => '/numbers/frontend/system/controller/dev', 'value' => 'Dev. Portal']) . '</td>';
        $result .= '</tr>';
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // errors
        $result .= '<tr id="debuging_toolbar_errors" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Errors (' . count(error_base::$errors) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        foreach (error_base::$errors as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . error_base::$error_codes[$v['errno']] . ' (' . $v['errno'] . ') - ' . implode('<br/>', $v['error']) . '</b></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td><pre>' . $v['code'] . '</pre></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td><pre>' . implode("\n", $v['backtrace']) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // suppressed
        $result .= '<tr id="debuging_toolbar_suppressed" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Suppressed (' . count(self::$data['suppressed']) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        foreach (self::$data['suppressed'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . error_base::$error_codes[$v['errno']] . ' (' . $v['errno'] . ') - ' . implode('<br/>', $v['error']) . '</b></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td><pre>' . $v['code'] . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // javascript
        $result .= '<tr id="debuging_toolbar_js" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Javascript Errors (' . count(self::$data['js']) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        foreach (self::$data['js'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . implode('<br/>', $v['error']) . '</b></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '<div id="debuging_toolbar_js_data">';
        $result .= '&nbsp;';
        $result .= '</div>';
        $result .= '</td>';
        $result .= '</tr>';
        // benchmark first
        $result .= '<tr id="debuging_toolbar_benchmark" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Benchmark (' . count(self::$data['benchmark']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Name</th>';
        $result .= '<th>Time</th>';
        $result .= '<th>Start</th>';
        $result .= '<th>Total</th>';
        $result .= '<th>Memory</th>';
        $result .= '</tr>';
        foreach (self::$data['benchmark'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td>' . $v['name'] . '</td>';
            $result .= '<td align="right">' . $v['time'] . '</td>';
            $result .= '<td align="right">' . $v['start'] . '</td>';
            $result .= '<td align="right">' . $v['total'] . '</td>';
            $result .= '<td align="right">' . format::memory($v['memory'], 'm') . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // sql
        $result .= '<tr id="debuging_toolbar_sql" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Sql (' . count(self::$data['sql']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Sql</th>';
        $result .= '<th>Error</th>';
        $result .= '<th>Errno</th>';
        $result .= '<th>Num Rows</th>';
        $result .= '<th>Affected Rows</th>';
        //$result.= '<th>Rows</th>';
        $result .= '<th>Key</th>';
        $result .= '<th>Structure</th>';
        $result .= '<th>Time</th>';
        $result .= '</tr>';
        foreach (self::$data['sql'] as $k => $v) {
            $temp = is_array($v['key']) ? implode('<br/>', $v['key']) : $v['key'];
            // header first
            $result .= '<tr>';
            $result .= '<td valign="top"><pre style="width: 500px;">' . nl2br($v['sql']) . '</pre></td>';
            $result .= '<td valign="top">' . implode('<br/>', $v['error']) . ' - ' . implode('<br/>', $v['error_original'] ?? []) . '</td>';
            $result .= '<td valign="top">' . $v['errno'] . '</td>';
            $result .= '<td valign="top">' . $v['num_rows'] . '</td>';
            $result .= '<td valign="top">' . $v['affected_rows'] . '</td>';
            //$result.= '<td valign="top">' . html::table(['options' => $v['rows']]) . '</td>';
            $result .= '<td valign="top">' . $temp . '</td>';
            $result .= '<td valign="top">' . html::table(['options' => $v['structure']]) . '</td>';
            $result .= '<td valign="top">' . $v['time'] . '</td>';
            $result .= '</tr>';
            // results second
            if (!empty($v['rows'])) {
                $temp = array_keys(current($v['rows']));
                $header = array_combine($temp, $temp);
                if (!empty($header)) {
                    $result .= '<tr>';
                    $result .= '<td valign="top" colspan="8" style="max-width: 1000px; overflow: scroll;">' . html::table(['header' => $header, 'options' => $v['rows']]) . '</td>';
                    $result .= '</tr>';
                }
            }
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // cache
        $result .= '<tr id="debuging_toolbar_cache" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Cache (' . count(self::$data['cache']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Type</th>';
        $result .= '<th>Link</th>';
        $result .= '<th>Cache #</th>';
        $result .= '<th>Has Data</th>';
        $result .= '</tr>';
        foreach (self::$data['cache'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top">' . $v['type'] . '</td>';
            $result .= '<td valign="top">' . $v['link'] . '</td>';
            $result .= '<td valign="top">' . $v['cache_id'] . '</td>';
            $result .= '<td valign="top">' . ($v['have_data'] ? 'Yes' : 'No') . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // dump
        $result .= '<tr id="debuging_toolbar_dump" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Dump (' . count(self::$data['dump']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Name</th>';
        $result .= '<th>Dump</th>';
        $result .= '</tr>';
        foreach (self::$data['dump'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top">' . $v['name'] . '</td>';
            $result .= '<td valign="top"><pre>' . print_r($v['value'], true) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // input
        $result .= '<tr id="debuging_toolbar_input" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Input (' . count(self::$data['input']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Input</th>';
        $result .= '</tr>';
        foreach (self::$data['input'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top"><pre>' . print_r($v, true) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // session
        $result .= '<tr id="debuging_toolbar_session" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Session (' . count(self::$data['session']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Session</th>';
        $result .= '</tr>';
        foreach (self::$data['session'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top"><pre>' . print_r($v, true) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // autoloaded classes
        $result .= '<tr id="debuging_toolbar_classes" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Loaded Classes (' . count($loaded_classes) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Class Name</th>';
        $result .= '<th>File</th>';
        $result .= '<th>Media</th>';
        $result .= '</tr>';
        foreach ($loaded_classes as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . $v['class'] . '</b></td>';
            $result .= '<td>' . $v['file'] . '</td>';
            $result .= '<td>' . html::table(['options' => $v['media']]) . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // application
        $result .= '<tr id="debuging_toolbar_application" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Application (' . count($application) . ')</h3>';
        $result .= print_r2($application, true);
        $result .= '</td>';
        $result .= '</tr>';
        // phpinfo
        $result .= '<tr id="debuging_toolbar_phpinfo" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>PHPInfo</h3>';
        helper_ob::start();
        phpinfo();
        $str = helper_ob::clean();
        $str = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $str);
        $str .= <<<TTT
\t\t\t\t\t\t\t<style type="text/css">
\t\t\t\t\t\t\t\t#phpinfo table {
\t\t\t\t\t\t\t\t\tborder: 1px solid #000;
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t#phpinfo table tr {
\t\t\t\t\t\t\t\t\tborder-bottom: 1px solid #000;
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t</style>
TTT;
        $result .= '<div id="phpinfo">' . $str . '</div>';
        $result .= '</td>';
        $result .= '</tr>';
        // acls
        $result .= '<tr id="debuging_toolbar_acls" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Acls (' . count(debug::$data['acls']) . ')</h3>';
        $result .= print_r2(debug::$data['acls'], true);
        $result .= '</td>';
        $result .= '</tr>';
        $result .= '</table>';
        $result .= '</div>';
        return $result;
    }
Example #15
0
function inputform5($alanlar, $action = '')
{
    global $debuglevel, $output;
    /*
    * general purpose input form generator. examples below.
    *
    sadece echo yapmaz.
    degistirildi. artik textarea gosterebiliyor.
    $res.="alanlar:".print_r2($alan);
    $res.="degerler:".print_r2($deger);
    */
    if (!is_array($alanlar)) {
        $alanlar = array($alanlar);
    }
    # convert to array if not , i.e, you dont need to use an array if you only has one input element,
    $alanlar[] = array('_insert', 'tip' => 'hidden', 'varsayilan' => '1');
    $alansayisi = count($alanlar);
    $res .= "\n\t<script> // script for pass generate\nvar keylist='abcdefghijklmnopqrstuvwxyz123456789'\nvar temp=''\nfunction generatepass(){\n\ttemp=''\n\tfor (i=0;i<6;i++)\n\ttemp+=keylist.charAt(Math.floor(Math.random()*keylist.length))\n\treturn temp\n}\n</script>\n\n\t<form method=post enctype='multipart/form-data' ";
    if ($action != "") {
        $res .= " action='{$action}'";
    }
    $res .= "><table class='inputform'>";
    if ($debuglevel > 2) {
        $output .= print_r2($alanlar);
    }
    foreach ($alanlar as $alan) {
        $res .= inputelement2($alan);
    }
    $res .= "</table>";
    if (strstr($res, "input type='submit' ") === false) {
        $res .= "<input type=submit>";
    }
    $res .= "</form>";
    return $res;
    /* this function is very flexible, c*k esnek yani... ingilizce yazdik diye yanlis anlasilmasin, anadoluda yazildi bu...;)
     * example usages:
     * echo inputform5('name')   # displays only an input form with field name
     * echo inputform5(array('name','surname'))  # input form with name, surname
     * echo inputform5(array(array('name','varsayilan'=>'defaultname'),'surname'))  # using default value
     * etc...
     */
}
Example #16
0
 function run($form, $actiondata)
 {
     echo "Data Array: <br />";
     print_r2($form->data);
 }
<?php

function longest_substr($str1, $str2)
{
    $common = array();
    $str1_arr = str_split($str1);
    $str2_arr = str_split($str2);
    foreach ($str1_arr as $value) {
        if (in_array($value, $str2_arr) && !in_array($value, $common)) {
            array_push($common, $value);
        }
    }
    return $common;
}
function print_r2($val)
{
    echo '<pre>';
    print_r($val);
    echo '</pre>';
}
print_r2(longest_substr("ABCDAF", "ACBCF"));
Example #18
0
 /**
  * Render elements value
  *
  * @param array $options
  * @param mixed $value
  * @param array $neighbouring_values
  * @return string
  * @throws Exception
  */
 public function render_element_value(&$options, $value = null, &$neighbouring_values = [])
 {
     // field name and values_key
     $options['options']['field_name'] = $options['options']['details_field_name'] ?? $options['options']['name'];
     $options['options']['field_values_key'] = implode('[::]', $options['options']['field_values_key'] ?? [$options['options']['field_name']]);
     // custom renderer
     if (!empty($options['options']['custom_renderer'])) {
         $method = factory::method($options['options']['custom_renderer'], null, true);
         $options_custom_renderer = $options;
         call_user_func_array($method, [&$this, &$options, &$value, &$neighbouring_values]);
     }
     // handling override_field_value method
     if (!empty($this->wrapper_methods['override_field_value']['main'])) {
         call_user_func_array($this->wrapper_methods['override_field_value']['main'], [&$this, &$options, &$value, &$neighbouring_values]);
     }
     $result_options = $options['options'];
     $options['options']['value'] = $value;
     array_key_extract_by_prefix($result_options, 'label_');
     $element_expand = !empty($result_options['expand']);
     $html_suffix = $result_options['html_suffix'] ?? '';
     // unset certain keys
     unset($result_options['order'], $result_options['required'], $result_options['html_suffix']);
     // processing options
     $flag_select_or_autocomplete = !empty($result_options['options_model']) || !empty($result_options['options']);
     if (!empty($result_options['options_model'])) {
         if (empty($result_options['options_params'])) {
             $result_options['options_params'] = [];
         }
         if (empty($result_options['options_options'])) {
             $result_options['options_options'] = [];
         }
         $result_options['options_options']['i18n'] = $result_options['options_options']['i18n'] ?? true;
         $result_options['options_options']['acl'] = $result_options['options_options']['acl'] ?? $this->acl;
         if (empty($result_options['options_depends'])) {
             $result_options['options_depends'] = [];
         }
         // options depends & params
         $this->process_params_and_depends($result_options['options_depends'], $neighbouring_values, $options, true);
         $this->process_params_and_depends($result_options['options_params'], $neighbouring_values, $options, false);
         $result_options['options_params'] = array_merge_hard($result_options['options_params'], $result_options['options_depends']);
         // we do not need options for autocomplete
         if (strpos($result_options['method'], 'autocomplete') === false) {
             $skip_values = [];
             if (!empty($options['options']['details_key'])) {
                 if (!empty($options['options']['details_parent_key'])) {
                     $temp_key = $options['options']['details_parent_key'] . '::' . $options['options']['details_key'];
                     if (!empty($this->misc_settings['details_unique_select'][$temp_key][$options['options']['details_field_name']][$options['options']['__parent_row_number']])) {
                         $skip_values = array_keys($this->misc_settings['details_unique_select'][$temp_key][$options['options']['details_field_name']][$options['options']['__parent_row_number']]);
                     }
                 } else {
                     if (!empty($this->misc_settings['details_unique_select'][$options['options']['details_key']][$options['options']['details_field_name']])) {
                         $skip_values = array_keys($this->misc_settings['details_unique_select'][$options['options']['details_key']][$options['options']['details_field_name']]);
                     }
                 }
             }
             $result_options['options'] = object_data_common::process_options($result_options['options_model'], $this, $result_options['options_params'], $value, $skip_values, $result_options['options_options']);
         } else {
             // we need to inject form id into autocomplete
             $result_options['form_id'] = "form_{$this->form_link}_form";
         }
     }
     // by default all selects are searchable if not specified otherwise
     if ($flag_select_or_autocomplete) {
         $result_options['searchable'] = $result_options['searchable'] ?? false;
     }
     // different handling for different type
     switch ($options['type']) {
         case 'container':
             $options_container = $options;
             //$options_container['previous_data'] = $v;
             // todo: pass $form_data_key from parent
             $options_container['previous_key'] = $options['previous_key'];
             // render container
             $temp_container_value = $this->render_container($data['fm_part_child_container_name'], $parents, $options_container);
             if (!empty($html_expand)) {
                 // get part id
                 $temp_id = $this->id('part_details', ['part_name' => $data['fm_part_name'], 'part_id' => $options_container['previous_id']]);
                 $temp_id_div_inner = $temp_id . '_html_expand_div_inner';
                 $temp_expand_div_inner = ['id' => $temp_id_div_inner, 'style' => 'display: none;', 'value' => $temp_container_value];
                 $temp_expand_div_a = ['href' => 'javascript:void(0);', 'onclick' => "numbers.element.toggle('{$temp_id_div_inner}');", 'value' => '+ / -'];
                 $temp_expand_div_outer = ['align' => 'left', 'value' => html::a($temp_expand_div_a) . '<br />' . html::div($temp_expand_div_inner)];
                 $value = html::div($temp_expand_div_outer);
             } else {
                 $value = $temp_container_value;
             }
             $result_options['value'] = $value;
             break;
         case 'field':
             $element_method = $result_options['method'] ?? 'html::input';
             if (strpos($element_method, '::') === false) {
                 $element_method = 'html::' . $element_method;
             }
             // value in special order
             $flag_translated = false;
             if (in_array($element_method, ['html::a', 'html::submit', 'html::button', 'html::button2'])) {
                 // translate value
                 $result_options['value'] = i18n($result_options['i18n'] ?? null, $result_options['value'] ?? null);
                 // process confirm_message
                 $result_options['onclick'] = $result_options['onclick'] ?? '';
                 if (!empty($result_options['confirm_message'])) {
                     $result_options['onclick'] .= 'return confirm(\'' . strip_tags(i18n(null, $result_options['confirm_message'])) . '\');';
                 }
                 // processing onclick for buttons
                 if (in_array($element_method, ['html::submit', 'html::button', 'html::button2'])) {
                     if (!empty($result_options['onclick']) && strpos($result_options['onclick'], 'this.form.submit();') !== false) {
                         $result_options['onclick'] = str_replace('this.form.submit();', "numbers.form.trigger_submit(this.form);", $result_options['onclick']) . ' return true;';
                     } else {
                         if (empty($result_options['onclick'])) {
                             $result_options['onclick'] .= 'numbers.form.trigger_submit_on_button(this); return true;';
                         } else {
                             $result_options['onclick'] = 'numbers.form.trigger_submit_on_button(this); ' . $result_options['onclick'];
                         }
                     }
                 }
                 $flag_translated = true;
                 // icon
                 if (!empty($result_options['icon'])) {
                     $result_options['value'] = html::icon(['type' => $result_options['icon']]) . ' ' . $result_options['value'];
                 }
                 // accesskey
                 if (isset($result_options['accesskey'])) {
                     $accesskey = explode('::', i18n(null, 'accesskey::' . $result_options['name'] . '::' . $result_options['accesskey'], ['skip_translation_symbol' => true]));
                     $result_options['accesskey'] = $accesskey[2];
                     $result_options['title'] = ($result_options['title'] ?? '') . ' ' . i18n(null, 'Shortcut Key: ') . $accesskey[2];
                 }
             } else {
                 if (in_array($element_method, ['html::div', 'html::span'])) {
                     if (!empty($result_options['i18n'])) {
                         $result_options['value'] = i18n($result_options['i18n'] ?? null, $result_options['value'] ?? null);
                         $flag_translated = true;
                     }
                 } else {
                     // editable fields
                     $result_options['value'] = $value;
                     // if we need to empty value, mostly for password fields
                     if (!empty($result_options['empty_value'])) {
                         $result_options['value'] = '';
                     }
                     // we need to empty zero integers and sequences, before format
                     if (($result_options['php_type'] ?? '') == 'integer' && ($result_options['type'] ?? '') != 'boolean' && ($result_options['domain'] ?? '') != 'counter' && 'counter' && empty($result_options['value'])) {
                         $result_options['value'] = '';
                     }
                     // format, not for selects/autocompletes/presets
                     if (!$flag_select_or_autocomplete) {
                         if (!empty($result_options['format'])) {
                             if (!empty($this->errors['fields'][$result_options['error_name']]) && empty($this->errors['formats'][$result_options['error_name']])) {
                                 // nothing
                             } else {
                                 $result_options['format_options'] = $result_options['format_options'] ?? [];
                                 if (!empty($result_options['format_depends'])) {
                                     $this->process_params_and_depends($result_options['format_depends'], $neighbouring_values, $options, true);
                                     $result_options['format_options'] = array_merge_hard($result_options['format_options'], $result_options['format_depends']);
                                 }
                                 $method = factory::method($result_options['format'], 'format');
                                 $result_options['value'] = call_user_func_array([$method[0], $method[1]], [$result_options['value'], $result_options['format_options']]);
                             }
                         }
                     }
                     // align
                     if (!empty($result_options['align'])) {
                         $result_options['style'] = ($result_options['style'] ?? '') . 'text-align:' . $result_options['align'] . ';';
                     }
                     // processing persistent
                     if (!empty($result_options['persistent']) && $this->values_loaded) {
                         if ($result_options['persistent'] === 'if_set') {
                             $original_value = $detail = array_key_get($this->original_values, $result_options['values_key']);
                             if (!empty($original_value)) {
                                 $result_options['readonly'] = true;
                             }
                         } else {
                             if (count($result_options['values_key']) == 1) {
                                 // parent record
                                 $result_options['readonly'] = true;
                             } else {
                                 if (empty($result_options['__new_row'])) {
                                     // details
                                     $temp = $result_options['values_key'];
                                     array_pop($temp);
                                     $detail = array_key_get($this->original_values, $temp);
                                     if (!empty($detail)) {
                                         $result_options['readonly'] = true;
                                     }
                                 }
                             }
                         }
                     }
                     // maxlength
                     if (in_array($result_options['type'] ?? '', ['char', 'varchar']) && !empty($result_options['length'])) {
                         $result_options['maxlength'] = $result_options['length'];
                     }
                     // global readonly
                     if (!empty($this->misc_settings['global']['readonly']) && empty($result_options['navigation'])) {
                         $result_options['readonly'] = true;
                     }
                     // title
                     if (isset($options['options']['label_name'])) {
                         $result_options['title'] = ($result_options['title'] ?? '') . ' ' . strip_tags(i18n(null, $options['options']['label_name']));
                     }
                 }
             }
             // translate place holder
             if (array_key_exists('placeholder', $result_options)) {
                 if (!empty($result_options['placeholder'])) {
                     $result_options['placeholder'] = strip_tags(i18n(null, $result_options['placeholder']));
                 }
             } else {
                 if (!empty($result_options['validator_method']) && empty($result_options['value'])) {
                     $temp = object_validator_base::method($result_options['validator_method'], $result_options['value'], $result_options['validator_params'] ?? [], $options['options'], $neighbouring_values);
                     if ($flag_select_or_autocomplete) {
                         $placeholder = $temp['placeholder_select'];
                     } else {
                         $placeholder = $temp['placeholder'];
                     }
                     if (!empty($placeholder)) {
                         $result_options['placeholder'] = strip_tags(i18n(null, $placeholder));
                     }
                 }
             }
             // events
             foreach (numbers_frontend_html_class_html5::$events as $e) {
                 if (!empty($result_options['readonly'])) {
                     // important - readonly emenets cannot have events
                     unset($result_options[$e]);
                 } else {
                     if (!empty($result_options[$e])) {
                         $result_options[$e] = str_replace('this.form.submit();', 'numbers.form.trigger_submit(this);', $result_options[$e]);
                         $result_options[$e] = str_replace('this.form.extended.', $this->misc_settings['extended_js_class'] . '.', $result_options[$e]);
                     }
                 }
             }
             break;
         case 'html':
             $element_method = null;
             break;
         default:
             throw new Exception('Render detail type: ' . $data['fm_part_type']);
     }
     // handling html_method
     if (isset($element_method)) {
         $method = factory::method($element_method, 'html');
         $field_method_object = factory::model($method[0], true);
         // todo: unset non html attributes
         $value = $field_method_object->{$method[1]}($result_options);
         // building navigation
         if (!empty($result_options['navigation'])) {
             $name = 'navigation[' . $result_options['name'] . ']';
             $temp = '<table width="100%" dir="ltr">';
             // always left to right
             $temp .= '<tr>';
             $temp .= '<td width="1%">' . html::button2(['name' => $name . '[first]', 'value' => html::icon(['type' => 'step-backward']), 'onclick' => 'numbers.form.trigger_submit_on_button(this);', 'title' => i18n(null, 'First')]) . '</td>';
             $temp .= '<td width="1%">&nbsp;</td>';
             $temp .= '<td width="1%">' . html::button2(['name' => $name . '[previous]', 'value' => html::icon(['type' => 'caret-left']), 'onclick' => 'numbers.form.trigger_submit_on_button(this);', 'title' => i18n(null, 'Previous')]) . '</td>';
             $temp .= '<td width="1%">&nbsp;</td>';
             $temp .= '<td width="90%">' . $value . '</td>';
             $temp .= '<td width="1%">&nbsp;</td>';
             $temp .= '<td width="1%">' . html::button2(['name' => $name . '[refresh]', 'value' => html::icon(['type' => 'refresh']), 'onclick' => 'numbers.form.trigger_submit_on_button(this);', 'title' => i18n(null, 'Refresh')]) . '</td>';
             $temp .= '<td width="1%">&nbsp;</td>';
             $temp .= '<td width="1%">' . html::button2(['name' => $name . '[next]', 'value' => html::icon(['type' => 'caret-right']), 'onclick' => 'numbers.form.trigger_submit_on_button(this);', 'title' => i18n(null, 'Next')]) . '</td>';
             $temp .= '<td width="1%">&nbsp;</td>';
             $temp .= '<td width="1%">' . html::button2(['name' => $name . '[last]', 'value' => html::icon(['type' => 'step-forward']), 'onclick' => 'numbers.form.trigger_submit_on_button(this);', 'title' => i18n(null, 'Last')]) . '</td>';
             $temp .= '</tr>';
             $temp .= '</table>';
             $value = $temp;
         }
     }
     // html suffix and prefix
     if (!empty($html_suffix)) {
         $value .= $html_suffix;
     }
     // if we need to display settings
     if (application::get('flag.numbers.frontend.html.form.show_field_settings')) {
         $id_original = $result_options['id'] . '__settings_original';
         $id_modified = $result_options['id'] . '__settings_modified';
         $value .= html::a(['href' => 'javascript:void(0);', 'onclick' => "\$('#{$id_original}').toggle();", 'value' => html::label2(['type' => 'primary', 'value' => count($options['options'])])]);
         $value .= html::a(['href' => 'javascript:void(0);', 'onclick' => "\$('#{$id_modified}').toggle();", 'value' => html::label2(['type' => 'warning', 'value' => count($result_options)])]);
         $value .= '<div id="' . $id_original . '" style="display:none; position: absolute; text-align: left; width: 500px; z-index: 32000;">' . print_r2($options['options'], true) . '</div>';
         $value .= '<div id="' . $id_modified . '" style="display:none; position: absolute; text-align: left; width: 500px; z-index: 32000;">' . print_r2($result_options, true) . '</div>';
     }
     // we need to put original options back
     if (!empty($options['options']['custom_renderer'])) {
         $options = $options_custom_renderer;
     }
     return $value;
 }
Example #19
-4
 function index()
 {
     ob_start();
     $data = DB::select('SELECT * FROM countries LIMIT 2');
     print_r2($data);
     $select_text = ob_get_contents();
     ob_end_clean();
     //insert
     $inserted = DB::insert('INSERT INTO test (a,b) VALUES(?,?)', array(1, 2));
     $insert_text = 'inserted: ' . $inserted . '<br>';
     //update
     $affected = DB::update('UPDATE test SET b=? WHERE a=?', array(55, 1));
     $update_text = 'update affected: ' . $affected . '<br>';
     //delete
     $affected = DB::delete('DELETE test WHERE a=?', array(999));
     $delete_text = 'delete affected: ' . $affected . '<br>';
     //show tables
     ob_start();
     $data = DB::select('SHOW TABLES');
     print_r2($data);
     $show_tables_text = ob_get_contents();
     ob_end_clean();
     //use pdo object
     //
     $pdo = DB::getPdo();
     $sql = 'SELECT * FROM language LIMIT 2';
     $query = $pdo->query($sql);
     ob_start();
     while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
         print_r($row);
     }
     $pdo_text = ob_get_contents();
     ob_end_clean();
     // ---------------
     $texts = array();
     $texts['select_text'] = $select_text;
     $texts['insert_text'] = $insert_text;
     $texts['update_text'] = $update_text;
     $texts['delete_text'] = $delete_text;
     $texts['show_tables_text'] = $show_tables_text;
     $texts['pdo_text'] = $pdo_text;
     return View::make('database', $texts);
 }