/** * Check for complex potions that include table definitions. */ function verifyPotions() { require_once WIKI_CLASSES . 'WikiPotion.php'; // Loop all enabled potions. $conf = VoodooIni::load('wiki'); $tables = array(); foreach ($conf['potions'] as $p => $enabled) { // If the potion is not enabled, we do not care for it. if (!$enabled) { continue; } $name = WikiPotionHandler::requirePotion($p); if (!$name) { continue; } if (!class_exists($name . 'Setup')) { continue; } $class = $name . 'Setup'; $s = new $class($this); // Merge the output with the already set tables. $tables = array_merge($tables, $s->getTables()); } return $tables; }
function SheetDispatcher(&$controller) { $this->controller =& $controller; $this->privs = new VoodooPrivileges($controller); $this->conf = VoodooIni::load('sheetgen'); $this->sheet = new Sheet($this->controller->db); }
/** * @param string $dispatcher * @param array $actionlist * @param string $content * @return string $content */ function attachmentList($dispatcher, $actionlist, $content) { $conf = VoodooIni::load($dispatcher); if (!isset($conf['attachment']) || !$conf['attachment']['attachment']) { return $content; } $content = str_replace('<!-- ATTACHMENTS -->', $this->getAttachments($dispatcher, $actionlist[0]), $content); return $content; }
function _configure() { $conf = VoodooIni::load('sheetgen'); $conf = $conf['diceroller']; $this->use_sheet_characters = $conf['use_sheet_characters']; $this->allow_any_character = $conf['allow_any_character']; $this->mutually_exclusive = $conf['mutually_exclusive']; $this->variable_difficulty = $conf['variable_difficulty']; $this->default_difficulty = $conf['default_difficulty']; }
function init() { $t = VoodooTemplate::getInstance(); $old = $t->getDir(); $t->setDir(SHEETGEN_TEMPLATES); $args = array('prepath' => PATH_TO_DOCROOT); $conf = VoodooIni::load('sheetgen'); $args['sheets'] = $conf['sheets']; $this->display = $t->parse('index', $args); $t->template_dir = $old; }
/** * @return string */ function init() { $rv = ''; // Parse ini $opts = VoodooIni::load('wiki'); foreach ($opts['potions'] as $potion => $enabled) { if ($enabled) { // The potion is enabled, list it. $rv .= '<h4>' . $potion . '</h4>'; } } return $this->display = $rv; }
function init() { $conf = VoodooIni::load('sheetgen'); $this->_map = $conf['sheets']; $sql = "SELECT COUNT(SHEET_ID) as cnt FROM TBL_SHEET_USER"; $q = $this->formatter->db->query($sql); $q->execute(); $r = $q->fetch(); $total = $r->cnt; $sql = "SELECT SHEET_TYPE as Game, COUNT(SHEET_ID) as `Absolute`, COUNT(SHEET_ID) as `Share`, " . $total . " as Total FROM TBL_SHEET_USER GROUP BY SHEET_TYPE ORDER BY `Share` DESC"; $q = $this->formatter->db->query($sql); $q->execute(); require_once CLASSES . 'TableFactory.php'; $tf = new TableFactory($q); $tf->setHiddenField('Total'); $tf->setValueProcessor(array('Game', 'Share'), array($this, 'tfValueProcessor')); $this->display = $tf->getXHTMLTable('list report', substr(md5('WikiMySheets'), 0, 5)); }
/** * Add a link table for every controller that has Attachments enabled * @param array $tables * @return array $tables */ function addLinkTables($tables) { // get the voodoo configuration for all available controllers $ini = VoodooIni::load('voodoo'); foreach ($ini['controllers'] as $controller => $enabled) { $class = 'AttachmentLink'; // Default object if (!$enabled) { // The Controller is not enabled, skip. continue; } $uc = strtoupper($controller); if (defined($uc . '_CLASSES')) { // If there is not a configuration file for the controller, we skip if (!is_file(constant($uc . '_CONF') . $controller . '.ini')) { continue; } $conf = VoodooIni::load($controller); // Attachments are not enabled for this controller, skip if (!isset($conf['attachment']) || !$conf['attachment']['attachment']) { continue; } // Hey, this controller has a seperate attachment link object, lets require it if (isset($conf['attachment']['class'])) { // heh, the class was defined in the ini, but doesnt exist. Skip. if (!is_file(constant($uc . '_CLASSES') . $conf['attachment']['class'])) { continue; } require_once constant($uc . '_CLASSES') . $conf['attachment']['class']; $class = ucfirst($controller) . 'Attachment'; } } // Use the abstract object functionality to parse the create tables $obj = new $class($this->db, $uc); if ($this->verifyTable($obj->getTable())) { $tables[] = $obj->generateCreateTables(); } } return $tables; }
/** * Delete the attachment * * Will also unlink the file if the second argument is true (default) * * @param int $id * @param bool $removefile * @return bool */ function delete($id = null, $removefile = true) { $id || ($id = $this->id); $this->isComplete() || $this->set($id); $conf = VoodooIni::load('attachment'); $file = PATH_TO_DOCROOT . $conf['settings']['upload_dir'] . '/' . $this->name; $removefile && unlink($file); $sql = "DELETE FROM TBL_ATTACHMENT WHERE ATTACHMENT_ID = ??"; $q = $this->db->query($sql); $q->bind_values($id); return $q->execute(); }
/** * @param array $actionlist */ function dispatch($actionlist) { require_once CLASSES . 'VoodooSetup.php'; if (!count($actionlist)) { // Dont do anything return $this->login(); } $args = array('prepath' => PATH_TO_DOCROOT); $showCredentials = (bool) $this->conf['setup']['insecure_sql_execution']; switch ($actionlist[0]) { // The first admin to be created is the God Admin case 'CreateAdmin': return $this->createAdmin(); break; case 'Login': return $this->login(); break; case 'conf': if (!$this->hasRights($_SESSION['access'], 'conf', 'view')) { return VoodooPrivileges::displayError('Permission Denied'); } $use_conf = ''; if (isset($_REQUEST['conf'])) { $use_conf = $_REQUEST['conf']; } $template =& VoodooTemplate::getInstance(); $template->setDir(ADMIN_TEMPLATES); $conf = VoodooIni::load('voodoo'); $vars = array('prepath' => PATH_TO_DOCROOT, 'controllers' => array()); foreach ($conf['controllers'] as $controller => $enabled) { $enabled && ($vars['controllers'][] = array('name' => $controller, 'selected' => $use_conf == $controller ? ' selected="selected" ' : '')); } if ($conf['controllers'][$use_conf]) { $vars['conf'] = $use_conf; $vars['configuration'] = VoodooIni::getContent($use_conf); if ($this->hasRights($_SESSION['access'], 'conf', 'modify')) { $vars['buttons'] = '<input type="submit" name="save" value="Save Configuration" />'; } } return array('Configuration files', $template->parse('conf.modify', $vars)); break; case 'Init': $complete = false; $cnames = array(); $controllers = $this->controller->voodooConf['controllers']; foreach ($controllers as $controller => $enabled) { $enabled && ($cnames[] = ucfirst($controller)); } if (!$showCredentials || !isset($_POST['dbcredentials'])) { $args['action'] = 'Init'; $template =& VoodooTemplate::getInstance(); $template->setDir(ADMIN_TEMPLATES); $output = ($showCredentials ? $template->parse('credentials', $args) : '') . '<strong>SQL Output</strong><pre class="MonospaceFormat">'; if (!$this->controller->voodooConf['engine']['site.setup']) { $obj = new VoodooSetup(false, $this->controller->conf); $obj->setup(); $output .= $obj->displaySQL(); } foreach ($cnames as $cname) { $output .= $this->controllerSetup($cname); } return array('SQL Output For VOODOO', $output . '</pre>'); } if (!$this->controller->voodooConf['engine']['site.setup']) { $obj = new VoodooSetup($_POST['dbcredentials'], $this->controller->conf); $complete || ($complete = $obj->setup()); } foreach ($cnames as $cname) { $this->controllerSetup($cname, $_POST['dbcredentials']); } header('Location: ' . PATH_TO_DOCROOT . ($complete ? '/' : '/setup/CreateAdmin')); exit; break; case 'Controller': if (count($actionlist) != 2) { exit('Incorrect Setup Of Controller'); } $cname = ucfirst(strtolower($actionlist[1])); if (!$showCredentials || !isset($_POST['dbcredentials'])) { $args['action'] = 'Init'; $template =& VoodooTemplate::getInstance(); $template->setDir(ADMIN_TEMPLATES); $output = ($showCredentials ? $template->parse('credentials', $args) : '') . '<strong>SQL Output</strong><pre class="MonospaceFormat">'; return array('SQL Output For ' . $cname, $output . $this->controllerSetup($cname) . '</pre>'); } $this->controllerSetup($cname, $_POST['dbcredentials']); header('Location: ' . PATH_TO_DOCROOT . '/'); exit; break; } }
/** * Contructor */ function DefaultController($complete = true, $formatter = null) { $this->conf = VoodooIni::load('engine'); $this->voodooConf = VoodooIni::load('voodoo'); $db = $this->DBConnect(); $this->addStyleSheet($this->voodooConf['engine']['site.style']); if ($complete) { $formatter || ($formatter = $this->voodooConf['engine']['site.formatter']); $this->setFormatter($db, $formatter); $this->initSession($db); } else { $this->setFormatter($db, 'VoodooFormatter'); } }
/** * @param array $actionlist * @return array(title,content) */ function dispatch($actionlist) { // Less than two params is NOT a valid attachment handler // Example of valids: // * /attachment/Wiki/WikiAttachmentExample // * /attachment/Wiki/WikiAttachmentExample/test.jpg if (count($actionlist) < 2) { return array('Attachment Error', VoodooError::displayError('Incorrect SubController Actionlist')); } // We default to not having an attachment set $attachment = false; if (count($actionlist) == 3) { // The third action from the actionlist is the attachment list($controller, $action, $attachment) = $actionlist; } else { list($controller, $action) = $actionlist; } $this->cont = $controller; $this->action = $action; $lookup = $controller . ($attachment ? '.' . $attachment : ''); // We need at least view rights to continue if (!$this->privs->hasRights($_SESSION['access'], 'view', 'attachment', $this->conf['privileges'], $lookup)) { return array('Attachment Error', VoodooError::displayError('Permission Denied')); } require_once ATTACHMENT_CLASSES . 'Attachment.php'; $class = 'AttachmentLink'; // The controller is enabled. $uc = strtoupper($controller); // Lets see if the linked object has its own linked attachment object if (defined($uc . '_CLASSES')) { $conf = VoodooIni::load($controller); if (!isset($conf['attachment']) || !$conf['attachment']['attachment']) { return array('Attachment Error', VoodooError::displayError('This Controller Doesnt Support Attachments')); } if (isset($conf['attachment']['class'])) { if (!is_file(constant($uc . '_CLASSES') . $conf['attachment']['class'])) { return array('Attachment Error', VoodooError::displayError('This Controller Attachment Class doesnt exist.')); } require_once constant($uc . '_CLASSES') . $conf['attachment']['class']; $class = ucfirst($controller) . 'Attachment'; } } // Lets init a new link object $al = new $class($this->controller->DBConnect(), $uc); if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'download': $ad = new AttachmentDownload($this, $attachment, $al); return $ad->execute(); break; case 'create': $ac = new AttachmentCreate($this, $attachment, $al); return $ac->execute(); break; case 'delete': $ad = new AttachmentDelete($this, $attachment, $al); return $ad->execute(); break; case 'modify': break; } } // Display the attachment information, dont auto download $av = new AttachmentView($this, $attachment, $al); return $av->execute(); }
/** * Set the wiki configuration parameters and get the list of wiki pages. */ function init() { $this->conf = VoodooIni::load('wiki'); $wf =& VoodooFormatter::getInstance(); $this->wikilist = $wf->wikilist; }