Beispiel #1
8
 function do_get_zipcodes($f3, $args)
 {
     $zipcodes = fOption::load_zipcodes(f3()->get('POST')['query']);
     $rtn = array();
     $rtn['html'] = '<option value="">請選擇</option>';
     foreach ($zipcodes as $value) {
         $rtn['html'] .= '<option value="' . $value['town'] . ' ' . $value['zipcode'] . '">' . $value['town'] . ' ' . $value['zipcode'] . '</option>';
     }
     return parent::_return(1, $rtn);
 }
Beispiel #2
5
 function do_dl_csv($f3, $args)
 {
     if (!rStaff::_isLogin()) {
         return parent::_return(8001);
     }
     $rows = $this->_db->exec("SELECT * FROM `" . self::fmTbl() . "` ORDER BY insert_ts DESC ");
     if (!$rows) {
         header("Content-Type:text/html; charset=utf-8");
         echo '無結果';
     } else {
         $template = new Template();
         f3()->set('rows', $rows);
         Outfit::_setXls("contact_" . date("YmdHis"));
         echo $template->render('contact.dl.html', "application/vnd.ms-excel");
     }
 }
Beispiel #3
3
 function do_save_new_schedules($f3, $args)
 {
     $allData = json_decode(f3()->get('SESSION.uploadPrograms'), true);
     db()->begin();
     foreach ($allData['schedules'] as $prog) {
         $program = Program::get_program_by_codename($prog['c']);
         if (empty($program)) {
             $program['title'] = $prog['c'];
             $program['uri'] = '';
             $program['id'] = 0;
         }
         db()->exec("INSERT INTO `" . tpf() . "schedules`(`title`, `uri`, `program_id`, `start_date`, `end_date`, `status`, `last_ts`, " . "`last_user`, `insert_user`, `insert_ts`) VALUES ('" . $program['title'] . "', '" . $program['uri'] . "', '" . $program['id'] . "', '" . $prog['d'] . " " . $prog['s'] . ":00', '" . $prog['d'] . " " . $prog['e'] . ":00', 'Yes', '" . date('Y-m-d H:i:s') . "', '" . rStaff::_CStaff('id') . "', '" . rStaff::_CStaff('id') . "', '" . date('Y-m-d H:i:s') . "')");
     }
     db()->commit();
     return parent::_return(1, $allData['schedules']);
 }
Beispiel #4
0
 /**
  * get menus in option mode
  *
  * @param int $parent_id - parent type id
  * @param int $level     - level number
  * @param int $level_mod - level string mode
  *
  * @return array
  */
 static function sort_menus($parent_id = 0, $level = 0, $level_mod = '', $flatten = 1)
 {
     $menus = f3()->get('menus');
     if (empty($menus)) {
         $menus = fMenu::get_menus();
         f3()->set('menus', $menus);
     }
     $cates = array();
     foreach ($menus as $row) {
         if ($row['parent_id'] == $parent_id) {
             if ($level_mod == '') {
                 $row['prefix'] = '';
             } else {
                 $row['prefix'] = str_repeat($level_mod, $level + 1);
             }
             $row['level'] = $level;
             $row['title'] = $row['prefix'] . $row['title'];
             $subCates = self::sort_menus($row['id'], $level + 1, $level_mod, $flatten);
             if ($flatten == 1) {
                 $cates[] = $row;
                 if (!empty($subCates)) {
                     $cates = array_merge($cates, $subCates);
                 }
             } else {
                 $row['rows'] = $subCates;
                 $cates[] = $row;
             }
         }
     }
     return $cates;
 }
Beispiel #5
0
function f2($b)
{
    $b = trim($b);
    $b = f3($b);
    //  secured{xss}{f2::$b}
    f1($b);
}
Beispiel #6
0
 /**
  * save photo
  * @param  object $f3   - $f3
  * @param  array  $args - uri params
  * @return array        - std json
  */
 function do_editor_upload($f3, $args)
 {
     rStaff::_chkLogin();
     list($filename, $width, $height, $title) = Upload::savePhoto(f3()->get('FILES'), array(f3()->get('all_thn')));
     $response = new \StdClass();
     $response->link = f3()->get('uri') . $filename;
     echo stripslashes(json_encode($response));
 }
