Пример #1
0
 function FlysprayAuth()
 {
     $plugins = glob_compat(dirname(__FILE__) . '/class.*');
     foreach ($plugins as $plugin) {
         require_once $plugin;
         $class = substr(basename($plugin), 6, -4);
         // better not include yourself ;)
         if (strcasecmp($class, get_class($this)) == 0) {
             continue;
         }
         $class = new $class();
         $this->authenticators[$class->getOrder()] = $class;
     }
     ksort($this->authenticators);
 }
Пример #2
0
 function TextFormatter()
 {
     global $proj;
     require_once 'class.syntaxplugin.php';
     $plugins = glob_compat(dirname(__FILE__) . '/syntaxplugins/class.*');
     foreach ($plugins as $plugin) {
         require_once $plugin;
         $class = substr(basename($plugin), 6, -4);
         $this->allclasses[] = ucfirst(substr($class, 0, -6)) . 'Syntax';
         // if wanted, exclude some plugins
         if (isset($proj->prefs['syntax_plugins']) && $proj->prefs['syntax_plugins'] && strpos($proj->prefs['syntax_plugins'], stristr($proj->prefs['syntax_plugins'], $class)) === false) {
             continue;
         }
         $class = new $class();
         $this->classes[$class->getOrder()] = $class;
     }
     // needs to be seperated for templating
     foreach ($this->classes as $class) {
         $this->htmlbefore .= $class->getHtmlBefore();
         $this->htmlafter .= $class->getHtmlAfter();
     }
     ksort($this->classes);
 }
Пример #3
0
 /**
  * Returns a list of installed languages
  * @access public static
  * @return array
  * @version 1.0
  */
 public static function listLangs()
 {
     return str_replace('.php', '', array_map('basename', glob_compat(BASEDIR . "/lang/[a-zA-Z]*.php")));
 }
Пример #4
0
 /**
  * Function to populate the database with the sql constructs which is in an sql file
  * @param array $data The actual database configuration values
  * @return boolean
  */
 function PopulateDb($data)
 {
     // Check available upgrade scripts, use the script of very latest  version
     $folders = glob_compat(BASEDIR . '/upgrade/[0-9]*');
     usort($folders, 'version_compare');
     // start with lowest version
     $folders = array_reverse($folders);
     // start with highest version
     $sql_file = APPLICATION_PATH . '/setup/upgrade/' . basename(reset($folders)) . '/flyspray-install.xml';
     $upgradeInfo = APPLICATION_PATH . '/setup/upgrade/' . basename(reset($folders)) . '/upgrade.info';
     $upgradeInfo = parse_ini_file($upgradeInfo, true);
     // Check if the install/upgrade file exists
     if (!is_readable($sql_file)) {
         $_SESSION['page_message'][] = "SQL file required for importing structure and data is missing ({$sql_file}).";
         return false;
     }
     // Extract the variables to local namespace
     extract($data);
     if (!isset($db_prefix)) {
         $db_prefix = '';
     }
     if (is_numeric($db_prefix)) {
         $_SESSION['page_message'][] = 'Database prefix cannot be numeric only';
         return false;
     }
     // Set the prefix for database objects ( before parsing )
     require 'MDB2/Schema.php';
     $this->mDbConnection->setOption('use_transactions', false);
     $this->mDbConnection->setOption('default_table_type', 'MyISAM');
     $this->mXmlSchema =& MDB2_Schema::factory($this->mDbConnection);
     $def = $this->mXmlSchema->parseDatabaseDefinitionFile($sql_file, array('db_prefix' => $db_prefix, 'db_name' => $data['db_name']));
     if (PEAR::isError($def)) {
         var_dump($def);
         exit;
     }
     $op = $this->mXmlSchema->createDatabase($def);
     if (PEAR::isError($op)) {
         var_dump($op);
         exit;
     }
     // global prefs update
     if (isset($upgradeInfo['fsprefs'])) {
         $existing = $this->mDbConnection->x->GetCol("SELECT pref_name FROM {$db_prefix}prefs");
         // Add what is missing
         $stmt = $this->mDbConnection->x->autoPrepare("{$db_prefix}prefs", array('pref_name', 'pref_value'));
         foreach ($upgradeInfo['fsprefs'] as $name => $value) {
             if (!in_array($name, $existing)) {
                 $stmt->execute(array($name, $value === '' ? '0' : $value));
             }
         }
         $stmt->free();
         // Delete what is too much
         $stmt = $this->mDbConnection->prepare("DELETE FROM {$db_prefix}prefs WHERE pref_name = ?");
         foreach ($existing as $name) {
             if (!isset($upgradeInfo['fsprefs'][$name])) {
                 $stmt->execute($name);
             }
         }
         $stmt->free();
     }
     $this->mDbConnection->x->execParam("UPDATE {$db_prefix}prefs SET pref_value = ? WHERE pref_name = 'fs_ver'", $this->version);
     if (PEAR::isError($op)) {
         $_SESSION['page_heading'] = 'Database Processing';
         $_SESSION['page_message'][] = $op->getMessage();
         return false;
     }
     return true;
 }
