/** * Run the (un)zip command. * * @param int $type The type of zip (ATK_ZIP or ATK_UNZIP) * @param string $params The parameters for zipping or unzipping * * @return string The return code */ public function runInfozipCommand($type, $params) { $command = $this->getInfozipCommand($type, $params); $output = []; Tools::atkdebug("atkZip->runInfozipCommand: Executing command: {$command}"); $returncode = null; //var for catching returncode fro exec. exec($command, $output, $returncode); Tools::atkdebug('atkZip->runInfozipCommand: Return code was: ' . $returncode); Tools::atk_var_dump($output, 'atkZip->runInfozipCommand: Console output'); return $returncode; }
/** * Delete a row in the session for a given ATK/SQL selector. * * @param string $selector ATK/SQL selector * * @return bool Wether the deleting succeeded */ public function deleteDataRowForSelector($selector) { Tools::atk_var_dump($selector, __CLASS__ . '->' . __METHOD__ . ': Deleting row from session store with key: ' . $this->getKey()); $data = $this->getData(); if (!$data) { return false; } $row_key = self::getRowKeyFromSelector($selector); if (!self::isValidRowKey($row_key, $data)) { return false; } unset($data[$row_key]); $this->setData($data); return true; }
/** * Load search criteria. * * @param string $name name of the search criteria * * @return array search criteria */ public function loadCriteria($name) { if (!$this->tableExist()) { return []; } $db = $this->m_node->getDb(); $query = "SELECT c.criteria FROM {$this->m_table} c WHERE c.nodetype = '%s' AND UPPER(c.name) = UPPER('%s') AND handlertype = '%s'"; Tools::atk_var_dump(sprintf($query, $this->m_node->atkNodeUri(), Tools::escapeSQL($name), $this->getSearchHandlerType()), 'loadCriteria query'); list($row) = $db->getRows(sprintf($query, $this->m_node->atkNodeUri(), Tools::escapeSQL($name), $this->getSearchHandlerType())); $criteria = $row == null ? null : unserialize($row['criteria']); Tools::atk_var_dump($criteria, 'loadCriteria criteria'); return $criteria; }
/** * Parse data into the string and return all fields as an array. * * @param array $data * @param bool $split_tags_and_fields return fields and separators separated in resultarray (separators are not used in query, so quotes aren't used) * * @return array */ public function getAllParsedFieldsAsArray($data, $split_tags_and_fields = false) { $matches = $this->getAllFieldsAsArray(); Tools::atk_var_dump($matches, 'MATCHES' . ($split_tags_and_fields ? ' (split tags and separators)' : '')); $fields = []; if (is_array($matches)) { foreach ($matches[0] as $match) { // Check if need to parse the match if (strpos($match, '[') !== false && strpos($match, ']') !== false) { $parser = new self($match); if ($split_tags_and_fields) { $fields['tags'][] = $parser->parse($data); } else { $fields[] = $parser->parse($data); } } else { if ($split_tags_and_fields) { $fields['separators'][] = $match; } else { $fields[] = "'" . $match . "'"; } } } } return $fields; }
/** * Dump variable to debug output. * * Usage: {$sometplvar|atkvardump:label} * * @author Boy Baukema <*****@*****.**> * * @param mixed $data * @param string $name Label for the dump * * @return string */ function smarty_modifier_atkvardump($data, $name = '') { Tools::atk_var_dump($data, $name); return $data; }
/** * Creates a smart search condition for a given search value, and adds it * to the query that will be used for performing the actual search. * * @param int $id The unique smart search criterium identifier. * @param int $nr The element number in the path. * @param array $path The remaining attribute path. * @param Query $query The query to which the condition will be added. * @param string $ownerAlias The owner table alias to use. * @param mixed $value The value the user has entered in the searchbox. * @param string $mode The searchmode to use. */ public function smartSearchCondition($id, $nr, $path, $query, $ownerAlias, $value, $mode) { // default implementation doesn't supported nested paths, this method // should be overriden by relations etc. if they want to support this if (count($path) > 0) { Tools::atk_var_dump($path, 'Invalid search path for ' . $this->m_ownerInstance->atkNodeUri() . '#' . $this->fieldName() . ', ignoring criterium!'); } else { $this->searchCondition($query, $ownerAlias, $value, $mode); } }
/** * This function overrides the deleteDb function to delete a file * from the selected directory. * * @param string $selector The identifier of the file that should be deleted * * @return bool The result of the file deletion */ public function deleteDb($selector) { $sessmngr = SessionManager::getInstance(); $this->m_dir = $this->stripDir($sessmngr->stackVar('dirname')); $decodedselector = Tools::decodeKeyValuePair($selector); $filename = $decodedselector['dummy.filename']; Tools::atk_var_dump($this->m_dir, 'm_dir'); Tools::atk_var_dump($filename, 'filename'); if (strpos($filename, '..') === false) { unlink($this->m_dir . $filename); Tools::atkdebug('Deleted ' . $this->m_dir . $filename); } else { Tools::atkerror('Cannot unlink relative files. Possible hack attempt detected!'); } return true; }