function show_form()
{
    $genders = $GLOBALS['config']['gender'];
    $name = _req('name');
    $gender = _req('gender');
    $description = _req('description');
    render_view('master', compact('genders', 'name', 'gender', 'description'));
}
function show_form()
{
    $name = _req('name');
    $teacher = _req('teacher');
    $description = _req('description');
    $teachers = Teacher::search()->find(Searcher::KEY_VALUE_PAIR);
    render_view('master', compact('teachers', 'name', 'teacher', 'description'));
}
Exemple #3
0
function login_end()
{
    // if user is already logged in,
    // to index since we didn't provide such a link
    if ($GLOBALS['has_login']) {
        redirect();
        // to index
    }
    $username = _req('username');
    render_view('master', array('msg' => $GLOBALS['msg'], 'username' => $username));
}
Exemple #4
0
/**
 * @author  ryan <*****@*****.**>
 */
function init_var()
{
    $req_uri = i($_SERVER['REDIRECT_URL'], reset(explode('?', $_SERVER['REQUEST_URI'])));
    $arr = explode('/', trim($req_uri, '/'));
    // c is controller
    // a is action
    $GLOBALS['controller'] = i($arr[0]) ?: 'index';
    $GLOBALS['action'] = _req('a') ?: _req('action');
    $GLOBALS['target'] = i($arr[1]) ?: _req('target');
    $GLOBALS['argument'] = i($arr[2]);
    // we should use function here
    $GLOBALS['by_ajax'] = i($_REQUEST['is_ajax']) || strtolower(i($_SERVER['HTTP_X_REQUESTED_WITH'])) == strtolower('XMLHttpRequest');
    $GLOBALS['by_post'] = strtolower(i($_SERVER['REQUEST_METHOD'])) == 'post';
    $GLOBALS['page'] = array('title' => $GLOBALS['config']['site']['name'], 'head' => array(), 'scripts' => array(), 'styles' => array(), 'append_divs' => array());
    // 关于这个页面的变量
}
Exemple #5
0
/**
 * @author  ryan <*****@*****.**>
 */
function attitude($type)
{
    if (!$GLOBALS['has_login']) {
        return;
    }
    $class = camel2under($type);
    $map = array('like' => 1, 'hate' => 0);
    $target = _req('target');
    $action = _req('action');
    $info = array($type => $target, 'user' => $GLOBALS['user'], '`like`' => $map[$action]);
    $at = Attitude::create($info);
    if ($at) {
        $info = array('user' => $GLOBALS['user'], 'action' => $action, 'object' => $target);
        $act = Activity::create($info);
        // inform author
        $comment = new $class($target);
        $info = array('user' => $comment->user, 'activity' => $act);
        Timeline::create($info);
    }
    $o = new $class($target);
    echo $o->{$action . 'Count'}();
}
Exemple #6
0
        }
        break;
}
if (is_numeric($target) && ($by_ajax || $by_post)) {
    $factory = new Factory($target);
}
if (is_numeric($target) && $by_ajax) {
    switch ($action) {
        case 'get_pay_div':
            $order_id = _req('order');
            $order = new Order($order_id);
            $view_name = 'factory.pay';
            include smart_view('append.div');
            exit;
        case 'get_account_records_div':
            $order_id = _req('order');
            $order = new Order($order_id);
            $records = $factory->accountRecords(array('order' => $order_id));
            include smart_view('factory.account.record');
            exit;
        case 'get_stone_recharge_div':
            $account = $factory->stAccount();
            $view_name = 'factory.stone.recharge';
            include smart_view('append.div');
            exit;
        default:
            throw new Exception("ajax not good action: {$action}");
            break;
    }
}
if (is_numeric($target) && $by_post) {
Exemple #7
0
/**
 * include dependencies
 */
include_once dirname(__FILE__) . '/includes/common/require.php';
_load_class('cpanel');
_load_class('mysql', 'cpanel');
_load_class('user', 'cpanel');
_load_class('ftp', 'cpanel');
_load_class('fileman', 'cpanel');
include_once dirname(__FILE__) . '/includes/backup.php';
include_once dirname(__FILE__) . '/includes/mail.php';
include_once dirname(__FILE__) . '/includes/wp.php';
require_once ROOT_DIR . '/includes/svn.php';
require_once ROOT_DIR . '/includes/ftp.php';
global $hooks, $DB;
/*$luser = _post('luser');
$lpass = _post('lpass');
//check user login
if(!login($luser, $lpass)) {
    exit('unAuthorize');

if($auth){
    #$cpanel = authorize_cpanel($acc_id);
}
}*/
$task = _get('do');
$params = array('auth' => _get('auth'), 'task' => _get('do'), 'json_format' => _get('json'));
//do ajax action
$hooks->do_action(get_ajax_task_name($task), new HW_CPanel_Utilities(_req('acc', 8), $params));
Exemple #8
0
function exec_sql()
{
    global $db;
    $sql = _req('sql');
    $errorInfo = null;
    if ($sql) {
        try {
            $count = $db->exec($sql);
        } catch (PdoException $e) {
            $errorInfo = $e->errorInfo;
        }
    }
    render(__DIR__ . '/view/exec.html', compact('sql', 'count', 'errorInfo'), LAYOUT);
}
Exemple #9
0
}
/**
 * echo json encode data
 * @copy /cpanel/includes/common.php
 * @param $data
 */
