public function __call($m, $a) { $ignore_ofs_methods = array('__destruct'); if (in_array($m, $ignore_ofs_methods)) { return 'IGNORE_OFS_COMMAND_COMPLETE'; } // if the command is in the list of commands to run on all ofs objects, do so $all_ofs_methods = array('append_header', 'append_footer'); if (in_array($m, $all_ofs_methods)) { foreach ($this->ofs as $set_id => $ofs) { call_user_func_array(array(&$ofs, $m), $a); } return 'ALL_OFS_COMMAND_COMPLETE'; } $use_replica_set_id = format::get_context_replica_set_id(); if ($use_replica_set_id == -10) { // context_replica_set_id -10 means object does not have slonySetId defined // use the natural first replica set as the replica context $first_replica_set = pgsql8::get_slony_replica_set_natural_first(dbsteward::$new_database); $use_replica_set_id = (int) $first_replica_set['id']; } // make sure replica set id to use is known if (!isset($this->ofs[$use_replica_set_id])) { if ($this->skip_unknown_set_ids) { dbsteward::notice("[OFS RSR] context replica set ID is " . $use_replica_set_id . ", but no replica set by that ID, skipping output"); return FALSE; } throw new exception("context replica set ID " . $use_replica_set_id . " not defined"); } $active_set_ofs = $this->ofs[$use_replica_set_id]; dbsteward::debug("[OFS RSR] __call calling " . $use_replica_set_id . " ofs::" . $m); return call_user_func_array(array(&$active_set_ofs, $m), $a); }
public function action_index() { // clear buffer helper_ob::clean_all(); // validating do { $options = application::get('flag.numbers.backend.cron.base'); // token if (!empty($options['token']) && request::input('token') != $options['token']) { break; } // ip if (!empty($options['ip']) && !in_array(request::ip(), $options['ip'])) { break; } // get date parts $date_parts = format::now('parts'); print_r($date_parts); echo "GOOD\n"; } while (0); // we need to validate token //$token = request::input('token'); echo "OK\n"; // exit exit; }
/** * Whenever setting the slug, make sure that it conforms to requirements * @developer Brandon Hansen * @date Oct 26, 2010 */ public function __set($key, $value) { if ($key == 'slug') { $value = format::pretty_url($value); } parent::__set($key, $value); }
/** * Get the page title * @Developer brandon * @Date May 7, 2010 */ public static function get_title() { if (!isset(self::$meta['title'])) { return format::friendly_model_name(Router::$controller) . ' :: ' . format::friendly_model_name(Router::$method); } else { return strip_tags(self::$meta['title']); } }
/** * Provide a dropdown for variants * @developer Brandon Hansen * @date Nov 2, 2010 */ public static function variant_dropdown(Product_Model $product) { $options = array(); foreach ($product->variants as $variant) { $options[(string) $variant] = $variant->name . ' - ' . format::dollar_format($variant->price); } return self::dropdown(array('name' => 'variant_id', 'id' => 'select-variant'), $options); }
public static function size($file, $format = false) { $file = path::decode($file); $size = @filesize($file); if ($format) { $size = format::byte($size, $format); } return $size; }
/** * Show path route * @Developer brandon * @Date Oct 11, 2010 */ public function show_path($abs = true) { $path = $this->object_name . '/' . format::pretty_url($this->slug); if ($abs) { return url::site($path); } else { return $path; } }
/** * Clean up the show page URL * @Developer brandon * @Date Oct 11, 2010 */ public function show($name = NULL) { $blog = ORM::factory('blog')->where('name', format::dash_to_space($name))->find(); // Set the title meta::set_title(ucwords($blog->name)); // Set the description meta::set_description($blog->synopsis); // Show the page parent::show($blog); }
public function onDefault() { $tables = $this->db->table()->get(true); $header['title'] = '数据库管理'; page::header($header); page::add('<div id="page" class="clearfix">'); page::add('<div id="side">'); block::header('数据库基本信息'); table::header(); table::row(array('w60' => '数据库名称', '2' => '' . $this->db->config['database'] . '')); table::row(array('w60' => '数据库版本', '2' => '' . $this->db->version(true) . '')); table::row(array('w60' => '数据库大小', '2' => '<b>' . $this->db->size() . '</b> ')); table::row(array('w60' => '数据表个数', '2' => '<b>' . count($tables) . '</b> 个')); table::footer(); block::footer(); page::add('</div>'); page::add('<div id="main">'); page::top(); page::navbar($this->navbar(), 'table'); //zotop::dump($tables); form::header(array('class' => 'ajax')); $column['select'] = '<input name="id" class="selectAll" type="checkbox"/>'; $column['name'] = '数据表名称'; $column['size w60'] = '大小'; $column['Rows w60'] = '记录数'; $column['Engine w60'] = '类型'; $column['Collation w100'] = '整理'; $column['manage view w60'] = '浏览'; $column['manage delete'] = '删除'; table::header('list', $column); foreach ($tables as $table) { $size = $table['Data_length'] + $table['Index_length']; $column = array(); $column['select'] = '<input name="id[]" class="select" type="checkbox"/>'; $column['name'] = '<b>' . $table['Name'] . '</b><h5>' . $table['Comment'] . '</h5>'; $column['size w60'] = (string) format::size($size); $column['Rows w60'] = $table['Rows']; $column['Engine w60'] = $table['Engine']; $column['collation w100'] = $table['Collation']; $column['manage view w60'] = '<a href="' . url::build('system/database/table/record') . '">浏览</a>'; $column['manage delete'] = '<a href="' . url::build('system/database/table/delete') . '" class="confirm">删除</a>'; table::row($column); } table::footer(); page::add('<div style="height:200px;"></div>'); form::buttons(array('type' => 'select', 'style' => 'width:180px', 'options' => array('check' => '优化', 'delete' => '删除')), array('type' => 'submit', 'value' => '执行操作')); form::footer(); page::bottom(); page::add('</div>'); page::add('</div>'); page::footer(); }
public function init() { $total = $this->db->count(); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $pagesize = 20; $offset = ($page - 1) * $pagesize; $list = $this->db->select('', '*', $offset.','.$pagesize); pc_base::load_sys_class('format', '', 0); foreach ($list as $key=> $v) { $list[$key]['lastlogin'] = format::date($v['lastlogin'], 1); } $pages = pages($total, $page, $pagesize); include $this->admin_tpl('administrator_list'); }
/** * see html::calendar() */ public static function calendar($options = []) { // include js & css files if (empty($options['readonly'])) { layout::add_js('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_js_base.js'); layout::add_css('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_css_base.css'); } // font awesome icons library::add('fontawesome'); // widget parameters $type = $options['calendar_type'] ?? $options['type'] ?? 'date'; $widget_options = ['id' => $options['id'], 'type' => $type, 'format' => $options['calendar_format'] ?? format::get_date_format($type), 'date_week_start_day' => $options['calendar_date_week_start_day'] ?? 1, 'date_disable_week_days' => $options['calendar_date_disable_week_days'] ?? null, 'master_id' => $options['calendar_master_id'] ?? null, 'slave_id' => $options['calendar_slave_id'] ?? null]; $options['type'] = 'text'; // determine input size $placeholder = format::get_date_placeholder($widget_options['format']); $options['size'] = strlen($placeholder); // set placeholder if (!empty($options['placeholder']) && $options['placeholder'] == 'format::get_date_placeholder') { $options['placeholder'] = $placeholder; $options['title'] = ($options['title'] ?? '') . ' (' . $placeholder . ')'; } if (isset($options['calendar_icon']) && ($options['calendar_icon'] == 'left' || $options['calendar_icon'] == 'right')) { $position = $options['calendar_icon']; if (i18n::rtl()) { if ($position == 'left') { $position = 'right'; } else { $position = 'left'; } } $icon_type = $type == 'time' ? 'clock-o' : 'calendar'; unset($options['calendar_icon']); if (empty($options['readonly'])) { $icon_onclick = 'numbers_calendar_var_' . $options['id'] . '.show();'; } else { $icon_onclick = null; } $icon_value = html::span(['onclick' => $icon_onclick, 'class' => 'numbers_calendar_icon numbers_prevent_selection', 'value' => html::icon(['type' => $icon_type])]); $result = html::input_group(['value' => html::input($options), $position => $icon_value, 'dir' => 'ltr']); $div_id = $options['id'] . '_div_holder'; $result .= html::div(['id' => $div_id, 'class' => 'numbers_calendar_div_holder']); $widget_options['holder_div_id'] = $div_id; } else { $result = html::input($options); } // we do not render a widget if readonly if (empty($options['readonly'])) { layout::onload('numbers_calendar(' . json_encode($widget_options) . ');'); } return $result; }
/** * see tinyurl::set(); */ public static function set($url, $options = []) { // insert new row into the table $object = new numbers_backend_misc_tinyurl_db_model_tinyurls(); $result = $object->insert(['sm_tinyurl_inserted' => format::now('datetime'), 'sm_tinyurl_url' => $url . '', 'sm_tinyurl_expires' => $options['expires'] ?? null]); if ($result['success']) { $result['data']['id'] = $result['last_insert_id']; $result['data']['hash'] = base_convert($result['last_insert_id'] . '', 10, 36); } else { $result['data'] = []; } array_key_unset($result, ['success', 'error', 'data'], ['preserve' => true]); return $result; }
public function save(&$form) { $model = factory::model($form->options['other']['model']); $save = [$model->column_prefix . 'important' => !empty($form->values['important']) ? 1 : 0, $model->column_prefix . 'comment_value' => $form->values['comment'] . '', $model->column_prefix . 'who_entity_id' => session::get('numbers.entity.em_entity_id'), $model->column_prefix . 'inserted' => format::now('timestamp')]; foreach ($form->options['other']['map'] as $k => $v) { $save[$v] = $form->options['other']['pk'][$k]; } $save_result = $model->save($save, ['ignore_not_set_fields' => true]); if ($save_result['success']) { $form->error('success', 'Comment has been added successfully!'); } else { $form->error('danger', 'Could not add comment!'); } }
/** * Process the lock * @param string $id * @return boolean */ public static function process($id) { $lock_data = lock::exists($id); if ($lock_data !== false) { $minutes = round(abs(strtotime(format::now()) - strtotime($lock_data)) / 60, 2); if ($minutes > 30) { lock::release($id); $lock_data = false; } } // we are ok to proceed if ($lock_data === false) { lock::create($id); return true; } else { return false; } }
public function public_get_one() { $total = $this->comment_check_db->count(array('siteid'=>$this->get_siteid())); $comment_check_data = $this->comment_check_db->select(array('siteid'=>$this->get_siteid()), '*', '19,1', 'id desc'); $comment_check_data = $comment_check_data[0]; $r = array(); if (is_array($comment_check_data) && !empty($comment_check_data)) { $this->comment_data_db->table_name($comment_check_data['tableid']); $r = $this->comment_data_db->get_one(array('id'=>$comment_check_data['comment_data_id'], 'siteid'=>$this->get_siteid())); pc_base::load_sys_class('format','', 0); $r['creat_at'] = format::date($r['creat_at'], 1); if (pc_base::load_config('system','charset')=='gbk') { foreach ($r as $k=>$v) { $r[$k] = iconv('gbk', 'utf-8', $v); } } } echo json_encode(array('total'=>$total, 'data'=>$r)); }
/** * Get information * * @param string $ip * @return array */ public function get($ip) { $ip = $ip . ''; // try to get IP information from cache $cache = new cache('db'); $cache_id = 'misc_ip_ipinfo_' . $ip; $data = $cache->get($cache_id); if ($data !== false) { return ['success' => true, 'error' => [], 'data' => $data]; } // if we need to query ipinfo.io $json = file_get_contents("http://ipinfo.io/{$ip}/json"); $data = json_decode($json, true); if (isset($data['country'])) { $temp = explode(',', $data['loc']); $save = ['ip' => $ip, 'date' => format::now('date'), 'country' => $data['country'], 'region' => $data['region'], 'city' => $data['city'], 'postal' => $data['postal'], 'lat' => format::read_floatval($temp[0]), 'lon' => format::read_floatval($temp[1])]; $cache->set($cache_id, $save, ['misc_ip_ipinfo'], 604800); return ['success' => true, 'error' => [], 'data' => $save]; } else { return ['success' => false, 'error' => ['Could not decode IP address!'], 'data' => ['ip' => $ip]]; } }
/** * Render * * @param object $object * @return string */ public static function render($object) { $input = $object->options['input']; if (empty($input['sort'])) { $i = 0; foreach ($object->orderby as $k => $v) { $input['sort'][$i]['column'] = $k; $input['sort'][$i]['order'] = $v; $i++; } } // generating form $table = ['header' => ['row_number' => ' ', 'column' => i18n(null, 'Column'), 'order' => i18n(null, 'Order')], 'options' => []]; $order_model = new object_data_model_order(); $columns = []; // we need to skip certain columns foreach ($object->columns as $k => $v) { if (!in_array($k, ['row_number', 'offset_number', 'action'])) { $v['name'] = i18n(null, $v['name']); $columns[$k] = $v; } } // full text search goes last if (!empty($object->filter['full_text_search'])) { $columns['full_text_search'] = ['name' => i18n(null, 'Text Search')]; } // render 5 rows for ($i = 0; $i < 5; $i++) { if (empty($input['sort'][$i]['column'])) { $input['sort'][$i]['order'] = SORT_ASC; } $column = html::select(['id' => 'sort_' . $i . '_column', 'name' => 'sort[' . $i . '][column]', 'options' => $columns, 'value' => $input['sort'][$i]['column'] ?? null]); $order = html::select(['id' => 'sort_' . $i . '_order', 'name' => 'sort[' . $i . '][order]', 'no_choose' => true, 'options' => $order_model->options(['i18n' => true]), 'value' => $input['sort'][$i]['order'] ?? null]); $table['options'][$i] = ['row_number' => ['value' => format::id($i + 1) . '.', 'width' => '1%', 'align' => 'right'], 'column' => ['value' => $column, 'width' => '25%', 'class' => 'list_sort_name'], 'order' => ['value' => $order, 'width' => '30%']]; } $body = html::table($table); $footer = html::button2(['name' => 'submit_sort', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "numbers.modal.hide('list_{$object->list_link}_sort'); \$('#list_{$object->list_link}_form').attr('target', '_self'); \$('#list_{$object->list_link}_form').attr('no_ajax', ''); return true;"]); return html::modal(['id' => "list_{$object->list_link}_sort", 'class' => 'large', 'title' => i18n(null, 'Sort'), 'body' => $body, 'footer' => $footer]); }
public function action_index() { $input = request::input(null, true, true); $result = ['success' => false, 'error' => [], 'loggedin' => false, 'expired' => false, 'expires_in' => 0]; if (!empty($input['token']) && !empty($input[session_name()])) { $crypt = new crypt(); $token_data = $crypt->token_validate($input['token'], ['skip_time_validation' => true]); if (!($token_data === false || $token_data['id'] !== 'general')) { // quering database $model = new numbers_backend_session_db_model_sessions(); $db = $model->db_object(); $session_id = $db->escape($input[session_name()]); $expire = format::now('timestamp'); $sql = <<<TTT \t\t\t\t\tSELECT \t\t\t\t\t\tsm_session_expires, \t\t\t\t\t\tsm_session_user_id \t\t\t\t\tFROM {$model->name} \t\t\t\t\tWHERE 1=1 \t\t\t\t\t\tAND sm_session_id = '{$session_id}' \t\t\t\t\t\tAND sm_session_expires >= '{$expire}' TTT; $temp = $db->query($sql); // put values into result $result['expired'] = empty($temp['rows']); $result['loggedin'] = !empty($temp['rows'][0]['sm_session_user_id']); // calculate when session is about to expire if (!empty($temp['rows'])) { $now = format::now('unix'); $expires = strtotime($temp['rows'][0]['sm_session_expires']); $result['expires_in'] = $expires - $now; } $result['success'] = true; } } // rendering layout::render_as($result, 'application/json'); }
/** * Initialize * * @param array $options */ public static function init($options = []) { // default options self::$defaut_options = ['language_code' => 'sys', 'locale' => 'en_CA.UTF-8', 'timezone' => 'America/Toronto', 'server_timezone' => application::get('php.date.timezone'), 'date' => 'Y-m-d', 'time' => 'H:i:s', 'datetime' => 'Y-m-d H:i:s', 'timestamp' => 'Y-m-d H:i:s.u', 'amount_frm' => 20, 'amount_fs' => 40, 'settings' => ['currency_codes' => []], 'locale_locales' => [], 'locale_locale_js' => null, 'locale_set_name' => null, 'locale_options' => [], 'locale_override_class' => null]; // settings from config files $config = application::get('flag.global.format'); // settings from user account $entity = entity::groupped('format'); // merge all of them together self::$options = array_merge_hard(self::$defaut_options, $config, i18n::$options, $entity, $options); // fix utf8 self::$options['locale'] = str_replace(['utf8', 'utf-8'], 'UTF-8', self::$options['locale']); // generate a list of available locales $locale_settings = self::set_locale(self::$options['locale'], self::$defaut_options['locale']); self::$options = array_merge_hard(self::$options, $locale_settings); // fix values self::$options['amount_frm'] = (int) self::$options['amount_frm']; self::$options['amount_fs'] = (int) self::$options['amount_fs']; self::$options['locale_options']['mon_thousands_sep'] = self::$options['locale_options']['mon_thousands_sep'] ?? ','; self::$options['locale_options']['mon_decimal_point'] = self::$options['locale_options']['mon_decimal_point'] ?? '.'; if (empty(self::$options['locale_options']['mon_grouping'])) { self::$options['locale_options']['mon_grouping'] = [3, 3]; } // load data from models if (!empty(self::$options['model'])) { foreach (self::$options['model'] as $k => $v) { $method = factory::method($v, null); self::$options['settings'][$k] = factory::model($method[0], true)->{$method[1]}(); } unset(self::$options['model']); } // push js format version to frontend if (!empty(self::$options['locale_override_class'])) { $locale_override_class = self::$options['locale_override_class']; $locale_override_class::js(); } }
?> > <input name="info[islink]" type="checkbox" id="islink" value="1"<?php if ($info['islink']) { ?> checked<?php } ?> onclick="ruselinkurl();" > <font color="red"><?php echo L('islink'); ?> </font> <h6> <?php echo L('inputtime'); ?> </h6> <?php echo form::date('info[inputtime]', format::date($info['inputtime'], 1), 1); ?> <h6> <?php echo L('template_style'); ?> </h6> <?php echo form::select($template_list, $data['style'], 'name="data[style]" id="style" onchange="load_file_list(this.value)"', L('please_select')); ?> <h6> <?php echo L('show_template'); ?> </h6> <span id="show_template"><?php echo '<script type="text/javascript">$.getJSON(\'?m=admin&c=category&a=public_tpl_file_list&style=' . $style . '&id=' . $data['show_template'] . '&module=special&templates=show&name=data\', function(data){$(\'#show_template\').html(data.show_template);});</script>'; ?> </span> </div>
"><?php echo $hits_r['views']; ?> </td> <td align='center'> <?php if ($r['sysadd'] == 0) { echo "<a href='?m=member&c=member&a=memberinfo&username="******"&pc_hash=" . $_SESSION['pc_hash'] . "' >" . $r['username'] . "</a>"; echo '<img src="' . IMG_PATH . 'icon/contribute.png" title="' . L('member_contribute') . '">'; } else { echo $r['username']; } ?> </td> <td align='center'><?php echo format::date($r['updatetime'], 1); ?> </td> <td align='center'><a href="javascript:;" onclick="javascript:openwinx('?m=content&c=content&a=edit&catid=<?php echo $catid; ?> &id=<?php echo $r['id']; ?> ','')"><?php echo L('edit'); ?> </a> | <a href="javascript:view_comment('<?php echo id_encode('content_' . $catid, $r['id'], $this->siteid); ?> ','<?php
if(is_array($infos)){ foreach($infos as $info){ $space = $this->s_db->get_one(array('spaceid'=>$info['spaceid']), 'name'); ?> <tr> <td align="center"> <input type="checkbox" name="id[]" value="<?php echo $info['id']?>"> </td> <td align="center"><?php echo $info['id']?></td> <th width="70"><input type="text" size="5" name="listorder[<?php echo $info['id']?>]" value="<?php echo $info['listorder']?>" id="listorder"></th> <td><?php echo $info['name']?></td> <td align="center"><?php echo $types[$info['type']]?></td> <td align="center"><?php echo $space['name']?></td> <td align="center"><?php if($info['disabled']) { echo L('stop'); } elseif((strtotime($info['enddate'])<SYS_TIME) && (strtotime($info['enddate'])>0)) { echo L('past'); } else { echo L('start'); }?></td> <td align="center"><?php echo $info['clicks']?></td> <td align="center"><?php echo format::date($info['addtime'], 1);?></td> <td align="center"><a href="index.php?m=poster&c=poster&a=edit&id=<?php echo $info['id'];?>&pc_hash=<?php echo $_SESSION['pc_hash'];?>&menuid=<?php echo $_GET['menuid']?>" ><?php echo L('edit')?></a>|<a href="?m=poster&c=poster&a=stat&id=<?php echo $info['id']?>&spaceid=<?php echo $_GET['spaceid'];?>"><?php echo L('stat')?></a></td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><label for="check_box"><?php echo L('selected_all')?>/<?php echo L('cancel')?></label> <input name='submit' type='submit' class="button" value='<?php echo L('listorder')?>'> <input name='submit' type='submit' class="button" value='<?php echo L('start')?>' onClick="document.myform.action='?m=poster&c=poster&a=public_approval&passed=0'"> <input name='submit' type='submit' class="button" value='<?php echo L('stop')?>' onClick="document.myform.action='?m=poster&c=poster&a=public_approval&passed=1'"> <input name="submit" type="submit" class="button" value="<?php echo L('delete')?>" onClick="document.myform.action='?m=poster&c=poster&a=delete';return confirm('<?php echo L('confirm', array('message' => L('selected')))?>')"> </div> </div> <div id="pages"><?php echo $this->db->pages;?></div>
?> <?php echo L('keyword'); ?> :<input type='text' name="key" id="key" value="<?php echo $_GET['key']; ?> " size="25"> <div class="bk10"></div> <span id="catids"></span> <?php echo L('input_time'); ?> : <?php $start_f = $_GET['start_time'] ? $_GET['start_time'] : format::date(SYS_TIME - 2592000); $end_f = $_GET['end_time'] ? $_GET['end_time'] : format::date(SYS_TIME + 86400); ?> <?php echo form::date('start_time'); ?> - <?php echo form::date('end_time'); ?> <input type="submit" name="search" class="button" value="<?php echo L('search'); ?> " /> </div> </td> </tr> </tbody>
</a></h2> <div class="lh22"><?php echo $info['description']; ?> </div> <p class="gray4"><?php echo L('create_man'); ?> :<a href="#" class="blue"><?php echo $info['username']; ?> </a>, <?php echo L('create_time'); ?> :<?php echo format::date($info['createtime'], 1); ?> </p> </div> </td> <td align="center"><span style="height:22"><a href='?m=special&c=content&a=init&specialid=<?php echo $info['id']; ?> ' onclick="javascript:openwinx('?m=special&c=content&a=add&specialid=<?php echo $info['id']; ?> &pc_hash=<?php echo $_SESSION['pc_hash']; ?> ','')"><?php echo L('add_news');
/** * Initialize db connections, cache and session */ public static function init($options = []) { // initialize mbstring mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); // get flags & dependencies $flags = application::get('flag'); $backend = application::get('numbers.backend', ['backend_exists' => true]); // processing wildcard first $wildcard = application::get('wildcard'); $wildcard_keys = null; if (!empty($wildcard['enabled']) && !empty($wildcard['model'])) { $wildcard_keys = call_user_func($wildcard['model']); application::set(['wildcard', 'keys'], $wildcard_keys); } // initialize cryptography $crypt = application::get('crypt'); if (!empty($crypt) && $backend) { foreach ($crypt as $crypt_link => $crypt_settings) { if (!empty($crypt_settings['submodule']) && !empty($crypt_settings['autoconnect'])) { $crypt_object = new crypt($crypt_link, $crypt_settings['submodule'], $crypt_settings); } } } // create database connections $db = application::get('db'); if (!empty($db) && $backend) { foreach ($db as $db_link => $db_settings) { if (empty($db_settings['autoconnect']) || empty($db_settings['servers']) || empty($db_settings['submodule'])) { continue; } $connected = false; foreach ($db_settings['servers'] as $server_key => $server_values) { $db_object = new db($db_link, $db_settings['submodule']); // wildcards replaces if (isset($wildcard_keys[$db_link])) { $server_values['dbname'] = $wildcard_keys[$db_link]['dbname']; } // connecting $server_values = array_merge2($server_values, $db_settings); $db_status = $db_object->connect($server_values); if ($db_status['success'] && $db_status['status']) { $connected = true; break; } } // checking if not connected if (!$connected) { throw new Exception('Unable to open database connection!'); } } } // initialize cache $cache = application::get('cache'); if (!empty($cache) && $backend) { foreach ($cache as $cache_link => $cache_settings) { if (empty($cache_settings['submodule']) || empty($cache_settings['autoconnect'])) { continue; } $connected = false; foreach ($cache_settings['servers'] as $cache_server) { $cache_object = new cache($cache_link, $cache_settings['submodule']); $cache_status = $cache_object->connect($cache_server); if ($cache_status['success']) { $connected = true; break; } } // checking if not connected if (!$connected) { throw new Exception('Unable to open cache connection!'); } } } // if we are from command line we exit here if (!empty($options['__run_only_bootstrap'])) { return; } // initialize session $session = application::get('flag.global.session'); if (!empty($session['start']) && $backend && !application::get('flag.global.__skip_session')) { session::start(isset($session['options']) ? $session['options'] : []); } // we need to get overrides from session and put them back to flag array $flags = array_merge_hard($flags, session::get('numbers.flag')); application::set('flag', $flags); // initialize i18n if ($backend) { $temp_result = i18n::init(); if (!$temp_result['success']) { throw new Exception('Could not initialize i18n.'); } } // format format::init(); // including libraries that we need to auto include if (!empty($flags['global']['library'])) { foreach ($flags['global']['library'] as $k => $v) { // we need to skip certain keys if ($k == 'submodule' || $k == 'options') { continue; } // we only include if autoconnect is on if (!empty($v['autoconnect'])) { factory::submodule('flag.global.library.' . $k . '.submodule')->add(); } } } // check if we need to include system files from frontend if (application::get('dep.submodule.numbers.frontend.system')) { numbers_frontend_system_model_base::start(); } }
<th width="33%"> </th><th width="33%"> </th><th width="33%"> </th> </tr> </thead> <tbody> <?php if(is_array($infos)){ $n = 0; foreach($infos as $info){ $n++; ?> <?php if($n%3==1){?><tr><?php }?> <td><div class="col-left mr10" style="width:146px; height:112px"><img src="<?php echo format_url($info['video']['picPath'])?>" width="146" height="112" style="border:1px solid #eee" align="left" title="<?php echo $info['video']['title'];?>"></div> <div class="col-auto"> <h2 class="title-1 f14 lh28 mb6 blue" title="<?php echo $info['video']['title'];?>"><?php echo str_cut($info['video']['title'], 26)?></h2> <div class="lh22"><?php echo $info['video']['desc']?></div> <p class="gray4">上传时间:<?php echo format::date(substr(trim($info['video']['uploadTime']), 0, 10), 1)?></p> <p class="gray4">播放次数:<?php echo $info['video']['videoTime']?></p> </div> </td> <?php if($n%3==0){?></tr><?php }?> <?php } } ?> </tbody> </table> <div class="btn"></div> <div id="pages"><?php echo $pages;?></div><script>window.top.$("#display_center_id").css("display","none");</script> </form> </div>
</tr> <tr> <td><?php echo form::input('variant[' . $index . '][sku]', $variant->sku); ?> </td> <td><?php echo form::input('variant[' . $index . '][price]', format::dollar_round($variant->price)); ?> </td> <td><?php echo form::input('variant[' . $index . '][compare_price]', format::dollar_round($variant->compare_price)); ?> </td> <td><?php echo form::input('variant[' . $index . '][weight]', format::weight($variant->weight)); ?> </td> </tr> </table> <div class="form-fields"> <?php echo form::label('variant[' . $index . '][taxable]', 'Charge Tax'); ?> <?php echo form::hidden('variant[' . $index . '][taxable]', false); ?> <?php echo form::checkbox('variant[' . $index . '][taxable]', true, $variant->taxable); ?> </div>
public function sendConfirmation($orderId) { $order = ORM::factory('order', $orderId); $db = new Database(); $res = $db->query('SELECT oa.* FROM orders_addresses oa JOIN orders o ON (oa.id = o.orders_address_id) WHERE o.id="' . $orderId . '"'); // call autoresponder handlers $shippingInfo = $res[0]->shipping_first_name . ' ' . $res[0]->shipping_last_name . '<br/>' . $res[0]->shipping_address1 . '<br/>' . $res[0]->shipping_address2 . '<br/>' . $res[0]->shipping_city . ' ' . $res[0]->shipping_state . '<br/>' . $res[0]->shipping_zip . '<br/>' . $res[0]->shipping_country; $billingInfo = $res[0]->billing_first_name . ' ' . $res[0]->billing_last_name . '<br/>' . $res[0]->billing_address1 . '<br/>' . $res[0]->billing_address2 . '<br/>' . $res[0]->billing_city . ' ' . $res[0]->billing_state . '<br/>' . $res[0]->billing_zip . '<br/>' . $res[0]->billing_country; $dateTime = date('Y-m-d H:i:s'); $res = $db->query('SELECT p.name, ob.qty, ob.subtotal FROM products p JOIN orders_baskets ob ON (ob.product_id=p.id) WHERE ob.order_id="' . $orderId . '"'); $order_basket = new Orders_basket_Model(); $description = ''; $subtotal = 0; foreach ($res as $item) { $description .= $item->name . ' ' . $item->qty . ' x ' . format::dollar($item->subtotal) . '<br/>'; $subtotal += $item->subtotal; } if (!empty($order->comment)) { $description .= 'Comment:' . $order->comment . '<br/>'; } $total = 'Subtotal: ' . format::dollar($subtotal) . '<br/>Shipping:' . format::dollar($order->shipping_total); $total .= '<br/>Total:' . format::dollar($order->payment_total); Autoresponder::sendEmail('order.confirmation', $order->email, $order, array('shipping_info' => $shippingInfo, 'billing_info' => $billingInfo, 'date_time' => $dateTime, 'description' => $description, 'total' => $total)); }
protected static function get_data_row_update($node_schema, $node_table, $old_data_row_columns, $old_data_row, $new_data_row_columns, $new_data_row, $changed_columns) { if (count($changed_columns) == 0) { throw new exception("empty changed_columns passed"); } // what columns from new_data_row are different in old_data_row? // those are the ones to push through the update statement to make the database current $old_columns = array(); $update_columns = array(); foreach ($changed_columns as $changed_column) { if (!isset($changed_column['old_col'])) { $old_columns[] = 'NOTDEFINED'; } else { $old_col_value = format::column_value_default($node_schema, $node_table, $changed_column['name'], $changed_column['old_col']); $old_columns[] = $changed_column['name'] . ' = ' . $old_col_value; } $update_col_name = format::get_quoted_column_name($changed_column['name']); $update_col_value = format::column_value_default($node_schema, $node_table, $changed_column['name'], $changed_column['new_col']); $update_columns[] = $update_col_name . ' = ' . $update_col_value; } // if the computed update_columns expression is < 5 chars, complain // if ( strlen($update_columns) < 5 ) { // var_dump($update_columns); // throw new exception(sprintf("%s.%s update_columns is < 5 chars, unexpected", $node_schema['name'], $node_table['name'])); // } $old_columns = implode(', ', $old_columns); $update_columns = implode(', ', $update_columns); // use multiline comments here, so when data has newlines they can be preserved, but upgrade scripts don't catch on fire $sql = sprintf("UPDATE %s SET %s WHERE (%s); /* old values: %s */\n", format::get_fully_qualified_table_name($node_schema['name'], $node_table['name']), $update_columns, dbx::primary_key_expression(dbsteward::$new_database, $node_schema, $node_table, $new_data_row_columns, $new_data_row), $old_columns); return $sql; }
<th width="160"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center" width="40"><input class="inputcheckbox" <?php if (!empty($imported) && in_array($info['id'], $imported)){?>disabled<?php }?> name="id[]" value="<?php echo $info['id'];?>" type="checkbox"></td> <td width="40" align="center"><?php echo $info['id']?></td> <td><div class="col-left mr10" style="width:146px; height:112px"><img src="<?php echo format_url($info['coverurl'])?>" width="146" height="112" style="border:1px solid #eee" align="left"></div> <div class="col-auto"> <h2 class="title-1 f14 lh28 mb6 blue"><?php echo $info['title']?></h2> <div class="lh22"><?php echo $info['desc']?></div> <p class="gray4"><?php echo L('create_time')?>:<?php echo format::date(substr(trim($info['createtime']), 0, 10), 1)?></p> <p class="gray4">播放次数:<?php echo $info['videocount']?></p> </div> </td> <td align="center"><span style="height:22"><?php if (!empty($imported) && in_array($info['id'], $imported)){?><font color="red">专辑已载入<?php } else {?><a href='?m=special&c=album&a=import&id=<?php echo $info['id']?>&page=<?php echo $_GET['page'];?>&pc_hash=<?php echo $_GET['pc_hash'];?>'>载入此专辑</a><?php }?></span><br /><span style="height:22"><a href="?m=special&c=album&a=content_list&id=<?php echo $info['id']?>&menuid=<?php echo $_GET['menuid']?>&pc_hash=<?php echo $_GET['pc_hash'];?>">查看专辑下的视频</a></span></td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><label for="check_box"><?php echo L('selected_all')?>/<?php echo L('cancel')?></label> <input name='dosubmit' type='submit' class="button" value='载入'> </div>