Пример #1
0
 public function run()
 {
     header('Access-Control-Allow-Origin: *');
     date_default_timezone_set('Asia/Seoul');
     user()->login();
     if ($model = http_input('model')) {
         list($model_name, $class_name, $method_name) = explode('.', $model);
         $uc_first_class_name = ucfirst($class_name);
         $namespace = "of\\{$model_name}\\{$uc_first_class_name}";
         $obj = new $namespace();
         return $obj->{$method_name}();
     }
     switch ($doing = http_input('do')) {
         default:
             if (strpos($doing, '.')) {
                 $doing = str_replace('.', '\\', $doing);
             } else {
                 $doing = ucfirst($doing);
             }
             $name = "of\\{$doing}";
             $obj = new $name();
             $obj->runAjax();
             json_error(-40444, "Nothing to do");
             return null;
     }
 }
Пример #2
0
 public function runAjax()
 {
     $in = http_input();
     $table = $in['table'];
     $in['rows'] = $this->db->rows("SELECT * FROM  {$table}");
     json_success($in);
 }
Пример #3
0
 /**
  * 로그인 과정을 진행한다.
  *
  * 입력 정보는 HTTP input 의 idx_member 와 session_id 로 들어오며,
  * 회원 정보를 $sys->member 에 저장하고,
  * 회원 번호를 리턴한다.
  *
  * 이것은 module/ajax/DataLayer.php 의 회원 로그인과 비슷하며,
  *
  * ajax 의 model=.... 와 같이 호출하는 경우, overframe/ajax/Ajax.php 의 run() 에 의해서 호출된다.
  *
  * @return mixed 회원번호 또는 ajax 에러 메세지.
  */
 public function login()
 {
     global $sys;
     $in = http_input();
     $in['remember'] = 'Y';
     sys()->log(" =========> UserLayer::login() in: ");
     if (empty($in['idx_member'])) {
         return FALSE;
     }
     if (isset($in['idx_member']) && $in['idx_member'] && isset($in['session_id'])) {
         $member = $sys->member->get($in['idx_member']);
         if (empty($member)) {
             json_error(-508, "User not found. Wrong idx_member.");
         }
         if ($this->session_id($member) != $in['session_id']) {
             json_error(-507, "Wrong user session id. Your IP and location information has been reported to admin.");
         }
     } else {
         sys()->log(" =====> No. login. in[idx_member] and in[action] is not member_register_submit,  in[id], in[password] is empty. ");
         return FALSE;
     }
     $sys->member->idx = $member['idx'];
     $sys->member->info = $member;
     return $sys->member->idx;
 }
Пример #4
0
 public function runAjax()
 {
     switch ($doing = http_input('what')) {
         case 'file-upload':
             return data()->ajaxFileUpload();
         case 'file-delete':
             return data()->ajaxFileDelete();
         case 'file-finish':
             return data()->ajaxFileFinish();
         default:
             json_error(-40445, 'No what to do');
             return null;
     }
 }
Пример #5
0
 /**
  *
  *
  * @note HTTP 입력 변수로 condition 값이 들어오며 적절한 처리를 하여 JSON 으로 리턴한다.
  *
  * 내부적으로는 Entity::search() 를 사용하므로 where, limit, offset, page, order_by, fields 의 값을 그대로 사용 할 수 있다.
  *
  *
  *  &entity=데이터베이스 테이블
  *  &where=의 값은 entity->search() 의 where SQL 컨디션과 동일
  *  &order_by=SQL ORDER BY 컨디션
  *  &limit=, &offset=, &page= 의 값은 entity::search() 의 것과 동일
  *
  * @return JSON 내부의 동작은 entity::search() 의 것과 동일하지만, 결과는 JSON 으로 리턴한다.
  *
  * @code 쿼리 예제
  * http://philgo.org/?module=overframe&action=index&model=entity.crud.collect&entity=data&order_by=id%20ASC&fields=id,finish,name&where=id%3E3&limit=3
  * @endcode
  */
 public function collect()
 {
     $in = http_input();
     $o['fields'] = isset($in['fields']) ? $in['fields'] : '*';
     $o['where'] = isset($in['where']) ? $in['where'] : null;
     $o['order_by'] = isset($in['order_by']) ? $in['order_by'] : 'id DESC';
     $o['limit'] = isset($in['limit']) ? $in['limit'] : 10;
     $o['page'] = isset($in['page']) ? $in['page'] : 1;
     $o['offset'] = isset($in['offset']) ? $in['offset'] : 0;
     $entity_name = $in['entity'];
     $node = node($entity_name);
     $entities = $node->search($o);
     $data = array();
     foreach ($entities as $e) {
         $data[] = $e->getRecord();
     }
     json_success($data);
 }
