function getrss() { uses('Sanitize'); Configure::write('debug', '0'); //turn debugging off; debugging breaks ajax $this->layout = 'ajax'; $mrClean = new Sanitize(); $limit = 5; $start = 0; if (empty($this->params['form']['url'])) { die('Incorrect use'); } $url = $this->params['form']['url']; if (!empty($this->params['form']['limit'])) { $limit = $mrClean->paranoid($this->params['form']['limit']); } if (!empty($this->params['form']['start'])) { $start = $mrClean->paranoid($this->params['form']['start']); } $feed = $this->Simplepie->feed_paginate($url, (int) $start, (int) $limit); $out['totalCount'] = $feed['quantity']; $out['title'] = $feed['title']; $out['image_url'] = $feed['image_url']; $out['image_width'] = $feed['image_width']; $out['image_height'] = $feed['image_height']; foreach ($feed['items'] as $item) { $tmp['title'] = strip_tags($item->get_title()); $tmp['url'] = strip_tags($item->get_permalink()); $tmp['description'] = strip_tags($item->get_description(), '<p><br><img><a><b>'); $tmp['date'] = strip_tags($item->get_date('d/m/Y')); $out['items'][] = $tmp; } $this->set('json', $out); }
public function XpFrameworkCircularReferenceTest() { // try to load class uses('xpbug.circularreference.XPBugCircularReference'); // we are still here so no fatal error return $this->assertTrue(true); }
function purchase_product() { // Clean up the post uses('sanitize'); $clean = new Sanitize(); $clean->paranoid($_POST); // Check if we have an active cart, if there is no order_id set, then lets create one. if (!isset($_SESSION['Customer']['order_id'])) { $new_order = array(); $new_order['Order']['order_status_id'] = 0; // Get default shipping & payment methods and assign them to the order $default_payment = $this->Order->PaymentMethod->find(array('default' => '1')); $new_order['Order']['payment_method_id'] = $default_payment['PaymentMethod']['id']; $default_shipping = $this->Order->ShippingMethod->find(array('default' => '1')); $new_order['Order']['shipping_method_id'] = $default_shipping['ShippingMethod']['id']; // Save the order $this->Order->save($new_order); $order_id = $this->Order->getLastInsertId(); $_SESSION['Customer']['order_id'] = $order_id; global $order; $order = $new_order; } // Add the product to the order from the component $this->OrderBase->add_product($_POST['product_id'], $_POST['product_quantity']); global $config; $content = $this->Content->read(null, $_POST['product_id']); $this->redirect('/product/' . $content['Content']['alias'] . $config['URL_EXTENSION']); }
/** * Fetches a configured logger. * * @param string $name Name of the logger. * @return array An array of loggers */ public static function GetLogger($name) { if (isset(self::$_loggers[$name])) { return self::$_loggers[$name]; } else { $conf = Config::Get('logger'); if (isset($conf->items[$name])) { if (!$conf->items[$name]->enabled) { return null; } $logtypes = $conf->items[$name]->output; $target = $conf->items[$name]->target; $enabled = $conf->items[$name]->enabled; $types = explode(',', $logtypes); foreach ($types as $type) { uses("system.app.driver.logger.{$type}"); $class = $type . "Logger"; $logger = new $class($type, $target, $conf->items[$name]); self::$_loggers[$name][] = $logger; } return self::$_loggers[$name]; } return null; } }
function import($sFile) { if (!$this->bSpycReady) { return self::SPYC_CLASS_NOT_FOUND; } if (!file_exists($sFile)) { return self::YAML_FILE_NOT_FOUND; } $this->aTables = SPYC::YAMLload(file_get_contents($sFile)); if (!is_array($this->aTables)) { return self::YAML_FILE_IS_INVALID; } uses('model' . DS . 'model'); $oDB = $this->oDb; $aAllowedTables = $oDB->listSources(); foreach ($this->aTables as $table => $records) { if (!in_array($oDB->config['prefix'] . $table, $aAllowedTables)) { return self::TABLE_NOT_FOUND; } $temp_model = new Model(false, $table); foreach ($records as $record_num => $record_value) { if (!isset($record_value['id'])) { $record_value['id'] = $record_num; } if (!$temp_model->save($record_value)) { return array('error' => array('table' => $table, 'record' => $record_value)); } } } return true; }
/** * Runs a screen. * * @param string $which Which screen to run, "before" or "after" * @param Controller $controller The controller * @param AttributeReader $method_meta The method metadata * @param Array $data Array of data that the screen(s) can add to. */ public static function Run($which, $controller, $method_meta, &$data, &$args) { $c = $controller->metadata->{$which}; $m = $method_meta->{$which}; if (!$c) { $c = new AttributeReader(); } if (!$m) { $m = new AttributeReader(); } $screens = $c->merge($m); foreach ($screens as $name => $screen) { if (!$screen->ignore) { if (isset(self::$_screens[$name])) { $s = self::$_screens[$name]; } else { uses('screen.' . $name); $class = $name . 'Screen'; $s = new $class(); self::$_screens[$name] = $s; } $s->{$which}($controller, $screen, $data, $args); } } }
/** * Fetches a named database from the connection pool. * * @param string $name Name of the database to fetch from the connection pool. * @return Database The named database. */ public static function GetManager($name) { if (isset(self::$_managers[$name])) return self::$_managers[$name]; else { $conf=Config::Get('cloud'); if (isset($conf->dsn->items[$name])) { $dsn=$conf->dsn->items[$name]->storage; $matches=array(); if (preg_match_all('#([a-z0-9]*)://([^@]*)@(.*)#',$dsn,$matches)) { $driver=$matches[1][0]; $auth=$matches[2][0]; $secret=$matches[3][0]; uses('system.cloud.driver.storage.'.$driver); $class=$driver."Driver"; $storage=new $class($auth,$secret); self::$_managers[$name]=$storage; return $storage; } } throw new Exception("Cannot find storage named '$name' in Config."); } }
function getProductById($product_id) { $sql = "SELECT p.* FROM {$this->table_prefix}products p WHERE p.id=" . $product_id; $result = $this->dbstuff->GetRow($sql); if (empty($result) || !$result) { return false; } $result['pubdate'] = @date("Y-m-d", $result['created']); if (!empty($result['picture'])) { $result['imgsmall'] = "../" . pb_get_attachmenturl($result['picture']) . ".small.jpg"; $result['imgmiddle'] = "../" . pb_get_attachmenturl($result['picture']) . ".middle.jpg"; $result['image'] = "../" . pb_get_attachmenturl($result['picture']); $result['image_url'] = rawurlencode($result['picture']); } else { $result['image'] = pb_get_attachmenturl('', '', 'middle'); } if (!empty($result['tag_ids'])) { uses("tag"); $tag = new Tags(); $tag_res = $tag->getTagsByIds($result['tag_ids']); if (!empty($tag_res)) { $tags = null; foreach ($tag_res as $key => $val) { $tags .= '<a href="product/list.php?do=search&q=' . urlencode($val) . '" target="_blank">' . $val . '</a> '; } $result['tag'] = $tags; unset($tags, $tag_res, $tag); } } $this->info = $result; return $result; }
function beforeFilter() { header('Content-type: text/html; charset="utf-8"'); uses('L10n'); //backend is protected if (!empty($this->params['admin']) && $this->params['admin'] == 1) { $this->layout = "admin"; if (isset($this->Auth)) { $this->Auth->userModel = 'User'; $this->Auth->fields = array('username' => 'email', 'password' => 'password'); $this->Auth->loginAction = '/admin/users/login'; $this->Auth->loginRedirect = '/admin/users/'; $this->Auth->autoRedirect = true; $this->user = $this->Auth->user(); if (empty($this->user) && $this->RequestHandler->isAjax()) { $this->render(null, 'ajax', APP . 'views/elements/ajax_login_message.ctp'); } $this->set('user', $this->user); $this->_setAdminMenu(); } if ($this->name == 'Users' && $this->action == 'admin_login') { $this->layout = 'admin_login'; } } else { $this->Auth->allow(); } }
function Search($firstcount, $displaypg) { global $cache_types; uses("space", "industry", "area"); $space = new Space(); $area = new Areas(); $industry = new Industries(); $cache_options = cache_read('typeoption'); $area_s = $space->array_multi2single($area->getCacheArea()); $industry_s = $space->array_multi2single($area->getCacheArea()); $result = $this->findAll("*,name AS title,content AS digest", null, null, $this->orderby, $firstcount, $displaypg); while (list($keys, $values) = each($result)) { $result[$keys]['typename'] = $cache_types['productsort'][$values['sort_id']]; $result[$keys]['thumb'] = pb_get_attachmenturl($values['picture'], '', 'small'); $result[$keys]['pubdate'] = df($values['begin_time']); if (!empty($result[$keys]['area_id'])) { $r1 = $area_s[$result[$keys]['area_id']]; } if (!empty($result[$keys]['cache_companyname'])) { $r2 = "<a href='" . $space->rewrite($result[$keys]['cache_companyname'], $result[$keys]['company_id']) . "'>" . $result[$keys]['cache_companyname'] . "</a>"; } if (!empty($r1) || !empty($r2)) { $result[$keys]['extra'] = implode(" - ", array($r1, $r2)); } $result[$keys]['url'] = $this->getPermaLink($values['id']); } return $result; }
/** * test uses() * * @access public * @return void */ function testUses() { $this->assertFalse(class_exists('Security')); $this->assertFalse(class_exists('Sanitize')); uses('Security', 'Sanitize'); $this->assertTrue(class_exists('Security')); $this->assertTrue(class_exists('Sanitize')); }
/** * Creates a finder for documents of a given name. * @static * @param $document_name * @return Finder */ public static function Document($document_name) { $document_name = str_replace('/', '.', $document_name); uses("document.{$document_name}"); $parts = explode('.', $document_name); $class = str_replace('_', '', array_shift($parts)); $instance = new $class(); return $instance->doc_db->create_finder($instance); }
public static function Model($model) { //$model=str_replace('.','/',$model); uses('model.' . $model); $parts = explode('.', $model); $class = str_replace('_', '', $parts[1]); $instance = new $class(); return new SOLRFilter($instance, $class, false); }
/** * Instantiate the fixture. * * @param object Cake's DBO driver (e.g: DboMysql). * * @access public */ function __construct(&$db) { $this->db =& $db; $this->init(); if (!class_exists('cakeschema')) { uses('model' . DS . 'schema'); } $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test_suite')); }
function admin_upload() { uses('folder'); $folder = new Folder($this->directory, false, 0755); $upload = array(); $copyright_type = $this->Copyright->generateList(); $this->set(compact('copyright_type')); if (isset($this->data) && $this->data['Image']['filename']['error'] == 0) { // Check that Filetype is valid if (!in_array($this->data['Image']['filename']['type'], $this->allowedTypes)) { $this->Session->setFlash('Invalid File type: ' . $this->data['Image']['filename']['type']); return false; } $valid_ext = $this->getExt($this->data['Image']['filename']['type']); // Explode file name and extention $myfile = $this->FileOps->explodeFilename($this->data['Image']['filename']['name']); if (!$valid_ext == $myfile['ext']) { $this->Session->setFlash('File extention does not match mimetype. Please check this file is a valid' . $this->data['Image']['filename']['type'] . ' file.'); break; } // Lets get the metadata first $upload['type'] = $this->data['Image']['filename']['type']; $upload['filesize'] = $this->data['Image']['filename']['size']; $upload['alt'] = $this->data['Image']['alt']; $upload['filename'] = $myfile['filename']; $upload['copyright_id'] = $this->data['Image']['copyright_id']; $upload['copyright_owner'] = $this->data['Image']['copyright_owner']; // The temporary file we need to copy once uploaded. $upload['tmp'] = $this->data['Image']['filename']['tmp_name']; if (!file_exists($this->directory . $upload['filename'] . '.' . $myfile['ext'])) { if (!($moved = $this->FileOps->movefile($this->directory, $upload['tmp'], $upload['filename'] . '.' . $myfile['ext']))) { $this->Session->setFlash('File system save failed.'); return false; } else { $this->Image->create(); $this->Image->save($upload); $this->Session->setFlash('Image successfuly uploaded'); foreach ($this->thumbsize as $thumb => $settings) { $thumbfile = $myfile['filename'] . '.' . $thumb . '.' . $myfile['ext']; if (!$this->createthumb($this->directory . $upload['filename'] . '.' . $myfile['ext'], $this->directory . $thumbfile, $settings['width'], $settings['width'])) { // #TODO: validation does not seem to work. //$this->Session->setFlash('Thumb failed'); //return false; } } } } else { $this->Session->setFlash('File already exists.'); return false; } } else { if ($this->data['Image']['filename']['error'] == 4) { print_r('No File Selected'); } } }
/** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2075 $ */ function smarty_block_feed($params, $content, &$smarty, &$repeat) { $conditions = array(); $param_count = count($smarty->_tag_stack); if (empty($params['name'])) { $params['name'] = "feed"; } if (class_exists("Services")) { $service = new Services(); $service_controller = new Service(); } else { uses("service"); $service = new Services(); $service_controller = new Service(); } $orderby = array(); require CACHE_PATH . "cache_type.php"; if (isset($params['type'])) { $conditions[] = "type='" . $params['type'] . "'"; } if (isset($params['typeid'])) { $conditions[] = "type_id='" . $params['typeid'] . "'"; } if (isset($params['id'])) { $conditions[] = "id='" . $params['id'] . "'"; } if (isset($params['orderby'])) { $orderby[] = trim($params['orderby']); } else { $orderby[] = "id DESC "; } $service->setOrderby($orderby); $service->setCondition($conditions); $limit = $offset = 0; if (isset($params['row'])) { $limit = $params['row']; } if (isset($params['start'])) { $offset = $params['start']; } $service->setLimitOffset($offset, $limit); $sql = "SELECT * FROM {$service->table_prefix}feeds " . $service->getCondition() . $service->getOrderby() . $service->getLimitOffset(); $result = $service->GetArray($sql); $return = $link_title = null; if (!empty($result)) { $i_count = count($result); for ($i = 0; $i < $i_count; $i++) { $data = unserialize($result[$i]['data']); foreach ($data as $val) { $link_title .= $val; } $return .= str_replace(array("[link:title]"), array($link_title), $content); } } return $return; }
function __construct($config = null) { if ($config != null) { parent::__construct($config); } uses('xml'); vendor('snoopy/snoopy'); $this->xml = new XML(); $this->Snoopy = new Snoopy(); }
/** * Copy demo products directory to webroot */ public function copyDemoproductImages() { uses('folder'); $path = APP . 'webroot' . DS . 'img' . DS . 'uploads' . DS; $folder =& new Folder($path); @$folder->delete($path); $backup = APP . 'docs' . DS . 'uploads' . DS; $folder =& new Folder($backup); @$folder->copy($path); }
public static function Init() { $profiler=Config::$environment_config->profiler; if ((self::$_profiler==null) && ($profiler!=null) && ($profiler!="none")) { uses('sys.utility.profilers.'.$profiler); $class=$profiler."Profiler"; self::$_profiler=new $class(); } }
private function arreglar_tipoinstits() { App::import('Vendor', 'depura_tipoinstit/main'); uses('model' . DS . 'datasources' . DS . 'datasource'); config('database'); $this->autoRender = false; //conecto con la BD de cake default $this->db = new DATABASE_CONFIG(); $depurador = new DepuraTipoinstits($this->db->default); $depurador->main(); }
function initialize(&$controller, $settings = array()) { uses('Folder'); $this->Folder =& new Folder(); $this->controller =& $controller; if (!empty($this->controller->Newsletter)) { $this->Newsletter = $this->controller->Newsletter; } else { $this->Newsletter = ClassRegistry::init('Newsletter.Newsletter'); } }
function _invoke(&$controller, $params, $missingAction) { $controller->params =& $params; $classVars = get_object_vars($controller); if ($missingAction && in_array('scaffold', array_keys($classVars))) { uses('controller' . DS . 'scaffold'); return new Scaffold($controller, $params); } elseif ($missingAction && !in_array('scaffold', array_keys($classVars))) { return $this->cakeError('missingAction', array(array('className' => Inflector::camelize($params['controller'] . "Controller"), 'action' => $params['action'], 'webroot' => $this->webroot, 'url' => $this->here, 'base' => $this->base))); } return $controller; }
/** * Static function used to gain an instance of the correct ACL class. * * @return object instance of ACL_CLASSNAME set in app/config/core.php * @access public */ function &getACL() { if ($this->_instance == null) { uses('controller' . DS . 'components' . DS . ACL_FILENAME); $classname = ACL_CLASSNAME; $this->_instance = new $classname(); } if ($classname == 'DB_ACL') { $this->Aro = new Aro(); $this->Aco = new Aco(); } return $this->_instance; }
public static function Model($model) { $model=str_replace('/','.',$model); uses("model.$model"); $parts=explode('.',$model); $class=str_replace('_','',$parts[1]); $instance=new $class(); return new Filter($instance,$class); }
public static function Get($channel) { if (isset(self::$_cache[$channel])) { return self::$_cache[$channel]; } uses('channel.' . $channel); $classname = str_replace('_', '', $channel) . "Channel"; if (class_exists($classname)) { $class = new $classname(); self::$_cache[$channel] = $class; return $class; } throw new Exception("Channel '{$channel}' does not exist."); }
/** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2075 $ */ function smarty_block_keyword($params, $content, &$smarty, &$repeat) { $conditions = array(); $param_count = count($smarty->_tag_stack); if (empty($params['name'])) { $params['name'] = "keyword"; } if (!class_exists("Keywords")) { uses("keyword"); $keyword = new Keywords(); $keyword_controller = new Keyword(); } else { $keyword = new Keywords(); $keyword_controller = new Keyword(); } $conditions[] = "status=1"; if (isset($params['typeid'])) { $conditions[] = "type='" . intval($params['typeid']) . "'"; } if (isset($params['orderby'])) { $orderby = " ORDER BY " . trim($params['orderby']) . " "; } else { $orderby = " ORDER BY id DESC"; } $keyword->setCondition($conditions); $orderby = null; $limit = $offset = 0; if (isset($params['row'])) { $limit = $params['row']; } if (isset($params['start'])) { $offset = $params['start']; } $keyword->setLimitOffset($offset, $limit); $sql = "SELECT id,name,name AS title,name AS fulltitle FROM {$keyword->table_prefix}keywords " . $keyword->getCondition() . "{$orderby}" . $keyword->getLimitOffset(); $result = $keyword->GetArray($sql); $return = null; if (!empty($result)) { $i_count = count($result); for ($i = 0; $i < $i_count; $i++) { if (isset($params['titlelen'])) { $result[$i]['title'] = mb_substr($result[$i]['title'], 0, $params['titlelen']); } $url = $keyword->getPermaLink($result[$i]['id']); $return .= str_replace(array("[field:title]", "[field:fulltitle]", "[field:id]", "[link:title]"), array($result[$i]['title'], $result[$i]['fulltitle'], $result[$i]['id'], $url), $content); } } return $return; }
/** * Sets up the configuation for the model, and loads ACL models if they haven't been already * * @param mixed $config * @return void * @access public */ function setup(&$model, $config = array()) { if (is_string($config)) { $config = array('type' => $config); } $this->settings[$model->name] = array_merge(array('type' => 'requester'), (array) $config); $type = $this->__typeMaps[$this->settings[$model->name]['type']]; if (!class_exists('AclNode')) { uses('model' . DS . 'db_acl'); } $model->{$type} =& ClassRegistry::init($type); if (!method_exists($model, 'parentNode')) { trigger_error("Callback parentNode() not defined in {$model->alias}", E_USER_WARNING); } }
/** * Confirm database connection and redirect accordingly */ public function databaseconnection_check() { uses('model' . DS . 'connection_manager'); $db = ConnectionManager::getInstance(); @($connected = $db->getDataSource('default')); $message = 'Error: not able to connect to database'; $cssClass = 'error'; $action = 'database'; if ($connected->isConnected()) { $message = 'Success: your database connection is now set'; $cssClass = ''; $action = 'bakesale'; } $this->Session->setFlash($message, 'default', array('class' => $cssClass)); $this->redirect(array('action' => $action)); }
function setup() { if (!empty($this->data)) { $data = $this->data; $install_files_path = CONFIGS . 'install' . DS; $connection = array(); foreach (array('driver', 'host', 'login', 'password', 'database', 'prefix') as $k) { $connection[$k] = $data[$k]; } $this->_writeDBConfig($connection); uses('model' . DS . 'connection_manager'); $db = ConnectionManager::getInstance(); $connection = $db->getDataSource('default'); if ($connection->isConnected()) { App::import('vendor', 'migrations'); $oMigrations = new Migrations(); $oMigrations->load($install_files_path . 'schema.yml'); $dbRes = $oMigrations->up(); if (is_array($dbRes)) { $error_string = ''; foreach ($dbRes as $error) { $error_string .= $error['error'] . '<br />'; } $this->Session->setFlash(__('There were some errors during the creation of your db tables', true) . ':<br />' . $error_string); } elseif ($dbRes == true) { //add admin to the users table App::import('model', array('User', 'Site')); $User = new User(); $User->save(array('username' => $data['admin_username'], 'password' => sha1(Configure::read('Security.salt') . $data['admin_password']), 'group_id' => 1)); /*$Site = new Site(); $Site->save( array( 'user_id' => $User->getInsertID(), 'domain' => Configure::read( 'CMS.Site.Domain' ) ) );*/ App::import('vendor', 'fixtures'); $oFixtures = new Fixtures(); if ($oFixtures->import($install_files_path . 'fixtures.yml') === true) { $this->flash('Congratulations, you have successfully installed Pagebakery!', '/'); } else { $this->Session->setFlash(__('Sorry, there was an error adding initial data', true)); } } } else { $this->Session->setFlash('I could not connect to the DataBase. Please check the setup details again.'); } } $this->set('DBDrivers', $this->_getDBDrivers()); }
function search() { $this->pageTitle = __('USERS_SEARCH_TITLE', true); // objekt pre escapovanie // uses('sanitize'); $sanit = new Sanitize(); // // nastav condition na zaklade zaslaneho hladania // $condition = array('"User"."username" LIKE \'%' . $sanit->paranoid(@$_POST['name']) . '%\' OR ' . '"User"."first_name" LIKE \'%' . $sanit->paranoid(@$_POST['name']) . '%\' OR ' . '"User"."middle_name" LIKE \'%' . $sanit->paranoid(@$_POST['name']) . '%\' OR ' . '"User"."last_name" LIKE \'%' . $sanit->paranoid(@$_POST['name']) . '%\''); // // find & paginate it $this->set('name', $sanit->paranoid(@$_POST['name'])); $this->paginate['User']['limit'] = 20; $this->set('users', $this->paginate('User', $condition)); $this->render('index'); }