/** * Method to get the content types. * * @return array An array of JContentType objects. * * @since 12.1 * @throws RuntimeException */ public function getTypes() { $types = array(); // Get the cache store id. $storeId = $this->getStoreId('getTypes'); // Attempt to retrieve the types from cache first. $cached = $this->retrieve($storeId); // Check if the cached value is usable. if (is_array($cached)) { return $cached; } // Build the query to get the content types. $query = $this->db->getQuery(true); $query->select('a.*'); $query->from($query->qn('#__content_types') . ' AS a'); // Get the content types. $this->db->setQuery($query); $results = $this->db->loadObjectList(); // Reorganize the type information. foreach ($results as $result) { // Create a new JContentType object. $type = $this->factory->getType(); // Bind the type data. $type->bind($result); // Add the type, keyed by alias. $types[$result->alias] = $type; } // Store the types in cache. return $this->store($storeId, $types); }
/** * Execute the application. * * @return void */ public function doExecute() { // Get the query builder class from the database and set it up // to select everything in the 'db' table. $query = $this->dbo->getQuery(true)->select('*')->from($this->dbo->qn('db')); // Push the query builder object into the database connector. $this->dbo->setQuery($query); // Get all the returned rows from the query as an array of objects. $rows = $this->dbo->loadObjectList(); // Just dump the value returned. var_dump($rows); }
/** * Compacts the ordering sequence of the selected records * * @access public * @param string Additional where query to limit ordering to a particular subset of records */ function reorder($where = '') { $k = $this->_tbl_key; if (!in_array('ordering', array_keys($this->getProperties()))) { $this->setError(get_class($this) . ' does not support ordering'); return false; } if ($this->_tbl == '#__content_frontpage') { $order2 = ", content_id DESC"; } else { $order2 = ""; } $query = 'SELECT ' . $this->_tbl_key . ', ordering' . ' FROM ' . $this->_tbl . ' WHERE ordering >= 0' . ($where ? ' AND ' . $where : '') . ' ORDER BY ordering' . $order2; $this->_db->setQuery($query); if (!($orders = $this->_db->loadObjectList())) { $this->setError($this->_db->getErrorMsg()); return false; } // compact the ordering numbers for ($i = 0, $n = count($orders); $i < $n; $i++) { if ($orders[$i]->ordering >= 0) { if ($orders[$i]->ordering != $i + 1) { $orders[$i]->ordering = $i + 1; $query = 'UPDATE ' . $this->_tbl . ' SET ordering = ' . (int) $orders[$i]->ordering . ' WHERE ' . $k . ' = ' . $this->_db->Quote($orders[$i]->{$k}); $this->_db->setQuery($query); $this->_db->query(); } } } return true; }
public function getBrands() { $query = "SELECT a.group_id,u.*, ku.userName, ku.description, ku.image, ku.url FROM `#__user_usergroup_map` as a LEFT JOIN #__users as u ON u.id = a.user_id LEFT JOIN #__k2_users as ku ON ku.userID = a.user_id where a.group_id = 13;"; $query_set = $this->dbo->setQuery($query); $items = $this->dbo->loadObjectList(); return $items; }
/** * Method to load an object by primary id. * * @return void * * @since 12.1 * @throws RuntimeException */ protected function doLoad() { // Get the primary key. $primaryKey = $this->getTableKey('primary', 'primary'); $primaryTable = $this->getTableExpression('primary'); // Build the query object. $query = $this->db->getQuery(true); $query->select($this->getTableKeyExpression('primary', '*')); $query->from($primaryTable); $query->where($this->getTableKeyExpression('primary', 'primary') . ' = ' . (int) $this->{$primaryKey}); // Get the subtables. $tables = $this->tables; unset($tables['primary']); // Add additional tables to the query. foreach ($tables as $alias => $table) { // Add the table select and join clauses. $query->select($this->getTableKeyExpression($alias, '*')); $query->join('INNER', $this->getTableExpression($alias)); } // Get the content data. $this->db->setQuery($query); $data = $this->db->loadObject(); // Check the type data. if (empty($data)) { throw new RuntimeException(JText::sprintf('JDATABASEOBJECT_NOT_FOUND', $this->{$primaryKey}, $primaryTable)); } // Bind the data. $this->bind($data); }
public function getNewItemid($id) { $query = 'SELECT k2_item_id,new_item_id,item_type from #__k2_recipe_map where k2_item_id = ' . $id . ';'; $query_set = $this->dbo->setQuery($query); $newitem = $this->dbo->loadObject(); return $newitem; }
public function getK2Users() { $query = "SELECT id, userID, userName, description, image, url from #__k2_users ;"; $query_set = $this->dbo->setQuery($query); $items = $this->dbo->loadObjectList(); return $items; }
/** * Tests the JDatabase::setQuery method. * * @return void * * @since 12.1 */ public function testSetQuery() { $this->assertThat( $this->db->setQuery('SELECT * FROM #__dbtest'), $this->isInstanceOf('JDatabase'), 'setQuery method should return an instance of JDatabase.' ); }
public function getK2Categories() { //$query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 and extraFieldsGroup = 1 order by id;" ; $query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 order by id;"; $query_set = $this->dbo->setQuery($query); $categories = $this->dbo->loadObjectList(); return $categories; }
/** * Count items. * * @return int */ public function count() { $query = clone $this->query; $this->build($query); $query->select('COUNT(*)'); $this->db->setQuery($query); $count = (int) $this->db->loadResult(); KunenaError::checkDatabaseError(); return $count; }
public function getElementScripts(){ $retArray = array(); $this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Validation'"); $retArray['validation'] = $this->db->loadObjectList(); $this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Action'"); $retArray['action'] = $this->db->loadObjectList(); $this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Init'"); $retArray['init'] = $this->db->loadObjectList();; return $retArray; }
function jotcache_upgrade(JDatabase $db) { $message = ''; $query = $db->getQuery(true); $query->select('COUNT(*)')->from('#__jotcache_exclude')->where('type=1'); $tplex_count = $db->setQuery($query)->loadResult(); if ($tplex_count == 0) { return false; } $query->clear('where'); $query->where('type=4'); $count = $db->setQuery($query)->loadResult(); if ($count == 0) { $query->clear('select')->clear('where'); $query->select($db->quoteName('value'))->from($db->quoteName('#__template_styles', 's'))->where('name=s.id')->where('type=1')->order('s.home'); $defs = $db->setQuery($query)->loadResultArray(); $positions = array(); foreach ($defs as $def) { $def_array = unserialize($def); $positions = array_merge($positions, $def_array); } $query->clear(); $query->select('position')->from('#__modules')->where('client_id = 0')->where('published = 1')->where('position <>' . $db->quote(''))->group('position')->order('position'); $db->setQuery($query); $items = $db->loadResultArray(); $cleaned_positions = array(); foreach ($items as $item) { if (array_key_exists($item, $positions)) { $cleaned_positions[$item] = $positions[$item]; } } $defs = serialize($cleaned_positions); $query->clear(); $query->insert('#__jotcache_exclude')->columns('name,value,type')->values('1,' . $db->quote($defs) . ',4'); if ($db->setQuery($query)->query()) { $message = "TABLE #__jotcache_exclude has been upgraded. Check JotCache TPL exclude definitions for correct values."; } else { JError::raiseNotice(100, $db->getErrorMsg()); } return $message; } }
public function loadK2ItemsMap() { $db = $this->dbo; $query = "select * from #__k2_recipe_map ;"; $query_set = $this->dbo->setQuery($query); $items = $this->dbo->loadObjectList(); $this->k2_items_maps = array(); foreach ($items as $key => $item) { $obj = new stdClass(); $obj->item_type = $item->item_type; $obj->new_item_id = $item->new_item_id; $this->k2_items_maps[$item->k2_item_id] = $obj; } }
/** * Generic check for whether dependencies exist for this object in the database schema * * Can be overloaded/supplemented by the child class * * @param mixed $pk An optional primary key value check the row for. If not * set the instance property value is used. * @param array $joins An optional array to compiles standard joins formatted like: * [label => 'Label', name => 'table name' , idfield => 'field', joinfield => 'field'] * * @return boolean True on success. * * @deprecated 12.1 * @link http://docs.joomla.org/JTable/canDelete * @since 11.1 */ public function canDelete($pk = null, $joins = null) { // Deprecation warning. JLog::add('JTable::canDelete() is deprecated.', JLog::WARNING, 'deprecated'); // Initialise variables. $k = $this->_tbl_key; $pk = is_null($pk) ? $this->{$k} : $pk; // If no primary key is given, return false. if ($pk === null) { return false; } if (is_array($joins)) { // Get a query object. $query = $this->_db->getQuery(true); // Setup the basic query. $query->select($this->_db->quoteName($this->_tbl_key)); $query->from($this->_db->quoteName($this->_tbl)); $query->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->{$k})); $query->group($this->_db->quoteName($this->_tbl_key)); // For each join add the select and join clauses to the query object. foreach ($joins as $table) { $query->select('COUNT(DISTINCT ' . $table['idfield'] . ') AS ' . $table['idfield']); $query->join('LEFT', $table['name'] . ' ON ' . $table['joinfield'] . ' = ' . $k); } // Get the row object from the query. $this->_db->setQuery((string) $query, 0, 1); $row = $this->_db->loadObject(); // Check for a database error. if ($this->_db->getErrorNum()) { $this->setError($this->_db->getErrorMsg()); return false; } $msg = array(); $i = 0; foreach ($joins as $table) { $k = $table['idfield'] . $i; if ($row->{$k}) { $msg[] = JText::_($table['label']); } $i++; } if (count($msg)) { $this->setError("noDeleteRecord" . ": " . implode(', ', $msg)); return false; } else { return true; } } return true; }
/** * Returns an associative array of records from a query. * * @param $query */ function query($query) { switch (strtolower(substr(trim($query), 0, 6))) { case 'select': $this->_db->setQuery($query); $results = $this->_db->loadAssocList(); return $results; break; case 'insert': case 'update': $this->_db->setQuery($query); $result = $this->_db->query(); return $result; break; } return false; }
/** * Description * * @access public * @param $oid * @param $log */ function hit() { if (!in_array('hits', array_keys($this->getProperties()))) { return; } $k = $this->_tbl_key; $query = $this->_db->getQuery(true); $query->update($this->_db->quoteName($this->_tbl)); $query->set(' hits = ( hits + 1 ) '); // check whether all fields are filled and build where statement for ($i = 0; $i < count($k); $i++) { if ($this->{$k}[$i] === null) { return false; } else { $query->where(' ' . $this->_db->quoteName($k[$i]) . ' = ' . $this->_db->Quote($this->{$k}[$i]) . ' '); } } $this->_db->setQuery($query); $this->_db->query(); $this->hits++; }
protected function _modTopicList($data) { $result = array(); $catid = intval($data); $user = KunenaFactory::getuser(); if ($catid && $user->isModerator($catid)) { $query = "SELECT id, subject\n\t\t\t\t\t\t\tFROM #__kunena_messages\n\t\t\t\t\t\t\tWHERE catid={$this->_db->Quote($catid)} AND parent=0 AND moved=0\n\t\t\t\t\t\t\tORDER BY id DESC"; $this->_db->setQuery($query, 0, 15); $topics_list = $this->_db->loadObjectlist(); if ($this->_db->getErrorNum()) { $result = array('status' => '-1', 'error' => KunenaError::getDatabaseError()); } else { $result['status'] = '1'; $result['topiclist'] = $topics_list; } } else { $result['status'] = '0'; $result['error'] = 'Error'; } return $result; }
/** * get exisiting records sets, optionally filtered by inn list * * @param string $table table suffix * @param array $filter array of inns or numbers * @return array of record objects */ private function getExistingRecords($filter = array(), $table = "") { if ($table && $table == "_oldcert") { $fields = "id,number,adding_date"; $wherefld = "number"; } else { $fields = "id,inn,adding_date"; $wherefld = "inn"; } $sql = "SELECT {$fields} FROM #__sro{$table} "; if (!empty($filter)) { $numbers = implode(",", $filter); $sql .= " WHERE {$wherefld} IN ({$numbers})"; } $this->_db->setQuery($sql); $result = $this->_db->loadObjectList($wherefld); if (is_null($result)) { $this->setError("Ошибка при загрузке существующих данных:" . $this->_db->getErrorMsg()); return array(); } return $result; }
/** * Generic Publish/Unpublish function * * @access public * @param array An array of id numbers * @param integer 0 if unpublishing, 1 if publishing * @param integer The id of the user performnig the operation * @since 1.0.4 */ function publish($cid = null, $publish = 1, $user_id = 0) { JArrayHelper::toInteger($cid); $user_id = (int) $user_id; $publish = (int) $publish; $k = $this->_tbl_key; if (count($cid) < 1) { if ($this->{$k}) { $cid = array($this->{$k}); } else { $this->setError("No items selected."); return false; } } $cids = $k . '=' . implode(' OR ' . $k . '=', $cid); $query = 'UPDATE ' . $this->_tbl . ' SET published = ' . (int) $publish . ' WHERE (' . $cids . ')'; $checkin = in_array('checked_out', array_keys($this->getProperties())); if ($checkin) { $query .= ' AND (checked_out = 0 OR checked_out = ' . (int) $user_id . ')'; } $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } if (count($cid) == 1 && $checkin) { if ($this->_db->getAffectedRows() == 1) { $this->checkin($cid[0]); if ($this->{$k} == $cid[0]) { $this->published = $publish; } } } $this->setError(''); return true; }
/** * Controlla l'esistenza di un indice in una tabella * @param string $tablename * @param string indexname * @return boolean TRUE se esiste, FALSE se non esiste */ public function indexExists($tablename, $indexname) { $q = "SHOW INDEX FROM `" . $this->replacePrefix($tablename) . "` WHERE Key_name='" . $indexname . "'"; $this->db->setQuery($q); return $this->db->loadResult() != null; }
/** * Get a JSON formatted list of installed extensions * Needs to be public so we can call it from the audit. * * @return string */ public function getExtensions() { // connect/get the Joomla db object $this->db = JFactory::getDbo(); // crazy way of handling Joomla 1.5.x legacy :-( $one5 = FALSE; // Get Joomla 2.0+ Extensions $this->db->setQuery('SELECT e.extension_id, e.name, e.type, e.element, e.enabled, e.folder, ( SELECT title FROM #__menu AS m WHERE m.component_id = e.extension_id AND parent_id = 1 ORDER BY ID ASC LIMIT 1 ) AS title FROM #__extensions AS e WHERE protected = 0'); $installedExtensions = $this->db->loadObjectList(); // ok if we have none maybe we are Joomla < 1.5.26 if (!$installedExtensions) { // Yooo hoo I'm on a crap old, out of date, probably hackable Joomla version! $one5 = TRUE; // Get the extensions - used to be called components $this->db->setQuery('SELECT "component" as "type", name, `option` as "element", enabled FROM #__components WHERE iscore != 1 and parent = 0'); $components = $this->db->loadObjectList(); // Get the plugins $this->db->setQuery('SELECT "plugin" as "type", name, element, folder, published as enabled FROM #__plugins WHERE iscore != 1'); $plugins = $this->db->loadObjectList(); // get the modules $this->db->setQuery('SELECT "module" as "type", module, module as name, client_id, published as enabled FROM #__modules WHERE iscore != 1'); $modules = $this->db->loadObjectList(); /** * Get the templates - I n Joomla 1.5.x the templates are not in the * db unless published so we need to read the folders from the /templates folders * Note in Joomla 1.5.x there was no such think as admin templates */ $folders = array_merge(scandir(JPATH_BASE . '/templates'), scandir(JPATH_ADMINISTRATOR . '/templates')); $templates = array(); foreach ($folders as $templateFolder) { $f = JPATH_BASE . '/templates/' . trim($templateFolder); $a = JPATH_ADMINISTRATOR . '/templates/' . trim($templateFolder); // We dont want index.html etc... if (!is_dir($f) && !is_dir($a) || ($templateFolder == '.' || $templateFolder == '..')) { continue; } if (is_dir($a)) { $client_id = 1; } else { $client_id = 0; } // make it look like we want like Joomla 2.5+ would $template = array('type' => 'template', 'template' => $templateFolder, 'client_id' => $client_id, 'enabled' => 1); // Convert to an obj $templates[] = json_decode(json_encode($template)); } // Merge all the "extensions" we have found all over the place $installedExtensions = array_merge($components, $plugins, $modules, $templates); } $lang = JFactory::getLanguage(); // Load all the language strings up front incase any strings are shared foreach ($installedExtensions as $k => $ext) { $lang->load(strtolower($ext->element) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($ext->element) . ".sys", JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($ext->name) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($ext->name) . ".sys", JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($ext->title) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($ext->title) . ".sys", JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($ext->element), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($ext->element), JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($ext->name), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($ext->name), JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($ext->title), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($ext->title), JPATH_SITE, 'en-GB', TRUE); $element = str_replace('_TITLE', '', strtoupper($ext->element)); $name = str_replace('_TITLE', '', strtoupper($ext->name)); $title = str_replace('_TITLE', '', strtoupper($ext->title)); $lang->load(strtolower($element) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($element) . ".sys", JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($name) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($name) . ".sys", JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($title) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($title) . ".sys", JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($element), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($element), JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($name), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($name), JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($title), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load(strtolower($title), JPATH_SITE, 'en-GB', TRUE); // templates $lang->load('tpl_' . strtolower($name), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load('tpl_' . strtolower($name), JPATH_SITE, 'en-GB', TRUE); // Joomla 1.5.x modules $lang->load('mod_' . strtolower($name), JPATH_ADMINISTRATOR, 'en-GB', TRUE); $lang->load('mod_' . strtolower($name), JPATH_SITE, 'en-GB', TRUE); // tut tut Akeeba - bad naming! $lang->load(strtolower('PLG_SYSTEM_SRP'), JPATH_ADMINISTRATOR, 'en-GB', TRUE); // should be plg_srp $lang->load(strtolower('PLG_SYSTEM_ONECLICKACTION'), JPATH_SITE, 'en-GB', TRUE); // should be plg_oneclickaction $lang->load(strtolower('PLG_SYSTEM_ONECLICKACTION'), JPATH_ADMINISTRATOR, 'en-GB', TRUE); // should be plg_oneclickaction // Joomla 1.5 plugins if ($ext->type == 'plugin') { $plg = 'plg_' . $ext->folder . '_' . $ext->element; $lang->load(strtolower($plg), JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($plg), JPATH_ADMINISTRATOR, 'en-GB', TRUE); } if ($ext->type == 'template') { $plg = 'tpl_' . $ext->name; $lang->load(strtolower($plg), JPATH_SITE, 'en-GB', TRUE); $lang->load(strtolower($plg), JPATH_ADMINISTRATOR, 'en-GB', TRUE); } } // ok now we have the extensions - get the xml for further offline crunching foreach ($installedExtensions as $k => $ext) { // remove not supported types :-( if ($ext->type == 'file' || $ext->type == 'package') { unset($installedExtensions[$k]); continue; } $ext->xmlFile = $this->findManifest($ext); try { if ($ext->xmlFile !== FALSE) { $parts = explode('/', $ext->xmlFile); array_pop($parts); $ext->path = implode('/', $parts); bfLog::log('Loading XML file = ' . str_replace(JPATH_BASE, '', $ext->xmlFile)); $xml = trim(file_get_contents($ext->xmlFile)); $myXML = new SimpleXMLElement($xml); if (property_exists($myXML, 'description')) { $ext->desc = $myXML->description; } $ext->xmlFileContents = base64_encode(gzcompress($xml)); $ext->xmlFileCreated = filemtime($ext->xmlFile); } else { $ext->MANIFESTERROR = TRUE; } } catch (Exception $e) { bfLog::log('EXCEPTION = ' . $ext->xmlFile . ' ' . $e->getMessage()); die('Could not process XML file at: ' . str_replace(JPATH_BASE, '', $ext->xmlFile)); } $ext->name = JText::_($ext->name); $ext->title = JText::_($ext->title); $ext->desc = base64_encode(gzcompress(JText::_($ext->desc))); // remove base paths - we dont want to leak data :) $ext->xmlFile = $this->removeBase($ext->xmlFile); $ext->path = $this->removeBase($ext->path); // Sort so its pretty - not that anyone sees, but debugging is easier $ext = (array) $ext; ksort($ext); // push to the result $installedExtensions[$k] = $ext; } return json_encode($installedExtensions); }
function expcsv(array $ids) { global $ff_config; $csvdelimiter = stripslashes($ff_config->csvdelimiter); $csvquote = stripslashes($ff_config->csvquote); $cellnewline = $ff_config->cellnewline == 0 ? "\n" : "\\n"; $fields = array(); $lines = array(); $ids = implode(',', $ids); $this->db->setQuery( "select * from #__facileforms_records where id in ($ids) order by submitted Desc" ); $recs = $this->db->loadObjectList(); $recsSize = count($recs); for($r = 0; $r < $recsSize; $r++) { $rec = $recs[$r]; $lineNum = count($lines); $fields['ZZZ_A_ID'] = true; $fields['ZZZ_B_SUBMITTED'] = true; $fields['ZZZ_C_USER_ID'] = true; $fields['ZZZ_D_USERNAME'] = true; $fields['ZZZ_E_USER_FULL_NAME'] = true; $fields['ZZZ_F_TITLE'] = true; $fields['ZZZ_G_IP'] = true; $fields['ZZZ_H_BROWSER'] = true; $fields['ZZZ_I_OPSYS'] = true; $fields['ZZZ_J_TRANSACTION_ID'] = true; $fields['ZZZ_K_DATE'] = true; $fields['ZZZ_L_TEST_ACCOUNT'] = true; $fields['ZZZ_M_DOWNLOAD_TRIES'] = true; $lines[$lineNum]['ZZZ_A_ID'][] = $rec->id; $lines[$lineNum]['ZZZ_B_SUBMITTED'][] = $rec->submitted; $lines[$lineNum]['ZZZ_C_USER_ID'][] = $rec->user_id; $lines[$lineNum]['ZZZ_D_USERNAME'][] = $rec->username; $lines[$lineNum]['ZZZ_E_USER_FULL_NAME'][] = $rec->user_full_name; $lines[$lineNum]['ZZZ_F_TITLE'][] = $rec->title; $lines[$lineNum]['ZZZ_G_IP'][] = $rec->ip; $lines[$lineNum]['ZZZ_H_BROWSER'][] = $rec->browser; $lines[$lineNum]['ZZZ_I_OPSYS'][] = $rec->opsys; $lines[$lineNum]['ZZZ_J_TRANSACTION_ID'][] = $rec->paypal_tx_id; $lines[$lineNum]['ZZZ_K_DATE'][] = $rec->paypal_payment_date; $lines[$lineNum]['ZZZ_L_TEST_ACCOUNT'][] = $rec->paypal_testaccount; $lines[$lineNum]['ZZZ_M_DOWNLOAD_TRIES'][] = $rec->paypal_download_tries; $rec = $recs[$r]; $this->db->setQuery( "select Distinct * from #__facileforms_subrecords where record = $rec->id order by id" ); $subs = $this->db->loadObjectList(); $subsSize = count($subs); for($s = 0; $s < $subsSize; $s++) { $sub = $subs[$s]; if($sub->name != 'bfFakeName' && $sub->name != 'bfFakeName2' && $sub->name != 'bfFakeName3' && $sub->name != 'bfFakeName4'){ if(!isset($fields[strtoupper($sub->name)])) { $fields[strtoupper($sub->name)] = true; } $lines[$lineNum][strtoupper($sub->name)][] = $sub->value; } } } $head = ''; ksort($fields); $lineLength = count($lines); foreach($fields As $fieldName => $null) { $head .= $csvquote.$fieldName.$csvquote.$csvdelimiter; for($i = 0; $i < $lineLength;$i++) { if(!isset($lines[$i][$fieldName])) { $lines[$i][$fieldName] = array(); } } } $head = substr($head,0,strlen($head)-1) . nl(); $out = ''; for($i = 0; $i < $lineLength;$i++) { ksort($lines[$i]); foreach($lines[$i] As $line){ $out .= $csvquote.str_replace($csvquote,$csvquote.$csvquote,str_replace("\n",$cellnewline,str_replace("\r","",implode('|',$line)))).$csvquote.$csvdelimiter; } $out = substr($out,0,strlen($out)-1); $out .= nl(); } $csvname = JPATH_SITE.'/components/com_breezingforms/exports/ffexport-'.date('YmdHis').'.csv'; JFile::makeSafe($csvname); if (!JFile::write($csvname,$head.$out)) { echo "<script> alert('".addslashes(BFText::_('COM_BREEZINGFORMS_RECORDS_XMLNORWRTBL'))."'); window.history.go(-1);</script>\n"; exit(); } // if $this->db->setQuery( "update #__facileforms_records set exported=1 where id in ($ids)" ); $this->db->query(); /* $data = JFile::read($csvname); $files[] = array('name' => basename($csvname), 'data' => $data); $zip = JArchive::getAdapter('zip'); $path = JPATH_SITE.'/components/com_breezingforms/exports/ffexport-csv-'.date('YmdHis').'.zip'; $zip->create($path, $files); JFile::delete($csvname); */ @ob_end_clean(); $_size = filesize($csvname); $_name = basename($csvname); @ini_set("zlib.output_compression", "Off"); Header("Content-Type: text/comma-separated-values; charset=utf-8"); Header("Content-Disposition: attachment;filename=\"$_name\""); Header("Content-Transfer-Encoding: 8bit"); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: private"); //header("Content-Type: application/octet-stream"); //header("Content-Disposition: attachment; filename=$_name"); //header("Accept-Ranges: bytes"); //header("Content-Length: $_size"); ob_start(); readfile($csvname); $c = ob_get_contents(); ob_end_clean(); if(function_exists('mb_convert_encoding')){ echo chr(255).chr(254).mb_convert_encoding( $c, 'UTF-16LE', 'UTF-8'); } else { echo $c; } exit; }
public function modifyInternalUrls() { $query = 'SELECT * from #__akrecipes_recipe order by id '; $query_set = $this->dbo->setQuery($query); }
/** * Custom doExecute method. * * This method loads a list of the published plugins from the 'cron' group, * then loads the plugins and registers them against the 'doCron' event. * The event is then triggered and results logged. * * Any configuration for the cron plugins is done via the Joomla CMS * administrator interface and plugin parameters. * * @return void * * @since 11.3 */ public function doExecute() { // // Check we have some critical information. // if (!defined('JPATH_PLUGINS') || !is_dir(JPATH_PLUGINS)) { throw new Exception('JPATH_PLUGINS not defined'); } // Add a start message. JLog::add('Starting cron run.'); // // Prepare the plugins // // Get the quey builder class from the database. $query = $this->dbo->getQuery(true); // Get a list of the plugins from the database. $query->select('p.*')->from('#__extensions AS p')->where('p.enabled = 1')->where('p.type = ' . $this->dbo->quote('plugin'))->where('p.folder = ' . $this->dbo->quote('cron'))->order('p.ordering'); // Push the query builder object into the database connector. $this->dbo->setQuery($query); // Get all the returned rows from the query as an array of objects. $plugins = $this->dbo->loadObjectList(); // Log how many plugins were loaded from the database. JLog::add(sprintf('.loaded %d plugin(s).', count($plugins))); // Loop through each of the results from the database query. foreach ($plugins as $plugin) { // Build the class name of the plugin. $className = 'plg' . ucfirst($plugin->folder) . ucfirst($plugin->element); $element = preg_replace('#[^A-Z0-9-~_]#i', '', $plugin->element); // If the class doesn't already exist, try to load it. if (!class_exists($className)) { // Compute the path to the plugin file. $path = sprintf(rtrim(JPATH_PLUGINS, '\\/') . '/cron/%s/%s.php', $element, $element); // Check if the file exists. if (is_file($path)) { // Include the file. include $path; // Double check if we have a valid class. if (!class_exists($className)) { // Log a warning and contine to the next record. JLog::add(sprintf('..plugin class for `%s` not found in file.', $element), JLog::WARNING); continue; } } else { // Log a warning and contine to the next record. JLog::add(sprintf('..plugin file for `%s` not found.', $element), JLog::WARNING); continue; } } JLog::add(sprintf('..registering `%s` plugin.', $element)); // Register the event. $this->registerEvent('doCron', new $className($this->dispatcher, array('params' => new JRegistry($plugin->params)))); } // // Run the cron plugins. // // Each plugin should have been installed in the Joomla CMS site // and must include a 'doCron' method. Configuration of the plugin // is done via plugin parameters. // JLog::add('.triggering `doCron` event.'); // Trigger the event and let the Joomla plugins do all the work. $results = $this->triggerEvent('doCron'); // Log the results. foreach ($this->triggerEvent('doCron') as $result) { JLog::add(sprintf('..plugin returned `%s`.', var_export($result, true))); } JLog::add('Finished cron run.'); }
/** * Sets the SQL query string for later execution. * * This function replaces a string identifier $prefix with the * string held is the $this->getPrefix() class variable. * * @param string $sql The SQL query (casted to (string) ) * @param int $offset The offset to start selection * @param int $limit The number of results to return * @param string $prefix The common table prefix search for replacement string */ function setQuery($sql, $offset = 0, $limit = 0, $prefix = '#__') { $sql = (string) $sql; if (in_array(checkJversion('product'), array('Mambo', 'Elxis', 'MiaCMS'))) { if ($offset || $limit) { $sql .= " LIMIT "; if ($offset) { $sql .= (int) abs($offset) . ', '; } $sql .= (int) abs($limit); } $this->_db->setQuery($sql, $prefix); } else { $this->_db->setQuery($sql, (int) abs($offset), (int) abs($limit), $prefix); } }
public function unpublishItem(){ $this->db->setQuery("Update #__facileforms_integrator_items Set published = 0 Where id = ".JRequest::getInt('publish_id',-1).""); $this->db->query(); }
/** * Sets the SQL query string for later execution. * * This function replaces a string identifier $prefix with the * string held is the $this->getPrefix() class variable. * * @param string $sql The SQL query (casted to (string) ) * @param int $offset The offset to start selection * @param int $limit The number of results to return * @return self For chaining */ public function setQuery($sql, $offset = 0, $limit = 0) { $this->_db->setQuery((string) $sql, (int) abs($offset), (int) abs($limit)); return $this; }
/** * Execute a query to the database and get an array of the result set rows from the database query where each row is an associative array * * The result returned by this method is the same as the one returned by JDatabase::loadAssocList() * Generally used for SELECT operations * * @param string $query The query to be executed * @param string $key The name of a field on which to key the result array * * @return array The results of the query * * @throws RuntimeException * * @since 1.0.0 */ public function queryAssocList($query, $key = '') { // query database table $this->_database->setQuery($query); return $this->_database->loadAssocList($key); }
public function getRows($class = null) { // get the subset (based on limits) of records $query = 'SELECT *' . ' FROM #__acctexp_' . $this->table . $this->getConstraints() . $this->getOrdering() . $this->getLimit(); $this->db->setQuery($query); $rows = $this->db->loadObjectList(); if ($this->db->getErrorNum()) { echo $this->db->stderr(); return false; } if ($class) { foreach ($rows as $k => $obj) { $rows[$k] = new $class(); $rows[$k]->load($obj->id); } } return $rows; }
function sortearEliminatoria(array $equipos, $numRows_eq, JDatabase $db_ins_part, $id_grupo, JDatabase $db_ins_jor) { $cantidad_equipos = $numRows_eq; $cantidad_partidos = $cantidad_equipos - 1; $cantidad_jornadas = ceil(log($cantidad_equipos, 2)); $preliminares = $cantidad_equipos - pow(2, floor(log($cantidad_equipos, 2))); $standby = $cantidad_equipos - $preliminares * 2; $partidos_potencia2 = $cantidad_equipos / 2; $partidos_ronda2 = ($standby + $preliminares) / 2; // echo "Equipos:".$cantidad_equipos."<br>"; // echo "Partidos:".$cantidad_partidos."<br>"; // echo "Jornadas:".$cantidad_jornadas."<br>"; // echo "Preliminares:".$preliminares."<br>"; // echo "Espera:".$standby."<br>"; // echo "Partidos potencia 2: ".$partidos_potencia2."<br>"; // echo "Partidos ronda 2: ".$partidos_ronda2."<br>"; $partidos = array(); $equipos_partido = array(); $nombre_jornadas = array('Final', 'Semifinal', 'Cuartos de Final', 'Octavos de Final', 'Primera Ronda', 'Preliminares'); $x = 0; // $y=0; // $y=$cantidad_equipos-1; $y = $preliminares * 2 - 1; //Insertar primer jornada for ($i = 0; $i < $cantidad_jornadas; $i++) { if ($preliminares == 0) { switch ($i) { case 0: $descr_jor = $nombre_jornadas[$i]; case 1: $descr_jor = $nombre_jornadas[$i]; case 2: $descr_jor = $nombre_jornadas[$i]; case 3: $descr_jor = $nombre_jornadas[$i]; case 4: $descr_jor = $nombre_jornadas[$i]; case 5: $descr_jor = $nombre_jornadas[$i]; } } else { switch ($i) { case 0: $descr_jor = $nombre_jornadas[$i]; case 1: $descr_jor = $nombre_jornadas[$i]; case 2: $descr_jor = $nombre_jornadas[$i]; case 3: $descr_jor = $nombre_jornadas[$i]; case 4: $descr_jor = $nombre_jornadas[$i]; case 5: $descr_jor = $nombre_jornadas[$i]; } } try { $query_ins_jor = $db_ins_jor->getQuery(true); $columns = array('descripcion', 'id_grupo', 'numero'); $values = array($db_ins_jor->quote($descr_jor), $id_grupo, $i + 1); $query_ins_jor->insert($db_ins_jor->quoteName('jornada'))->columns($db_ins_jor->quoteName($columns))->values(implode(',', $values)); $db_ins_jor->setQuery($query_ins_jor); $db_ins_jor->execute(); $id_jornada = $db_ins_jor->insertid(); } catch (Exception $e) { echo $e; } if ($preliminares != 0) { $partidos_ronda = pow(2, $i); if ($i == $cantidad_jornadas - 1) { $partidos_ronda = $preliminares; } for ($j = 0; $j < $partidos_ronda; $j++) { if ($i == $cantidad_jornadas - 1) { $equipos_partido[0] = $equipos[$x]; $equipos_partido[1] = $equipos[$x + 1]; $partidos[$j] = $equipos_partido; try { $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_torneo', 'id_jornada'); // Insert values. $values = array($_SESSION['id_torneo'], $id_jornada); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); $id_partido = $db_ins_part->insertid(); $equipos_p = $partidos[$j]; $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_equipo1', 'id_equipo2', 'id_partido'); // Insert values. $values = array($equipos_p[0]->id_eq, $equipos_p[1]->id_eq, $id_partido); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido_equipos'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); } catch (Exception $e) { echo $e; } $x++; $x++; } elseif ($i == $cantidad_jornadas - 2) { $dividido = ceil($preliminares / 2); $equipos_partido[0] = $equipos[$y]; if (isset($equipos[$y + 1])) { $equipos_partido[1] = $equipos[$y + 1]; } $partidos[$j] = $equipos_partido; if ($preliminares % 2 == 0) { if ($j < $dividido) { $equipos_partido[0] = 26; $equipos_partido[1] = 26; $partidos[$j] = $equipos_partido; } } else { if ($j < $dividido) { if ($j == $dividido - 1) { $equipos_partido[0] = 26; $equipos_partido[1] = $equipos[$y + 1]; $partidos[$j] = $equipos_partido; } elseif ($j < $dividido - 1) { $equipos_partido[0] = 26; $equipos_partido[1] = 26; $partidos[$j] = $equipos_partido; } } } try { $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_torneo', 'id_jornada'); // Insert values. $values = array($_SESSION['id_torneo'], $id_jornada); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); $id_partido = $db_ins_part->insertid(); $equipos_p = $partidos[$j]; $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_equipo1', 'id_equipo2', 'id_partido'); // Insert values. if ($j < $dividido) { if ($preliminares % 2 == 0) { $values = array($equipos_p[0], $equipos_p[1], $id_partido); } else { if ($j == $dividido - 1) { $values = array($equipos_p[0], $equipos_p[1]->id_eq, $id_partido); } else { $values = array($equipos_p[0], $equipos_p[1], $id_partido); } } } elseif ($j >= $dividido) { $values = array($equipos_p[0]->id_eq, $equipos_p[1]->id_eq, $id_partido); } // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido_equipos'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); } catch (Exception $e) { echo $e; } $y++; $y++; } else { try { $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_torneo', 'id_jornada'); // Insert values. $values = array($_SESSION['id_torneo'], $id_jornada); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); $id_partido = $db_ins_part->insertid(); // $equipos_p = $partidos[$j]; $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_equipo1', 'id_equipo2', 'id_partido'); // Insert values. $values = array(26, 26, $id_partido); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido_equipos'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); } catch (Exception $e) { echo $e; } } } } else { $partidos_ronda = pow(2, $i); for ($j = 0; $j < $partidos_ronda; $j++) { if ($i == $cantidad_jornadas - 1) { $equipos_partido[0] = $equipos[$x]; $equipos_partido[1] = $equipos[$x + 1]; $partidos[$j] = $equipos_partido; try { $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_torneo', 'id_jornada'); // Insert values. $values = array($_SESSION['id_torneo'], $id_jornada); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); $id_partido = $db_ins_part->insertid(); $equipos_p = $partidos[$j]; $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_equipo1', 'id_equipo2', 'id_partido'); // Insert values. $values = array($equipos_p[0]->id_eq, $equipos_p[1]->id_eq, $id_partido); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido_equipos'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); } catch (Exception $e) { echo $e; } $x++; $x++; } else { try { $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_torneo', 'id_jornada'); // Insert values. $values = array($_SESSION['id_torneo'], $id_jornada); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); $id_partido = $db_ins_part->insertid(); // $equipos_p = $partidos[$j]; $query_ins_part = $db_ins_part->getQuery(true); // Insert columns. $columns = array('id_equipo1', 'id_equipo2', 'id_partido'); // Insert values. $values = array(26, 26, $id_partido); // Prepare the insert query. $query_ins_part->insert($db_ins_part->quoteName('partido_equipos'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values)); // Set the query using our newly populated query object and execute it. $db_ins_part->setQuery($query_ins_part); $db_ins_part->execute(); } catch (Exception $e) { echo $e; } } } } } }