public static function search(Database $dbObj, array $criteria) { if (is_array($criteria) && count($criteria)) { $retval = array(); $sql = "SELECT c.*, ca.campaign_name FROM " . Character::tableName . " AS c\n\t\t\t\tLEFT OUTER JOIN " . Campaign::tableName . " AS ca \n\t\t\t\tUSING (campaign_id)\n\t\t\t\tWHERE \n\t\t\t\t(LOWER(c.character_name) LIKE :character_name OR :character_name IS NULL)\n\t\t\t\tAND \n\t\t\t\t(LOWER(ca.campaign_name) LIKE :campaign_name OR :campaign_name IS NULL)\t\n\t\t\tAND\n\t\t\t\t(c.campaign_id IS NULL)\n\t\t\t\tORDER BY c.character_name, ca.campaign_name"; //Note that the campaign_id IS NULL part is arbitrary... if (!isset($criteria['character_name'])) { $criteria['character_name'] = null; } else { $criteria['character_name'] .= '%'; } if (!isset($criteria['campaign_name'])) { $criteria['campaign_name'] = null; } else { $criteria['campaign_name'] .= '%'; } // if(!isset($criteria['campaign'])) try { $numRows = $dbObj->run_query($sql, $criteria); if ($numRows > 0) { $retval = $dbObj->farray_fieldnames(Character::pkeyField); } } catch (Exception $e) { cs_debug_backtrace(1); throw new exception(__METHOD__ . ": error while running search::: " . $e->getMessage()); } } else { throw new exception(__METHOD__ . ": invalid or empty search criteria"); } return $retval; }
public function mkdir($name, $mode = 0777) { if (isset($mode)) { $mode = intval($mode); } $retval = NULL; if (!is_null($name) && strlen($name)) { $name = $this->filename2absolute($name); if ($this->check_chroot($name)) { $retval = mkdir($name, $mode); chmod($name, $mode); } else { throw new exception(__METHOD__ . ': (' . $name . ') isn\'t within chroot'); } } else { cs_debug_backtrace(1); throw new exception(__METHOD__ . ': invalid data: (' . $name . ')'); } return $retval; }
/** * @codeCoverageIgnore */ protected function flogger($msg) { $msg = strip_tags($msg); if (!is_object($this->fsObj)) { $this->fsObj = new cs_fileSystem(constant('RWDIR')); $this->fsObj->openFile('sessionDebug.log', 'a'); } try { $fullBt = debug_backtrace(); $bt = $fullBt[1]; @($method = $bt['method']); $class = $bt['class']; $file = $bt['file']; if (!isset($bt['method'])) { @($method = $fullBt[0]['method']); $class = $fullBt[0]['class']; $file = $fullBt[0]['file']; } $msg = '[' . DBSession::$runDate . '] ' . cs_get_where_called() . " -- " . $msg; $msg .= "\n-----------------------\n" . strip_tags(cs_debug_backtrace(0)); $msg .= "\n====================================\n"; $this->fsObj->append_to_file($msg); } catch (Exception $e) { //nothing can be done at this point... ugh. } }