function _do_mkdir($dir, $perm) { if(is_dir($dir)) return true; if(fs :: _has_win32_net_prefix($dir)) { debug :: write_notice('win32 net path - cant check if it exists', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('dir' => $dir)); return true; } $oldumask = umask(0); if(!mkdir($dir, $perm)) { umask($oldumask); debug :: write_error('failed to create directory', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('dir' => $dir)); return false; } umask($oldumask); return true; }
function error_handler($errno, $errstr, $errfile, $errline) { if (error_reporting() == 0) { // error-control operator is used return; } if (!debug::is_debug_enabled()) { return; } $str = "{$errstr} in {$errfile} on line {$errline}"; $errnames =& $GLOBALS['DEBUG_PHP_ERROR_NAMES']; if (!is_array($errnames)) { $errnames = array(E_ERROR => 'E_ERROR', E_PARSE => 'E_PARSE', E_CORE_ERROR => 'E_CORE_ERROR', E_COMPILE_ERROR => 'E_COMPILE_ERROR', E_USER_ERROR => 'E_USER_ERROR', E_WARNING => 'E_WARNING', E_CORE_WARNING => 'E_CORE_WARNING', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_USER_WARNING => 'E_USER_WARNING', E_NOTICE => 'E_NOTICE', E_USER_NOTICE => 'E_USER_NOTICE'); } $errname = 'unknown'; if (isset($errnames[$errno])) { $errname = $errnames[$errno]; } switch ($errno) { case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: debug::write_error($str, 'PHP'); break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: debug::write_warning($str, 'PHP'); break; case E_USER_NOTICE: case E_NOTICE: debug::write_notice($str, 'PHP'); break; } }
function group($block_name) { if (isset($this->block_values[$block_name])) { return $this->block_values[$block_name]; } debug::write_notice('unknown block', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('ini' => $this->file_name, 'block_name' => $block_name)); return null; }
function get_group($group_name) { if (isset($this->group_values[$group_name])) return $this->group_values[$group_name]; debug::write_notice('undefined group', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('ini' => $this->file_path, 'group' => $group_name ) ); return null; }
function &_get_ini($with_variation = false, $directory = '') { $type = $with_variation ? 'variation' : 'default'; $country = $this->get_country_code(); $country_variation = $this->get_country_variation(); $language = $this->get_language_code(); $locale = $language; if ($country !== '') { $locale .= '-' . $country; } if ($with_variation) { if ($country_variation !== '') { $locale .= '@' . $country_variation; } } $file_name = $locale . '.ini'; if (locale::is_debug_enabled()) { debug::write_notice("Requesting {$file_name}", 'locale :: _get_locale_ini'); } if (ini::exists($file_name, $directory)) { return ini::instance($file_name, $directory); } else { return null; } }
/** * Creates a new root node. If no id is specified then it is either * added to the beginning/end of the tree based on the $pos. * Optionally it deletes the whole tree and creates one initial rootnode * * <pre> * +-- root1 [target] * | * +-- root2 [new] * | * +-- root3 * </pre> * * @param array $values Hash with param => value pairs of the node (see $this->_params) * @param integer $id ID of target node (the rootnode after which the node should be inserted) * @param bool $first Danger: Deletes and (re)init's the hole tree - sequences are reset * @param string $pos The position in which to insert the new node. * @access public * @return mixed The node id or false on error */ function create_root_node($values, $id = false, $first = false, $pos = NESE_MOVE_AFTER) { $this->_verify_user_values($values); // If they specified an id, see if the parent is valid if (!$first && ($id && !($parent = $this->get_node($id)))) { debug::write_error(NESE_ERROR_NOT_FOUND, __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('id' => $id)); return false; } elseif ($first && $id) { debug::write_notice('these 2 params don\'t make sense together', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('first' => $first, 'id' => $id)); } elseif (!$first && !$id) { // If no id was specified, then determine order $parent = array(); if ($pos == NESE_MOVE_BEFORE) { $parent['ordr'] = 1; } elseif ($pos == NESE_MOVE_AFTER) { // Put it at the end of the tree $qry = sprintf('SELECT MAX(ordr) as m FROM %s WHERE l=1', $this->_node_table); $this->_db->sql_exec($qry); $tmp_order = $this->_db->fetch_row(); // If null, then it's the first one $parent['ordr'] = isset($tmp_order['m']) ? $tmp_order['m'] : 0; } } // Try to aquire a table lock $lock = $this->_set_lock(); $sql = array(); $insert_data = array(); $insert_data['level'] = 1; // Shall we delete the existing tree (reinit) if ($first) { $this->_db->sql_delete($this->_node_table); $insert_data['ordr'] = 1; } else { // Let's open a gap for the new node if ($pos == NESE_MOVE_AFTER) { $insert_data['ordr'] = $parent['ordr'] + 1; $sql[] = sprintf('UPDATE %s SET ordr=ordr+1 WHERE l=1 AND ordr > %s', $this->_node_table, $parent['ordr']); } elseif ($pos == NESE_MOVE_BEFORE) { $insert_data['ordr'] = $parent['ordr']; $sql[] = sprintf('UPDATE %s SET ordr=ordr+1 WHERE l=1 AND ordr >= %s', $this->_node_table, $parent['ordr']); } } $insert_data['parent_id'] = 0; // Sequence of node id (equals to root id in this case if (!$this->_dumb_mode || !isset($values['id']) || !isset($values['root_id'])) { $insert_data['root_id'] = $insert_data['id'] = $node_id = $this->_db->get_max_column_value($this->_node_table, 'id') + 1; } else { $node_id = $values['id']; } // Left/Right values for rootnodes $insert_data['l'] = 1; $insert_data['r'] = 2; // Transform the node data hash to a sql_exec if (!($qr = $this->_values2insert_query($values, $insert_data))) { $this->_release_lock(); return false; } // Insert the new node $sql[] = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->_node_table, implode(', ', array_keys($qr)), implode(', ', $qr)); foreach ($sql as $qry) { $this->_db->sql_exec($qry); } $this->_release_lock(); return $node_id; }
/** * Write the given data in the cache file * * @param string $data data to put in cache * @return boolean true if ok * @access private */ function _write($data) { $fp = @fopen($this->_file, "w"); if ($fp) { if ($this->_file_locking) { @flock($fp, LOCK_EX); } if ($this->_read_control) { @fwrite($fp, $this->_hash($data, $this->_read_control_type), 32); } $len = strlen($data); @fwrite($fp, $data, $len); if ($this->_file_locking) { @flock($fp, LOCK_UN); } @fclose($fp); if ($this->_file_last_modified > -1) { @touch($this->_file, $this->_file_last_modified); } if ($this->is_debug_enabled()) { debug::write_notice("cache '{$this->_id}' group '{$this->_group}' written", 'cache_lite::_write()'); } return true; } debug::write_error('Unable to write cache !', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $this->_file)); }