本文整理汇总了PHP中AJXP_Utils::cleanDibiDriverParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Utils::cleanDibiDriverParameters方法的具体用法?PHP AJXP_Utils::cleanDibiDriverParameters怎么用?PHP AJXP_Utils::cleanDibiDriverParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Utils
的用法示例。
在下文中一共展示了AJXP_Utils::cleanDibiDriverParameters方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performChecks
public function performChecks()
{
if (!isset($this->options)) {
return;
}
$test = AJXP_Utils::cleanDibiDriverParameters($this->options["SQL_DRIVER"]);
if (!count($test)) {
throw new Exception("Please define an SQL connexion in the core configuration");
}
}
示例2: installSQLTables
public function installSQLTables($param)
{
$p = AJXP_Utils::cleanDibiDriverParameters(isset($param) && isset($param["SQL_DRIVER"]) ? $param["SQL_DRIVER"] : $this->sqlDriver);
return AJXP_Utils::runCreateTablesQuery($p, $this->getBaseDir() . "/create.sql");
}
示例3: upgradeDB
public function upgradeDB()
{
$confDriver = ConfService::getConfStorageImpl();
$authDriver = ConfService::getAuthDriverImpl();
$logger = AJXP_Logger::getInstance();
if (is_a($confDriver, "sqlConfDriver")) {
$conf = AJXP_Utils::cleanDibiDriverParameters($confDriver->getOption("SQL_DRIVER"));
if (!is_array($conf) || !isset($conf["driver"])) {
return "Nothing to do";
}
switch ($conf["driver"]) {
case "sqlite":
case "sqlite3":
$ext = ".sqlite";
break;
case "postgre":
$ext = ".pgsql";
break;
case "mysql":
$ext = is_file($this->workingFolder . "/" . $this->dbUpgrade . ".mysql") ? ".mysql" : ".sql";
break;
default:
return "ERROR!, DB driver " . $conf["driver"] . " not supported yet in __FUNCTION__";
}
$file = $this->dbUpgrade . $ext;
if (!is_file($this->workingFolder . "/" . $file)) {
return "Nothing to do.";
}
$sqlInstructions = file_get_contents($this->workingFolder . "/" . $file);
$parts = array_map("trim", explode("/* SEPARATOR */", $sqlInstructions));
$results = array();
$errors = array();
dibi::connect($conf);
dibi::begin();
foreach ($parts as $sqlPart) {
if (empty($sqlPart)) {
continue;
}
try {
dibi::nativeQuery($sqlPart);
$results[] = $sqlPart;
} catch (DibiException $e) {
$errors[] = $sqlPart . " (" . $e->getMessage() . ")";
}
}
dibi::commit();
dibi::disconnect();
if (!count($errors)) {
return "Database successfully upgraded";
} else {
return "Database upgrade failed. <br>The following statements were executed : <br>" . implode("<br>", $results) . ",<br><br> The following statements failed : <br>" . implode("<br>", $errors) . "<br><br> You should manually upgrade your DB.";
}
}
}
示例4: testConnexions
/**
* Helpers to test SQL connection and send a test email.
* @param $action
* @param $httpVars
* @param $fileVars
* @throws Exception
*/
public function testConnexions($action, $httpVars, $fileVars)
{
$data = array();
AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "DRIVER_OPTION_");
if ($action == "boot_test_sql_connexion") {
$p = AJXP_Utils::cleanDibiDriverParameters($data["db_type"]);
if ($p["driver"] == "sqlite3") {
$dbFile = AJXP_VarsFilter::filter($p["database"]);
if (!file_exists(dirname($dbFile))) {
mkdir(dirname($dbFile), 0755, true);
}
}
// Should throw an exception if there was a problem.
dibi::connect($p);
dibi::disconnect();
echo 'SUCCESS:Connexion established!';
} else {
if ($action == "boot_test_mailer") {
$mailerPlug = AJXP_PluginsService::findPluginById("mailer.phpmailer-lite");
$mailerPlug->loadConfigs(array("MAILER" => $data["MAILER_ENABLE"]["MAILER_SYSTEM"]));
$mailerPlug->sendMail(array("adress" => $data["MAILER_ENABLE"]["MAILER_ADMIN"]), "Pydio Test Mail", "Body of the test", array("adress" => $data["MAILER_ENABLE"]["MAILER_ADMIN"]));
echo 'SUCCESS:Mail sent to the admin adress, please check it is in your inbox!';
}
}
}
示例5: installSQLTables
public function installSQLTables($param)
{
$p = AJXP_Utils::cleanDibiDriverParameters($param["SQL_DRIVER"]);
$res = AJXP_Utils::runCreateTablesQuery($p, $this->getBaseDir() . "/create.sql");
// SET DB VERSION
if (defined('AJXP_VERSION_DB') && AJXP_VERSION_DB != "##DB_VERSION##") {
dibi::connect($p);
dibi::query("UPDATE [ajxp_version] SET [db_build]=%i", intval(AJXP_VERSION_DB));
dibi::disconnect();
}
return $res;
}
示例6: testSQLConnexion
public function testSQLConnexion($httpVars)
{
$p = AJXP_Utils::cleanDibiDriverParameters($httpVars["SQL_CUSTOM_DRIVER"]);
if ($p["driver"] == "sqlite3") {
$dbFile = AJXP_VarsFilter::filter($p["database"]);
if (!file_exists(dirname($dbFile))) {
mkdir(dirname($dbFile), 0755, true);
}
}
// Should throw an exception if there was a problem.
dibi::connect($p);
$cTableName = $httpVars["SQL_CUSTOM_TABLE"];
$cUserField = $httpVars["SQL_CUSTOM_TABLE_USER_FIELD"];
$cUserValue = $httpVars["SQL_CUSTOM_TABLE_TEST_USER"];
$res = dibi::query("SELECT COUNT(*) FROM [" . $cTableName . "] WHERE [" . $cUserField . "]=%s", $cUserValue);
$found = intval($res->fetchSingle()) > 0;
if (!$found) {
throw new Exception("Could connect to the DB but could not find user " . $cUserValue);
}
dibi::disconnect();
echo "SUCCESS:Connexion established and user {$cUserValue} found in DB";
}
示例7: rename
rename(AJXP_INSTALL_PATH . "/conf/bootstrap_context.php" . ".new-" . date("Ymd"), AJXP_INSTALL_PATH . "/conf/bootstrap_context.php");
}
// FORCE bootstrap_context copy, otherwise it won't reboot
if (is_file(AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php" . ".new-" . date("Ymd"))) {
rename(AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php", AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php.pre-update");
rename(AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php" . ".new-" . date("Ymd"), AJXP_INSTALL_PATH . "/conf/bootstrap_repositories.php");
}
echo "The bootstrap_context and bootstrap_repositories files were replaced by the new version, the .pre-update version is kept.";
$dbInst = "\n/* SEPARATOR */\nALTER TABLE ajxp_user_rights ADD INDEX (login), ADD INDEX (repo_uuid);\n/* SEPARATOR */\nCREATE TABLE IF NOT EXISTS `ajxp_changes` (\n `seq` int(20) NOT NULL AUTO_INCREMENT,\n `repository_identifier` TEXT NOT NULL,\n `node_id` bigint(20) NOT NULL,\n `type` enum('create','delete','path','content') NOT NULL,\n `source` text NOT NULL,\n `target` text NOT NULL,\n PRIMARY KEY (`seq`),\n KEY `node_id` (`node_id`,`type`)\n);\n/* SEPARATOR */\nCREATE TABLE IF NOT EXISTS `ajxp_index` (\n `node_id` int(20) NOT NULL AUTO_INCREMENT,\n `node_path` text NOT NULL,\n `bytesize` bigint(20) NOT NULL,\n `md5` varchar(32) NOT NULL,\n `mtime` int(11) NOT NULL,\n `repository_identifier` text NOT NULL,\n PRIMARY KEY (`node_id`)\n);\n/* SEPARATOR */\nDROP TRIGGER IF EXISTS `LOG_DELETE`;\n/* SEPARATOR */\nCREATE TRIGGER `LOG_DELETE` AFTER DELETE ON `ajxp_index`\nFOR EACH ROW INSERT INTO ajxp_changes (repository_identifier, node_id,source,target,type)\n VALUES (old.repository_identifier, old.node_id, old.node_path, 'NULL', 'delete');\n/* SEPARATOR */\nDROP TRIGGER IF EXISTS `LOG_INSERT`;\n/* SEPARATOR */\nCREATE TRIGGER `LOG_INSERT` AFTER INSERT ON `ajxp_index`\nFOR EACH ROW INSERT INTO ajxp_changes (repository_identifier, node_id,source,target,type)\n VALUES (new.repository_identifier, new.node_id, 'NULL', new.node_path, 'create');\n/* SEPARATOR */\nDROP TRIGGER IF EXISTS `LOG_UPDATE`;\n/* SEPARATOR */\nCREATE TRIGGER `LOG_UPDATE` AFTER UPDATE ON `ajxp_index`\nFOR EACH ROW INSERT INTO ajxp_changes (repository_identifier, node_id,source,target,type)\n VALUES (new.repository_identifier, new.node_id, old.node_path, new.node_path, CASE old.node_path = new.node_path WHEN true THEN 'content' ELSE 'path' END);\n/* SEPARATOR */\nCREATE TABLE `ajxp_log2` LIKE `ajxp_log.back`;\n/* SEPARATOR */\nINSERT `ajxp_log.back` SELECT * FROM `ajxp_log`;\n/* SEPARATOR */\nCREATE TABLE `ajxp_log2` LIKE `ajxp_log`;\n/* SEPARATOR */\nINSERT `ajxp_log2` SELECT * FROM `ajxp_log`;\n/* SEPARATOR */\nALTER TABLE `ajxp_log2` ADD `source` VARCHAR( 255 ) NOT NULL AFTER `user` , ADD INDEX ( `source` ) ;\n/* SEPARATOR */\nUPDATE `ajxp_log2` INNER JOIN ajxp_log ON ajxp_log2.id=ajxp_log.id SET ajxp_log2.source = ajxp_log.message, ajxp_log2.message = SUBSTRING_INDEX(SUBSTRING_INDEX(ajxp_log.params, '\t', 1), '\t', -1),ajxp_log2.params = SUBSTRING_INDEX(SUBSTRING_INDEX(ajxp_log.params, '\t', 2), '\t', -1);\n/* SEPARATOR */\nDROP TABLE `ajxp_log`;\n/* SEPARATOR */\nRENAME TABLE `ajxp_log2` TO `ajxp_log`;\n";
$confDriver = ConfService::getConfStorageImpl();
$authDriver = ConfService::getAuthDriverImpl();
$logger = AJXP_Logger::getInstance();
if (is_a($confDriver, "sqlConfDriver")) {
$test = $confDriver->getOption("SQL_DRIVER");
if (!isset($test["driver"])) {
$test = AJXP_Utils::cleanDibiDriverParameters($confDriver->getOption("SQL_DRIVER"));
}
if (is_array($test) && isset($test["driver"]) && $test["driver"] == "mysql") {
echo "Upgrading MYSQL database ...";
$parts = array_map("trim", explode("/* SEPARATOR */", $dbInst));
$results = array();
$errors = array();
require_once AJXP_BIN_FOLDER . "/dibi.compact.php";
dibi::connect($test);
dibi::begin();
foreach ($parts as $sqlPart) {
if (empty($sqlPart)) {
continue;
}
try {
dibi::nativeQuery($sqlPart);
示例8: installSQLTables
/**
* Install SQL table using a dibi driver data
* @param $param array("SQL_DRIVER" => $dibiDriverData)
* @return mixed
*/
public function installSQLTables($param)
{
$base = basename($this->getBaseDir());
if ($base == "core.mailer") {
$p = AJXP_Utils::cleanDibiDriverParameters($param["SQL_DRIVER"]);
return AJXP_Utils::runCreateTablesQuery($p, $this->getBaseDir() . "/create.sql");
}
return true;
}