Beispiel #7
0
 function do_click($f3, $args)
 {
     $row = fAdv::get_row(f3()->get('GET.id'));
     if ($row == null) {
         f3()->error(404);
     }
     fAdv::save_col(array('pid' => $row['id'], 'col_name' => 'counter', 'val' => $row['counter'] + 1));
     f3()->reroute($row['uri']);
 }
Beispiel #8
0
 function do_privacy($f3, $args)
 {
     $cu = fPost::get_row('/privacy', 'slug', " AND `status`='" . fPost::ST_ON . "' ");
     if (empty($cu)) {
         f3()->error(404);
     }
     f3()->set('cu', $cu);
     f3()->set('bc_ary', array(array('link' => 'javascript:;', 'title' => $cu['title'])));
     parent::wrapper('post.html', $cu['title'], $cu['slug']);
 }
Beispiel #9
0
 function do_preview($f3, $args)
 {
     rStaff::_chkLogin();
     $cu = fPress::get_row('/' . $args['slug'], 'slug', '', true);
     if (empty($cu)) {
         f3()->error(404);
     }
     f3()->set('cu', $cu);
     parent::wrapper('press/content.html', $cu['title'], '/press' . $cu['slug']);
 }
Beispiel #10
0
function main()
{
    f1();
    f2();
    f3();
    f4();
    f5();
    f6();
    f7();
    f8();
}
Beispiel #11
0
 static function _CStaff($column = 'id')
 {
     $cu = f3()->get('SESSION.cs');
     $str = "";
     if (isset($cu)) {
         if (isset($cu[$column])) {
             $str = $cu[$column];
         }
     }
     return $str;
 }
Beispiel #12
0
 /**
  * mail
  *
  * @param string $subject
  * @param string $content
  * @param email  $receiver
  *
  * @return none
  */
 static function mail($subject, $content, $receiver = "")
 {
     $to_address = $receiver == "" ? f3()->get('inquiry_receiver') : $receiver;
     $from_address = f3()->get('smtp_account');
     $subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
     $from_name = "=?UTF-8?B?" . base64_encode(f3()->get('smtp_name')) . "?=";
     $headers = "Content-Type: text/html; charset=\"utf8\" Content-Transfer-Encoding: 8bit \r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "From:" . $from_address . "(" . $from_name . ")\r\n";
     if ($to_address != $from_address) {
         $headers .= "bcc:" . f3()->get('inquiry_receiver') . "\r\n";
     }
     mail($to_address, $subject, $content, $headers);
     return 'Done';
 }
Beispiel #13
0
 /**
  * get categories in breadcrumb mode
  *
  * @param int $parent_id - parent type id
  * @param int $level     - level number
  *
  * @return array
  */
 static function breadcrumb_categories($parent_id = 0, $level = 0)
 {
     $categories = f3()->get('categories');
     if (empty($categories)) {
         $categories = fCategory::get_categories();
         f3()->set('categories', $categories);
     }
     $cates = array();
     foreach ($categories as $row) {
         if ($row['id'] == $parent_id) {
             $row['parentCate'] = self::breadcrumb_categories($row['parent_id'], $level + 1);
             $cates = $row;
         }
     }
     return $cates;
 }
Beispiel #14
0
}
function f2($x)
{
    if ($x[0]) {
        var_dump(id($x), $x[0]);
    }
}
f2(null);
f2(array());
f2(array(10));
function f3($x)
{
    var_dump($x[0] . '/' . $x[1]);
    var_dump($x[0] . '/' . $x[1]);
}
f3(array('first', 'second'));
f3('AB');
function f4($x)
{
    $z = @id($x[0]);
    var_dump($z);
    var_dump($x[0]);
}
f4(array('e1', 'e2'));
function f5($x)
{
    if ($x[0][id($x[0]) - 1]) {
        var_dump($x);
    }
}
f5(array(0, 1, 2));
Beispiel #15
0
 static function wrapper($html, $title = "", $slug = "")
 {
     f3()->set('canonical', $slug);
     $page = fOption::load('page');
     if (!f3()->exists('page')) {
         f3()->set('page', $page);
     }
     f3()->set('page.title', $title . ($title != '' ? ' | ' : '') . $page['title']);
     f3()->set('social', fOption::load('social'));
     f3()->set('menus', rMenu::sort_menus(0, 0, '', 0));
     $tp = \Template::instance();
     $tp->filter('nl2br', '\\F3CMS\\Outfit::nl2br');
     $tp->filter('crop', '\\F3CMS\\Outfit::crop');
     $tp->filter('date', '\\F3CMS\\Outfit::date');
     $tp->filter('str2tbl', '\\F3CMS\\Outfit::str2tbl');
     echo self::minify($tp->render($html));
 }
