/** * @param $in * @return array * * @code * $ php index.php "route=user.Controller.register&username=abc&password=1234&email=abc@def.com" * @endcode * */ public function register($in) { if (!isset($in['username'])) { sys()->log("Username is empty."); return ERROR(-111, "Username is empty."); } if (!isset($in['password'])) { return ERROR(-1121, "Password is empty."); } if (!isset($in['email'])) { return ERROR(-113, "Email is empty."); } if (user_exists($in['username'])) { return ERROR(-121, "User: {$in['username']} exists."); } if (user_email_exists($in['email'])) { return ERROR(-121, "User email: {$in['email']} exists."); } $sets = array(); $sets['username'] = $in['username']; $sets['password'] = password_encrypt($in['password']); $sets['email'] = $in['email']; $sets['first_name'] = hi('first_name', ''); $sets['middle_name'] = hi('middle_name', ''); $sets['last_name'] = hi('last_name'); $sets['mobile'] = hi('mobile', ''); $sets['landline'] = hi('landline', ''); $sets['address'] = hi('address'); $re = user()->create()->sets($sets)->save(); if ($re) { return SUCCESS(); } else { return ERROR(-4, 'Failed on saving user information.'); } }
public function edit() { sys()->log("company\\Controller::edit()"); $company_name = hi('company_name'); $email = hi('email'); if (!login()) { return ERROR(-436, "Login first"); } if (empty($company_name)) { return ERROR(-437, "Input company name"); } if (empty($email)) { return ERROR(-439, "Input email"); } //$e = $this->load("company_name='$company_name'"); //if ( $e ) return ERROR( -438, "Company name exists."); //$e = $this->load("email='$email'"); //if ( $e ) return ERROR( -440, "Company email exists."); if (hi('id')) { $this->load(hi('id')); } else { $this->create()->set('username', login()->username)->set('gid', hi('gid')); } $entity = $this->set('category', hi('category', 0))->set('company_name', $company_name)->set('title', hi('title'))->set('ceo_name', hi('ceo_name'))->set('email', $email)->set('mobile', hi('mobile'))->set('landline', hi('landline'))->set('address', hi('address'))->set('kakao', hi('kakao'))->set('delivery', hi('delivery'))->set('region', hi('region'))->set('province', hi('province'))->set('city', hi('city'))->set('address', hi('address'))->set('homepage', hi('homepage'))->set('etc', hi('etc'))->set('content', hi('content'))->save(); if ($entity) { return SUCCESS(array('id' => $entity->id)); } else { return ERROR(-431, "Failed on creating/updating company information"); } }
/** * 해당 경로에 있는 클래스의 객체를 생성하고 메소드를 실행한다. * @param $path * @return array */ public function run($path, $in) { list($model, $class, $method) = explode('.', $path); if (sys()->isCoreModel($model)) { //response( array( 'code' => -2, 'message'=>'model does not exists.') ); $path = "core\\model\\{$model}\\{$class}"; $obj = new $path(); if (!method_exists($obj, $method)) { response(array('code' => -200, 'message' => "method {$method} - does not exists. in {$path}")); } $data = $obj->{$method}($in); if ($data) { response($data); } } else { if (sys()->isUserModel($model)) { $path = "model\\{$model}\\{$class}"; $obj = new $path(); if (!method_exists($obj, $method)) { response(array('code' => -201, 'message' => "method {$method} - does not exists. in {$path}")); } $data = $obj->{$method}($in); if ($data) { response($data); } } else { response(array('code' => -100, 'message' => 'model does not exists.')); } } }
public static function getModels() { $names = array(); foreach (sys()->getModelPaths() as $model) { $names[] = pathinfo($model, PATHINFO_BASENAME); } return $names; }
public function runAjax() { $in = http_input(); sys()->log('Philgo_banner:;runAjax()'); sys()->log($in); if ($in['what'] == 'upload') { $this->ajaxUpload(); } else { if ($in['what'] == 'delete') { $this->ajaxDelete(); } } }
<?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'); default: echo '<h1>No action</h1>'; } ?> </div> </div>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Condor</title> <?php o(include_stylesheet('app')); ?> <?php o(include_script('app')); ?> <style> body { background-color: blue; color: white; } a { color: white; } </style> </head> <body> <div id='content'> <?php echo sys()->flash->render(); ?> <?php echo sys()->content; ?> </div> </body> </html>
function sweet($params) { sys()->content = "URL Parameters for AppController#sweet ['{$params['arg']}', '{$params['arg2']}']"; }
<?php use core\model\system\System; sys()->log('core/model/system/init.php with URL : ' . url_full()); if (is_post()) { sys()->log(http_input()); }
public function __construct() { sys()->find(); $this->db = database(); }
public function getTables() { if (sys()->isCodeIgniter3()) { return $this->db->list_tables(); } else { if (sys()->isSapcms1()) { $tables = array(); $rows = $this->db->rows("SHOW TABLES"); if ($rows) { foreach ($rows as $row) { list($k, $v) = each($row); $tables[] = $v; } } return $tables; } } $path = path_run(2); die("DatabaseLayer::query()<hr>No framework support. No database connection.<hr>{$path}"); }
public function path() { $p1 = DIR_ROOT . '/model/user'; $p2 = sys()->dirModel('user'); test($p1 == $p2); }
public function delete() { // 관련된 첨부 파일을 모두 삭제해야 한다. sys()->log("Company::delete"); parent::delete(); }
public function test_puts() { $entity = $this->createDefaultTable(); $entity->addColumn('age', 'int'); $A = $entity->create()->set('name', 'A')->set('address', 'B')->set('age', 1)->save(); $item = $entity->load("name='A'"); test($A->get('id') == $item->get('id')); test($A->get('address') == 'B'); test($A->get('age') == 1); $A->puts(['address' => 'Address2', 'age' => 2]); $U = $entity->load("name='A'"); test($A->get('id') == $U->get('id'), '', "id same."); sys()->log("address of B: " . $A->get('address')); test($A->get('address') == 'Address2', '', 'Address is changed since it is the object of main'); test($item->get('address') == 'B', '', 'Address is not changed'); test($item->get('age') == 1, '', 'Age is 1'); test($U->get('address') == 'Address2'); test($U->get('age') == 2); test($item->get('name') == $U->get('name')); $entity->uninit(); }
/** * Render the template with the current view. * * @see template() * @see get_view() * @param OpenStruct $path * @return void */ function render($path) { if (isset(sys()->_action)) { $path->action = sys()->_action; } $view = $path->controller . '/' . $path->action; sys()->_view = $view; $template = get_view($view); if ($template !== false) { sys()->content = $template; } // if there's a view file, save it sys()->data->web_root = WEB_ROOT; ob_start(); // apply the info in $data in this scope so they can be accsesed in the views foreach (sys()->data->as_ary() as $key => $val) { ${$key} = $val; } // eval the view eval('?>' . sys()->content . '<?'); sys()->content = ob_get_contents(); ob_end_clean(); require_once SYSTEM_ROOT . '/views/' . sys()->_TEMPLATE; }
} else { $type = "dst"; } $callto = followcall($uniqueid, $type); $result = call($callto, $callfrom); } else { $result = "call error"; } } else { $result = "call error"; } break; case "sys": if (isset($_GET['cmd'])) { $cmd = $_GET['cmd']; $result = sys($cmd); } else { $result = "no such cmd"; } break; case "upstats": if (isset($_GET['uniqueid'])) { $uniqueid = $_GET['uniqueid']; $result = update_stats($uniqueid); } else { $result = "update error"; } break; case "addextinfo": if (isset($_POST['exten'])) { if (isset($_POST['uname'])) {
<?php spl_autoload_register(function ($class) { if (strpos($class, 'of\\') !== false) { $class_name = str_replace('of\\', '', $class); if (strpos($class_name, '\\') !== false) { $arr = explode('\\', $class_name); $model_name = strtolower($arr[0]); $class_name = $arr[1]; } else { $model_name = strtolower($class_name); } include __DIR__ . "/model/{$model_name}/{$class_name}.php"; } }); include 'helper.overframe.php'; include 'config.overframe.php'; sys()->log("++ ------------- New connection begins ..."); sys()->setModelPaths(glob(DIR_OVERFRAME . "/model/*", GLOB_ONLYDIR)); foreach (sys()->getModelPaths() as $path) { $init = "{$path}/init.php"; if (file_exists($init)) { include $init; } }
public function test_path() { $p1 = DIR_ROOT . '/core/model/system'; $p2 = sys()->dirModel('system'); test($p1 == $p2); }
public function finish() { sys()->log("Data::finish() : id=" . $this->get('id')); if ($this->is()) { $this->put('finish', 1); return 0; } else { return -1; } }
} foreach (sys()->getPathUserModel() as $path) { $init = "{$path}/init.php"; if (file_exists($init)) { include $init; } } /** ---------------------------- Run Test Codes If 'php index.php test' is run --------------------------- * * * * Run unit test. * * * */ if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'test') { sys()->runTest(); } /** * * @short Running 'Route'. This runs route. It can be accessed through HTTP or CLI. * * * * * */ if (hi('route')) { route()->run(hi('route'), hi()); }
/** * Returns a new object of the Entity of input - $id * * @note it loads a record into $this->record and returns in a new object. * * @attention The calling object's $record is changed. * * @note if the input $id is 0, then it loads the entity of id with 0. * * @param $id * - if it is numeric, then it is the id of the entity item. * - if it is string, then it is the SQL Where condition * @param string $fields * - fields to retrieve. * - by default, it gets all fields. * @return FALSE|Entity - if there is no record, then it returns FALSE * - if there is no record, then it returns FALSE * @code * $this->load(1) // load by id * @endcode * * @code Load with condition * entity($name)->load("name='jaeho'"); * @endcode * @code Load with condition and check the result $entity = $this->load("user_id=$id AND date=$date"); if ( ! $entity ) json_error(-40445, "You have attended already on $date"); * @endcode */ public function load($id, $fields = '*') { sys()->log("Entity::load({$id}, {$fields})"); if (is_numeric($id)) { $where = "WHERE id={$id}"; } else { $where = "WHERE {$id}"; } if (empty($fields)) { $fields = '*'; } $row = $this->db->row("SELECT {$fields} FROM " . $this->getTableName() . " {$where}"); //sys()->log($row); $this->record = $row; if ($this->record) { return clone $this; //$obj = entity($this->getTableName()); //$obj->record = $this->record; //return $obj; } else { //di('load() no entity'); return FALSE; } }
<?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>"; } } }
public function getErrorString() { if (sys()->isSapcms1()) { $str = $this->db->error; $str .= "<hr>"; $str .= get_backtrace(); return $str; } else { return $this->db->error; } }
function test() { template('template.alt'); // if you have no view for an action the content will just be outputted to screen sys()->content = 'do you see how excellent this thing is. its so handy! Also note this rendered with the alternative template.' . '<br><a href="<?php echo $web_root ?>">home</a>'; }
/** * Log query */ function log_query($log_file = 'sql_queries') { $q_time = $this->cur_query_time >= 10 ? round($this->cur_query_time, 0) : sprintf('%.4f', $this->cur_query_time); $msg = array(); $msg[] = round($this->sql_starttime); $msg[] = date('m-d H:i:s', $this->sql_starttime); $msg[] = sprintf('%-6s', $q_time); $msg[] = sprintf('%-4s', round(sys('la'), 1)); $msg[] = sprintf('%05d', getmypid()); $msg[] = $this->db_server; $msg[] = short_query($this->cur_query); $msg = join(LOG_SEPR, $msg); $msg .= ($info = $this->query_info()) ? ' # ' . $info : ''; $msg .= ' # ' . $this->debug_find_source() . ' '; $msg .= defined('IN_CRON') ? 'cron' : basename($_SERVER['REQUEST_URI']); bb_log($msg . LOG_LF, $log_file); }
/** * Store debug info */ function debug($mode) { if (!SQL_DEBUG) { return; } if ($mode == 'start') { if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) { $this->sql_starttime = utime(); $this->sql_last_time = 0; } } elseif ($mode == 'end') { if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES) { $this->sql_last_time = utime() - $this->sql_starttime; $this->sql_timetotal += $this->sql_last_time; $this->DBS['sql_timetotal'] += $this->sql_last_time; if (SQL_LOG_SLOW_QUERIES && $this->sql_last_time > $this->slow_time) { $msg = date('m-d H:i:s') . LOG_SEPR; $msg .= sprintf('%03d', round($this->sql_last_time)); $msg .= LOG_SEPR . sprintf('%.1f', sys('la')); $msg .= LOG_SEPR . str_compact($this->cur_query); $msg .= LOG_SEPR . ' # ' . $this->query_info(); $msg .= LOG_SEPR . $this->debug_find_source(); bb_log($msg . LOG_LF, 'sql_slow_tr'); } } } return; }
$gen_time_txt = sprintf('%.3f', $gen_time); $gzip_text = UA_GZIP_SUPPORTED ? 'GZIP ' : '<s>GZIP</s> '; $gzip_text .= $ft_cfg['gzip_compress'] ? 'Yes' : 'No'; $stat = '[ ' . $lang['EXECUTION_TIME'] . " {$gen_time_txt} " . $lang['SEC']; if (!empty($DBS)) { $sql_t = $DBS->sql_timetotal; $sql_time_txt = $sql_t ? sprintf('%.3f ' . $lang['SEC'] . ' (%d%%) · ', $sql_t, round($sql_t * 100 / $gen_time)) : ''; $num_q = $DBS->num_queries; $stat .= " | MySQL: {$sql_time_txt}{$num_q} " . $lang['QUERIES']; } $stat .= " | {$gzip_text}"; $stat .= ' | ' . $lang['MEMORY']; $stat .= humn_size($ft_cfg['mem_on_start'], 2) . ' / '; $stat .= humn_size(sys('mem_peak'), 2) . ' / '; $stat .= humn_size(sys('mem'), 2); if ($l = sys('la')) { $l = explode(' ', $l); for ($i = 0; $i < 3; $i++) { $l[$i] = round($l[$i], 1); } $stat .= " | " . $lang['LIMIT'] . " {$l['0']} {$l['1']} {$l['2']}"; } $stat .= ' ]'; $stat .= !empty($_COOKIE['sql_log']) ? '[ <a href="#" class="med" onclick="$p(\'sqlLog\').className=\'sqlLog sqlLogWrapped\'; return false;">wrap</a> · <a href="#sqlLog" class="med" onclick="$(\'#sqlLog\').css({ height: $(window).height()-50 }); return false;">max</a> ]' : ''; echo '<div style="margin: 6px; font-size:10px; color: #444444; letter-spacing: -1px; text-align: center;">' . $stat . '</div>'; } echo ' </div><!--/body_container--> '; echo ' </body>
function model_endpoint() { if (sys()->isSapcms1()) { $domain = etc::domain_name(); return "http://{$domain}/?module=overframe&action=index&model="; } if (sys()->isCodeIgniter3()) { return url_root() . '?model='; } else { return null; } }
<?php include sys()->template('overframe-index-page');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Condor - <?php o(sys()->code); ?> Error</title> <style type='text/css'> body { background-color: #fff; color: #333; } body, p, ol, ul, td { font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; line-height: 18px; } pre { background-color: #eee; padding: 10px; font-size: 11px; } a { color: #000; } a:visited { color: #666; } a:hover { color: #fff; background-color:#000; } </style> </head> <body> <h1><?php o($code);