Пример #6
0
/**
* 내부적으로 캐시를 하므로 반복적으로 사용을 해도 빠르게 처리를 한다.
*
* @note alias of http_input
*
* @param null $name
* @param null $default
* @return mixed
* @code
       if ( hi('route') ) {
           route()->run( hi('route'), hi() );
       }
* @endcode
*/
function hi($name = null, $default = null)
{
    return http_input($name, $default);
}
Пример #7
0
<?php

use core\model\system\System;
sys()->log('core/model/system/init.php with URL : ' . url_full());
if (is_post()) {
    sys()->log(http_input());
}
Пример #8
0
function json_success($data)
{
    $in = http_input();
    $out = array('code' => 0, 'system' => sys()->find());
    if (isset($in['do'])) {
        $out['do'] = $in['do'];
    } else {
        if (isset($in['model'])) {
            $out['model'] = $in['model'];
        }
    }
    $out['data'] = $data;
    echo json_encode($out);
    exit;
}
Пример #9
0
<?php

$in = http_input();
if (isset($in['name'])) {
    include_once DIR_OVERFRAME . "/model/{$in['name']}/install.php";
    $func = "hook_{$in['name']}_{$in['do']}";
    $func();
}
echo "<table width='100%'>";
echo "<tr><th>Name</th><th>status</th><th>Action</th></tr>";
foreach (sys()->getModels() as $name) {
    $path = DIR_OVERFRAME . "/model/{$name}/install.php";
    $status = '-';
    $action = '-';
    if (file_exists($path)) {
        include_once $path;
        $is_installed = "hook_{$name}_is_installed";
        $install = "hook_{$name}_install";
        $uninstall = "hook_{$name}_uninstall";
        if (function_exists($is_installed)) {
            $re = $is_installed();
            $url = url_action();
            if ($re) {
                $status = 'installed';
                $action = "<a href='{$url}&do=uninstall&name={$name}' onclick='return confirm(\"Are you sure you want to delete {$name} entity and its records?\");'>Un-Install</a>";
            } else {
                $status = 'not installed';
                $action = "<a href='{$url}&do=install&name={$name}'>Install</a>";
            }
        }
    }
Пример #10
0
 private function ajaxDelete()
 {
     $id = http_input('id', 0);
     if ($id) {
         $banner = $this->load($id);
         if ($banner) {
             $fid = $banner->get('fid');
             if ($fid) {
                 $data = data($fid);
                 if ($data) {
                     $data->delete();
                 }
             }
             $banner->delete();
             json_success(array('id' => $id));
         } else {
             json_error(-1235, 'No banner by that id');
         }
     } else {
         json_error(-1234, 'No id provided');
     }
 }
Пример #11
0
            <?php 
if (isLocalhost() || banner()->hasAccess()) {
    ?>
                <a class="btn btn-secondary" href="<?php 
    echo $url;
    ?>
&do=philgo-banner">배너</a>
            <?php 
}
?>

    </nav>

    <div class="of-content jumbotron">
        <?php 
switch (http_input('do')) {
    case 'test':
        return run_test();
    case 'model-list':
    case 'install':
    case 'uninstall':
        include sys()->template('model-list');
        return;
    case 'entity-list':
        include sys()->template('entity-list');
        return;
    case 'file-upload-test':
        include sys()->template('file-upload-test');
        return;
    case 'philgo-banner':
        return include sys()->template('philgo-banner');
Пример #12
0
<style>
    .jumbotron {
        border-radius: 0!important;
    }
</style>

<div class="of-page">
<a class="btn btn-secondary" href="<?php 
echo url_action();
?>
&do=philgo-banner&what=list">배너 목록</a> |
<a class="btn btn-secondary" href="<?php 
echo url_action();
?>
&do=philgo-banner&what=upload">배너 등록</a>
</div>


<?php 
$what = http_input('what', 'list');
if ($what) {
    include $what . '.php';
}
?>

Пример #13
0
 public function __construct()
 {
     parent::__construct();
     $this->setTableName('data');
     $this->in = http_input();
 }