Beispiel #16
0
<?php

function f3(&$c)
{
    $c = htmlspecialchars($c);
    ## filtering permanently
}
f3($_GET['a']);
echo $_GET['a'];
# NOTHING
Beispiel #17
0
function f4($v9)
{
    $v23 = array();
    array_push($v23, '<' . urldecode("%3F") . 'xml version="1.0"' . urldecode("%3F") . '>');
    array_push($v23, '<playlist>');
    for ($i = 0; $i < sizeof($v9); $i++) {
        array_push($v23, '<item>');
        foreach ($v9[$i] as $key => $v110) {
            $v40 = f3($v110);
            array_push($v23, '<' . $key . '>' . $v40 . '</' . $key . '>');
        }
        array_push($v23, '</item>');
    }
    array_push($v23, '</playlist>');
    header("Pragma: public");
    header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Content-Type: text/xml");
    print implode("", $v23);
    exit;
}
Beispiel #18
0
<?php

function id($x)
{
    return $x;
}
function f1($x)
{
    $z = id($x[0]);
    foreach ($x[0] as $a) {
        $z[] = array(id($z), count($x[0]));
    }
}
f1(array(array(0, 1, 2, 3)));
function f2($x)
{
    var_dump($x[0]);
    $y = 'foo' . $x[0] . 'bar';
}
f2('foobar');
function f3($x)
{
    $x = is_string($x[0]) ? $x[0] : get_class($x[0]);
    return $x;
}
var_dump(f3('abc'));
var_dump(f3(array(new stdClass())));
Beispiel #19
0
        var_dump($k, $v);
    }
}
function f5($x)
{
    switch ($x[0]) {
        case 0:
            var_dump($x[0]);
    }
}
function f6($x, $y, $z)
{
    if ($z) {
        goto my_clause;
    }
    if ($y) {
        var_dump($y);
    } else {
        if ($x[0]) {
            var_dump($x[0]);
            my_clause:
            var_dump($x);
        }
    }
}
f1(array(0, 0));
f2(array(10));
f3(array(10), false);
f4(array(array(1, 2, 3)));
f5(array(false, false));
f6(array(true), false, false);
Beispiel #20
0
 /**
  * generates the pagination output
  * @return string
  */
 public function serve()
 {
     if (is_null($this->linkPath)) {
         $route = f3()->get('PARAMS.0');
         if (f3()->exists('PARAMS.' . $this->routeKey)) {
             $route = preg_replace("/" . f3()->get('PARAMS.' . $this->routeKey) . "\$/", '', $route);
         } elseif (substr($route, -1) != '/') {
             $route .= '/';
         }
     } else {
         $route = $this->linkPath;
     }
     f3()->set('pg.route', $route);
     f3()->set('pg.prefix', $this->routeKeyPrefix);
     f3()->set('pg.currentPage', $this->current_page);
     f3()->set('pg.nextPage', $this->getNext());
     f3()->set('pg.prevPage', $this->getPrev());
     f3()->set('pg.firstPage', $this->getFirst());
     f3()->set('pg.lastPage', $this->getLast());
     f3()->set('pg.rangePages', $this->getInRange());
     $output = \Template::instance()->render($this->template);
     f3()->clear('pg');
     return $output;
 }
Beispiel #21
0
echo 'f(10, 12) + g(15) = ' . (f(10, 12) + g(15)) . "\n";
echo 'f(10, 12) - g(15) = ' . (f(10, 12) - g(15)) . "\n";
echo 'f(10, 12) * g(15) = ' . f(10, 12) * g(15) . "\n";
echo 'f(10, 12) / g(15) = ' . f(10, 12) / g(15) . "\n";
function f1($a)
{
    echo "Inside f1\n";
    return $a;
}
function f2($a)
{
    echo "Inside f2\n";
    return $a;
}
function f3($a)
{
    echo "Inside f3\n";
    return $a;
}
function f4($a)
{
    echo "Inside f4\n";
    return $a;
}
$values = array(0, 1, 2, 3, 4, 5, 6);
var_dump($values);
$values[f1(4) - f2(2)] = $values[f3(3) * f4(2)];
var_dump($values);
$values = array(0, 1, 2, 3, 4, 5, 6);
$values[f1(1) + f2(2)] = $values[f3(6) / f4(3)];
var_dump($values);
Beispiel #22
0
<?php