Пример #5
0
 /**
  * Function to populate the database with the sql constructs which is in an sql file
  * @param array $data The actual database configuration values
  * @return boolean
  */
 public function PopulateDb($data)
 {
     // Check available upgrade scripts, use the script of very latest  version
     $folders = glob_compat(BASEDIR . '/upgrade/[0-9]*');
     usort($folders, 'version_compare');
     // start with lowest version
     $folders = array_reverse($folders);
     // start with highest version
     $sql_file = APPLICATION_PATH . '/setup/upgrade/' . reset($folders) . '/flyspray-install.xml';
     $upgradeInfo = APPLICATION_PATH . '/setup/upgrade/' . reset($folders) . '/upgrade.info';
     $upgradeInfo = parse_ini_file($upgradeInfo, true);
     // Check if the install/upgrade file exists
     if (!is_readable($sql_file)) {
         $_SESSION['page_message'][] = 'SQL file required for importing structure and data is missing.';
         return false;
     }
     // Extract the variables to local namespace
     extract($data);
     if (!isset($db_prefix)) {
         $db_prefix = '';
     }
     if (is_numeric($db_prefix)) {
         $_SESSION['page_message'][] = 'database prefix cannot be numeric only';
         return false;
     }
     // Set the prefix for database objects ( before parsing)
     $this->mXmlSchema->setPrefix(isset($db_prefix) ? $db_prefix : '', false);
     $this->mXmlSchema->ParseSchema($sql_file);
     $this->mXmlSchema->ExecuteSchema();
     // Last but not least global prefs update
     if (isset($upgradeInfo['fsprefs'])) {
         $existing = $this->mDbConnection->GetCol("SELECT pref_name FROM {$db_prefix}prefs");
         // Add what is missing
         foreach ($upgradeInfo['fsprefs'] as $name => $value) {
             if (!in_array($name, $existing)) {
                 $this->mDbConnection->Execute("INSERT INTO {$db_prefix}prefs (pref_name, pref_value) VALUES (?, ?)", array($name, $value));
             }
         }
         // Delete what is too much
         foreach ($existing as $name) {
             if (!isset($upgradeInfo['fsprefs'][$name])) {
                 $this->mDbConnection->Execute("DELETE FROM {$db_prefix}prefs WHERE pref_name = ?", array($name));
             }
         }
     }
     $this->mDbConnection->Execute("UPDATE {$db_prefix}prefs SET pref_value = ? WHERE pref_name = 'fs_ver'", array($this->version));
     if ($error_no = $this->mDbConnection->MetaError()) {
         $_SESSION['page_heading'] = 'Database Processing';
         switch ($error_no) {
             case '-5':
                 // If there are tables with the same name
                 $_SESSION['page_message'][] = 'Table ' . $this->mDbConnection->MetaErrorMsg($this->mDbConnection->MetaError());
                 $_SESSION['page_message'][] = 'There probably are tables in the database which have the same prefix you provided.';
                 $_SESSION['page_message'][] = 'It is advised to change the prefix provided or you can drop the existing tables if you don\'t need them. Make a backup if you are not certain.';
                 return false;
                 break;
             case '-1':
                 // We are using the unknown error code(-1) because ADOdb library may not have the error defined.
                 $_SESSION['page_message'][] = $this->mDbConnection->ErrorMsg();
                 return false;
                 break;
             default:
                 $_SESSION['page_message'][] = $this->mDbConnection->ErrorMsg() . ': ' . $this->mDbConnection->ErrorNo();
                 $_SESSION['page_message'][] = 'Unknown error, please notify Developer quoting the error number';
                 return false;
                 break;
         }
     }
     return true;
 }
Пример #6
0
<?php

/*
   This is the main script that everything else is included
   in.  Mostly what it does is check the user permissions
   to see what they have access to.
*/
define('IN_FS', true);
require_once dirname(__FILE__) . '/header.php';
// Get available do-modes
$modes = str_replace('.php', '', array_map('basename', glob_compat(BASEDIR . "/scripts/*.php")));
$do = Req::enum('do', $modes, $proj->prefs['default_entry']);
if ($do == 'admin' && Req::has('switch') && Req::val('project') != '0') {
    $do = 'pm';
} elseif ($do == 'pm' && Req::has('switch') && Req::val('project') == '0') {
    $do = 'admin';
} elseif (Req::has('show') || Req::has('switch') && $do == 'details' || $do == 'newtask' && Req::val('project') == '0') {
    $do = 'index';
} elseif (Req::has('code')) {
    $_SESSION['oauth_provider'] = 'microsoft';
    $do = 'oauth';
} elseif (Req::has('do') && Req::val('do') == 'tasklist') {
    $do = 'index';
}
// supertask_id for add new sub-task
$supertask_id = 0;
if (Req::has('supertask')) {
    $supertask_id = Req::val('supertask');
}
/* permission stuff */
if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) {
Пример #7
0
$page = new Tpl();
$page->assign('title', 'Upgrade ');
$page->assign('short_version', UPGRADE_VERSION);
if (!isset($conf['general']['syntax_plugin']) || !$conf['general']['syntax_plugin'] || $conf['general']['syntax_plugin'] == 'none') {
    $page->assign('ask_for_conversion', true);
} else {
    $page->assign('ask_for_conversion', false);
}
//cleanup
//the cache dir
@rmdirr(sprintf('%s/cache/dokuwiki', APPLICATION_PATH));
// ---------------------------------------------------------------------
// Now the hard work
// ---------------------------------------------------------------------
// Find out which upgrades need to be run
$folders = glob_compat(BASEDIR . '/upgrade/[0-9]*');
usort($folders, 'version_compare');
// start with lowest version
if (Post::val('upgrade')) {
    $uplog = array();
    $uplog[] = "Start database transaction";
    $db->dblink->StartTrans();
    fix_duplicate_list_entries(true);
    foreach ($folders as $folder) {
        if (version_compare($installed_version, $folder, '<=')) {
            $uplog[] = "Start {$installed_version} to {$folder}";
            $uplog[] = execute_upgrade_file($folder, $installed_version);
            $installed_version = $folder;
            $uplog[] = "End {$installed_version} to {$folder}";
        }
    }