protected function saveToDb(array $result, $index = 0) { $table = $this->getTable(); $fileInfo = $result['info']; $dbal = DBAL::insert($table); $dbal->set(array('name' => $fileInfo->getName(), 'filepath' => $fileInfo->getPath(), 'mime' => $fileInfo->getType(), 'filesize' => $fileInfo->getSize(), 'created' => Util::getNow(), 'options' => serialize($this->getOptions()))); if (!empty($this->_extra)) { foreach ($this->_extra as $k => $v) { //@todo consider to add some callback feature $dbal->set($k, $v); } } if (method_exists($this, 'preSaveToDb')) { $dbal = $this->preSaveToDb($dbal, $result, $index); } return $dbal->execute(); }
public function auth() { // TODO Auto-generated method stub $ip = Util::getIP(); $config = Config::getInstance(); $ips = $config->get('interior.ip'); foreach ($ips as $ip_range) { if (strpos($ip_range, ',')) { list($start_ip, $end_ip) = explode(',', $ip_range); if (Util::inValidIPRange($ip, $start_ip, $end_ip)) { return true; } } else { if ($ip == $ip_range) { return true; } } } return $this->sendAccessDined(); }
public function touch($key, $expiration) { $key = $this->resolveKey($key); if (isset($this->data[$key])) { if ($expiration != 0) { $expiration += Util::getNow(); } $this->data[$key]['expire'] = $expiration; return true; } return false; }
protected function createNewId() { return Util::generateRandStr(40); }
private function prepareReservedVariable($name) { $output = ''; $cache_buster = Config::getInstance()->get('template.cache_buster'); if ($cache_buster == '') { $cache_buster = \ORC\Util\Util::getNow(); } switch ($name) { case 'js': //first get the template js $existing_jses = array(); $jses = array_merge($this->_jses, $this->getViewModel()->getAllJs()); //pre($jses, $this->_jses); foreach ($jses as $path) { if (in_array($path, $existing_jses)) { continue; } $existing_jses[] = $path; $path = Url::getFullHttpPath($path); $output .= sprintf('<script type="text/javascript" src="%s?%s"></script>', $path, $cache_buster); } break; case 'css': $existing_csses = array(); $csses = array_merge($this->_csses, $this->getViewModel()->getAllCss()); foreach ($csses as $css) { if (!isset($existing_csses[$css['media']])) { $existing_csses[$css['media']] = array(); } if (in_array($css['path'], $existing_csses[$css['media']])) { continue; } $existing_csses[$css['media']][] = $css['path']; $css['path'] = Url::getFullHttpPath($css['path']); $output .= sprintf('<link type="text/css" rel="stylesheet" href="%s?%s" media="%s" />', $css['path'], $cache_buster, $css['media']); } break; case 'raw_js': $output .= implode("\n", $this->_viewModel->getRawJs()); break; case 'raw_css': $output .= implode("\n", $this->_viewModel->getRawCss()); break; case 'title': $output .= $this->getViewModel()->getTitle(); break; } return $output; }
/** * * @param int $index * @param string $sql * @todo not called at all.. */ protected function logSql($index, $sql) { if ($this->debug) { $args = func_get_args(); array_shift($args); array_shift($args); $this->sqls[$index][] = array('sql' => $sql, 'params' => $args, 'time' => \ORC\Util\Util::getNow()); } }