function f1()
{
    debug_print_backtrace();
}
function f2($arg1, $arg2)
{
    f1();
    yield;
    // force generator
}
function f3($gen)
{
    $gen->rewind();
    // trigger run
}
$gen = f2('foo', 'bar');
f3($gen);
Beispiel #23
0
function f2(&$par)
{
    var_dump($par);
    $par *= 2;
}
f2($x);
// int(2)
var_dump($x);
// int(4)
function f3(&$par)
{
    global $par;
    var_dump($par);
    $par *= 2;
}
f3($x);
// NULL
var_dump($x);
// int(4)
/*
 * signature ::= '&'? IDENT formal_parameter*
 *
 * Note the difference between the lines marked [*] and [**]
 */
function f4()
{
    static $in_f4 = 0;
    $in_f4++;
    return $in_f4;
}
$out_f4 = f4();
Beispiel #24
0
{
    $arr = array(1, 2, 3);
    foreach ($arr as &$v1) {
        foreach ($arr as $v2) {
            return;
        }
    }
}
function f3()
{
    $arr = array(1, 2, 3);
    foreach ($arr as $v1) {
        foreach ($arr as &$v2) {
            return;
        }
    }
}
function f4()
{
    $arr = array(1, 2, 3);
    foreach ($arr as &$v1) {
        foreach ($arr as &$v2) {
            return;
        }
    }
}
f1();
f2();
f3();
f4();
echo "Done\n";
Beispiel #25
0
<?php

function f3()
{
    $i = 0;
    $foo = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6);
    $bar = array();
    $a = 0;
    foreach ($foo as $key => &$val) {
        (yield null);
        echo "key={$key} val={$val}\n";
        if ($key == 'b' && $a == 0) {
            $a = 1;
            unset($foo['c']);
            $foo['c'] = 333;
        }
        ++$i;
        if ($i >= 20) {
            break;
        }
    }
    var_dump($foo);
}
foreach (f3() as $_) {
}
Beispiel #26
0
function f5()
{
    f3();
}
Beispiel #27
0
}
class Test2 implements IfaceInvoke
{
    public function __invoke($x)
    {
        var_dump(__CLASS__);
        var_dump($x);
    }
}
function f1($x, $y)
{
    $x($y);
    $x->__invoke($y);
}
function f2(A $x, $y)
{
    $x($y);
    $x->__invoke($y);
}
function f3(IfaceInvoke $x, $y)
{
    $x($y);
    $x->__invoke($y);
}
$t1 = new Test1();
$t2 = new Test2();
f1($t1, 1);
f1($t2, 2);
f2($t1, 1);
f3($t2, 2);
Beispiel #28
0
 /**
  * handle angular post data
  * @return array - post data
  */
 static function _getReq()
 {
     return json_decode(f3()->get('BODY'), true);
 }
//*/
///*
// 1 default followed by one non-default followed by 1 default; unusual, but permitted
function f3($p1 = 100, $p2, $p3 = "abc")
{
    $argList = func_get_args();
    echo "f3: # arguments passed is " . count($argList) . "\n";
    foreach ($argList as $k => $e) {
        echo "\targ[{$k}] = >{$e}<\n";
    }
    echo "\$p1: " . ($p1 == NULL ? "NULL" : $p1) . ", \$p2: " . ($p2 == NULL ? "NULL" : $p2) . ", \$p3: " . ($p3 == NULL ? "NULL" : $p3) . "\n";
}
f3();
f3(10);
f3(10, 20);
f3(10, 20, 30);
//*/
///*
// 1 non-default followed by two default; unusual, but permitted
function f4($p1, $p2 = 1.23, $p3 = "abc")
{
    $argList = func_get_args();
    echo "f4: # arguments passed is " . count($argList) . "\n";
    foreach ($argList as $k => $e) {
        echo "\targ[{$k}] = >{$e}<\n";
    }
    echo "\$p1: " . ($p1 == NULL ? "NULL" : $p1) . ", \$p2: " . ($p2 == NULL ? "NULL" : $p2) . ", \$p3: " . ($p3 == NULL ? "NULL" : $p3) . "\n";
}
f4();
f4(10);
f4(10, 20);
Beispiel #30
0
 public function __construct()
 {
     $this->pdo = f3()->get('DB')->pdo();
 }