function ajax_output($data, $break_line = false)
{
    if (is_array($data)) {
        echo json_encode($data);
    } else {
        print_r($data);
    }
    if ($break_line) {
        echo '<hr/>';
    }
}
#------------------------------------
$task = _req('do');
/**
 * decode hash string
 */
if ($task == 'decpass') {
    echo decrypt(_req('str'));
} elseif ($task == 'dec_svn_pass') {
    $t = explode(PHP_EOL, _req('str'));
    #if failt try "\r\n"
    if (count($t) && trim($t[0]) == 'svn_pass') {
        echo decrypt(trim($t[1]));
    }
}
Exemple #10
0
<?php

ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/php_errors.log');
include 'xiaochi-db/src/DB.php';
include 'lib.php';
include 'actions.php';
include 'logic.php';
date_default_timezone_set('PRC');
$app_begin_time = microtime(true);
$config = get_config();
$dbname = _req('dbname');
if (empty($dbname)) {
    $dbname = key($config['dbnames']);
}
$conf = $config['dbnames'][$dbname];
$db = new xiaochi\DB($conf['dsn'], $conf['username'], $conf['password']);
$vk = plant_vk();
define('LAYOUT', __DIR__ . '/view/layout.html');
list($router, $args) = get_router();
run($router, $args);
 /**
  * decode hash string
  * @param $cp
  */
 function decpass($cp)
 {
     echo decrypt(_req('str'));
 }
Exemple #12
0
function reqs($name)
{
    return _req($name) . '';
}
Exemple #13
0
if ($user_type !== 'Customer') {
    exit('no permission');
}
if ($by_ajax) {
    switch ($action) {
        case 'add':
            $id = _req('id');
            $material = _req('material');
            $size = _req('size');
            $carve_text = _req('carveText');
            $customer->addProductToCart(new Product($id), compact('material', 'size', 'carve_text'));
            $cart = $customer->cart();
            echo $cart->count();
            exit;
        case 'del':
            $id = _req('id');
            $customer->delProductFromCart(new Order($id));
            echo $customer->cart()->count();
            exit;
        default:
            throw new Exception("nuknow action: {$action}");
            break;
    }
} else {
    $cart = $customer->cart();
    $orders = $cart->orders();
    $orders_count = count($orders);
    $addresses = $customer->addresses();
    if ($orders_count > 0) {
        $labor_expense = Setting::get('labor_expense');
        $wear_tear = Setting::get('wear_tear');
Exemple #14
0
/**
 * svn decode pass from svn-create-repo.sh
 * @param $cp
 */
function dec_svn_pass($cp)
{
    $t = explode("\r\n", _req('str'));
    if (count($t) && $t[0] == 'svn_pass') {
        echo decrypt($t[1]);
    }
}
Exemple #15
0
}
list($username, $password, $repassword, $realname, $phone, $email) = _post('username', 'password', 'repassword', 'realname', 'phone', 'email');
$msg = '';
if ($by_post) {
    $ERROR_INFO = $config['error']['info'];
    if (empty($password)) {
        $msg = $ERROR_INFO['PASSWORD_EMPTY'];
    } elseif (empty($repassword)) {
        $msg = $ERROR_INFO['REPASSWORD_EMPTY'];
    } elseif ($password !== $repassword) {
        $msg = $ERROR_INFO['PASSWORD_NOT_SAME'];
    } elseif (empty($username)) {
        $msg = $ERROR_INFO['USERNAME_EMPTY'];
    } elseif (User::find($username)) {
        $msg = $ERROR_INFO['USER_ALREADY_EXISTS'];
    } elseif (empty($realname)) {
        $msg = $ERROR_INFO['REALNAME_EMPTY'];
    } elseif (empty($phone)) {
        $msg = $ERROR_INFO['PHONE_EMPTY'];
    } elseif (empty($email)) {
        $msg = $ERROR_INFO['EMAIL_EMPTY'];
    } else {
        $customer = Customer::register(compact('username', 'password', 'realname', 'phone', 'email'));
        $user = $customer->user();
        $user->login();
        $back_url = _req('back_url') ?: DEFAULT_LOGIN_REDIRECT_URL;
        redirect($back_url);
    }
}
$view .= '?master';
$page['scripts'][] = 'jquery.validate.min';
Exemple #16
0
/**
 * del cron
 * @param $data
 */
function delcron($data)
{
    $cpanel_file = $data->get_instance('fileman1');
    //new HW_CPanel_Fileman($data->host, $data->cpaneluser, $data->cpaneluser_pass);
    $cpanel_file->delcron(_req('id'));
}