本文整理汇总了PHP中PMF_Db::setTablePrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Db::setTablePrefix方法的具体用法?PHP PMF_Db::setTablePrefix怎么用?PHP PMF_Db::setTablePrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Db
的用法示例。
在下文中一共展示了PMF_Db::setTablePrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startInstall
/**
* Starts the installation
*
* @param array $DB
*/
public function startInstall(array $DB = null)
{
$query = $uninst = $dbSetup = [];
// Check table prefix
$dbSetup['dbPrefix'] = $sqltblpre = PMF_Filter::filterInput(INPUT_POST, 'sqltblpre', FILTER_SANITIZE_STRING, '');
if ('' !== $dbSetup['dbPrefix']) {
PMF_Db::setTablePrefix($dbSetup['dbPrefix']);
}
// Check database entries
$dbSetup['dbType'] = PMF_Filter::filterInput(INPUT_POST, 'sql_type', FILTER_SANITIZE_STRING);
if (!is_null($dbSetup['dbType'])) {
$dbSetup['dbType'] = trim($dbSetup['dbType']);
if (!file_exists(PMF_ROOT_DIR . '/setup/assets/sql/' . $dbSetup['dbType'] . '.sql.php')) {
printf('<p class="alert alert-danger"><strong>Error:</strong> Invalid server type: %s</p>', $dbSetup['dbType']);
PMF_System::renderFooter(true);
}
} else {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please select a database type.</p>\n";
PMF_System::renderFooter(true);
}
$dbSetup['dbServer'] = PMF_Filter::filterInput(INPUT_POST, 'sql_server', FILTER_SANITIZE_STRING);
if (is_null($dbSetup['dbServer']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a database server.</p>\n";
PMF_System::renderFooter(true);
}
$dbSetup['dbPort'] = PMF_Filter::filterInput(INPUT_POST, 'sql_port', FILTER_VALIDATE_INT);
if (is_null($dbSetup['dbPort']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
echo "<p class=\"alert alert-error\"><strong>Error:</strong> Please add a valid database port.</p>\n";
PMF_System::renderFooter(true);
}
$dbSetup['dbUser'] = PMF_Filter::filterInput(INPUT_POST, 'sql_user', FILTER_SANITIZE_STRING);
if (is_null($dbSetup['dbUser']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a database username.</p>\n";
PMF_System::renderFooter(true);
}
$dbSetup['dbPassword'] = PMF_Filter::filterInput(INPUT_POST, 'sql_passwort', FILTER_UNSAFE_RAW);
if (is_null($dbSetup['dbPassword']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
// Password can be empty...
$dbSetup['dbPassword'] = '';
}
$dbSetup['dbDatabaseName'] = PMF_Filter::filterInput(INPUT_POST, 'sql_db', FILTER_SANITIZE_STRING);
if (is_null($dbSetup['dbDatabaseName']) && !PMF_System::isSqlite($dbSetup['dbType'])) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a database name.</p>\n";
PMF_System::renderFooter(true);
}
if (PMF_System::isSqlite($dbSetup['dbType'])) {
$dbSetup['dbServer'] = PMF_Filter::filterInput(INPUT_POST, 'sql_sqlitefile', FILTER_SANITIZE_STRING);
if (is_null($dbSetup['dbServer'])) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a SQLite database filename.</p>\n";
PMF_System::renderFooter(true);
}
}
// check database connection
PMF_Db::setTablePrefix($dbSetup['dbPrefix']);
$db = PMF_Db::factory($dbSetup['dbType']);
$db->connect($dbSetup['dbServer'], $dbSetup['dbUser'], $dbSetup['dbPassword'], $dbSetup['dbDatabaseName']);
if (!$db) {
printf("<p class=\"alert alert-danger\"><strong>DB Error:</strong> %s</p>\n", $db->error());
PMF_System::renderFooter(true);
}
$configuration = new PMF_Configuration($db);
// check LDAP if available
$ldapEnabled = PMF_Filter::filterInput(INPUT_POST, 'ldap_enabled', FILTER_SANITIZE_STRING);
if (extension_loaded('ldap') && !is_null($ldapEnabled)) {
$ldapSetup = [];
// check LDAP entries
$ldapSetup['ldapServer'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_server', FILTER_SANITIZE_STRING);
if (is_null($ldapSetup['ldapServer'])) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a LDAP server.</p>\n";
PMF_System::renderFooter(true);
}
$ldapSetup['ldapPort'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_port', FILTER_VALIDATE_INT);
if (is_null($ldapSetup['ldapPort'])) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a LDAP port.</p>\n";
PMF_System::renderFooter(true);
}
$ldapSetup['ldapBase'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_base', FILTER_SANITIZE_STRING);
if (is_null($ldapSetup['ldapBase'])) {
echo "<p class=\"alert alert-danger\"><strong>Error:</strong> Please add a LDAP base search DN.</p>\n";
PMF_System::renderFooter(true);
}
// LDAP User and LDAP password are optional
$ldapSetup['ldapUser'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_user', FILTER_SANITIZE_STRING, '');
$ldapSetup['ldapPassword'] = PMF_Filter::filterInput(INPUT_POST, 'ldap_password', FILTER_SANITIZE_STRING, '');
// check LDAP connection
require PMF_ROOT_DIR . "/inc/PMF/Ldap.php";
$ldap = new PMF_Ldap($configuration);
$ldap->connect($ldapSetup['ldapServer'], $ldapSetup['ldapPort'], $ldapSetup['ldapBase'], $ldapSetup['ldapUser'], $ldapSetup['ldapPassword']);
if (!$ldap) {
echo "<p class=\"alert alert-danger\"><strong>LDAP Error:</strong> " . $ldap->error() . "</p>\n";
PMF_System::renderFooter(true);
}
}
// check loginname
$loginname = PMF_Filter::filterInput(INPUT_POST, 'loginname', FILTER_SANITIZE_STRING);
//.........这里部分代码省略.........
示例2: array
$faqInstanceClient->copyConstantsFile($clientDir . '/constants.php');
$faqInstanceClient->copyLdapConstantsFile($clientDir . '/constants_ldap.php');
$dbSetup = array('dbServer' => $DB['server'], 'dbUser' => $DB['user'], 'dbPassword' => $DB['password'], 'dbDatabaseName' => $DB['db'], 'dbPrefix' => substr($hostname, 0, strpos($hostname, '.')), 'dbType' => $DB['type']);
$clientSetup->createDatabaseFile($dbSetup, '');
$faqInstanceClient->setClientUrl('http://' . $hostname);
$faqInstanceClient->createClientTables($dbSetup['dbPrefix']);
PMF_Db::setTablePrefix($dbSetup['dbPrefix']);
// add admin account and rights
$instanceAdmin = new PMF_User($faqConfig);
$instanceAdmin->createUser($admin, $password, 1);
$instanceAdmin->setStatus('protected');
$instanceAdminData = array('display_name' => '', 'email' => $email);
$instanceAdmin->setUserData($instanceAdminData);
// Add anonymous user account
$clientSetup->createAnonymousUser($faqConfig);
PMF_Db::setTablePrefix($DB['prefix']);
} else {
$faqInstance->removeInstance($instanceId);
$payload = array('error' => 'Cannot create instance.');
}
if (0 !== $instanceId) {
$payload = array('added' => $instanceId, 'url' => $data['url']);
} else {
$payload = array('error' => $instanceId);
}
$http->sendJsonWithHeaders($payload);
break;
case 'delete_instance':
if (!isset($_SESSION['phpmyfaq_csrf_token']) || $_SESSION['phpmyfaq_csrf_token'] !== $csrfToken) {
$http->sendJsonWithHeaders(array('error' => $PMF_LANG['err_NotAuth']));
exit(1);