本文整理汇总了PHP中dol_decode函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_decode函数的具体用法?PHP dol_decode怎么用?PHP dol_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dol_decode函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encodedecode_dbpassconf
/**
* Encode or decode database password in config file
*
* @param int $level Encode level: 0 no encoding, 1 encoding
* @return int <0 if KO, >0 if OK
*/
function encodedecode_dbpassconf($level = 0)
{
dol_syslog("encodedecode_dbpassconf level=" . $level, LOG_DEBUG);
$config = '';
$passwd = '';
$passwd_crypted = '';
if ($fp = fopen(DOL_DOCUMENT_ROOT . '/conf/conf.php', 'r')) {
while (!feof($fp)) {
$buffer = fgets($fp, 4096);
$lineofpass = 0;
if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\\s]*=[\\s]*(.*)/i', $buffer, $reg)) {
$val = trim($reg[1]);
// This also remove CR/LF
$val = preg_replace('/^["\']/', '', $val);
$val = preg_replace('/["\'][\\s;]*$/', '', $val);
if (!empty($val)) {
$passwd_crypted = $val;
$val = dol_decode($val);
$passwd = $val;
$lineofpass = 1;
}
} elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\\s]*=[\\s]*(.*)/i', $buffer, $reg)) {
$val = trim($reg[1]);
// This also remove CR/LF
$val = preg_replace('/^["\']/', '', $val);
$val = preg_replace('/["\'][\\s;]*$/', '', $val);
if (preg_match('/crypted:/i', $buffer)) {
$val = preg_replace('/crypted:/i', '', $val);
$passwd_crypted = $val;
$val = dol_decode($val);
$passwd = $val;
} else {
$passwd = $val;
$val = dol_encode($val);
$passwd_crypted = $val;
}
$lineofpass = 1;
}
// Output line
if ($lineofpass) {
// Add value at end of file
if ($level == 0) {
$config .= '$dolibarr_main_db_pass=\'' . $passwd . '\';' . "\n";
}
if ($level == 1) {
$config .= '$dolibarr_main_db_pass=\'crypted:' . $passwd_crypted . '\';' . "\n";
}
//print 'passwd = '.$passwd.' - passwd_crypted = '.$passwd_crypted;
//exit;
} else {
$config .= $buffer;
}
}
fclose($fp);
// Write new conf file
$file = DOL_DOCUMENT_ROOT . '/conf/conf.php';
if ($fp = @fopen($file, 'w')) {
fputs($fp, $config);
fclose($fp);
// It's config file, so we set read permission for creator only.
// Should set permission to web user and groups for users used by batch
//@chmod($file, octdec('0600'));
return 1;
} else {
dol_syslog("encodedecode_dbpassconf Failed to open conf.php file for writing", LOG_WARNING);
return -1;
}
} else {
dol_syslog("encodedecode_dbpassconf Failed to read conf.php", LOG_ERR);
return -2;
}
}
示例2: define
}
// If $suburi is /, it is now ''
define('DOL_URL_ROOT_ALT', $suburi);
// URL relative root ('', '/dolibarr/custom', ...)
}
// Define prefix
define('MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
//print DOL_URL_ROOT.'-'.DOL_URL_ROOT_ALT;
/*
* Include functions
*/
if (!file_exists(DOL_DOCUMENT_ROOT . "/lib/functions.lib.php")) {
print "Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
print "Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
exit;
}
include_once DOL_DOCUMENT_ROOT . "/lib/functions.lib.php";
// Need 970ko memory (1.1 in 2.2)
// If password is encoded, we decode it
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
require_once DOL_DOCUMENT_ROOT . "/lib/security.lib.php";
if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
// We need to set this as it is used to know the password was initially crypted
} else {
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
}
//print memory_get_usage();
示例3: testEncodeDecode
/**
* testEncodeDecode
*
* @return number
*/
public function testEncodeDecode()
{
$stringtotest = "This is a string to test encode/decode";
$encodedstring = dol_encode($stringtotest);
$decodedstring = dol_decode($encodedstring);
print __METHOD__ . " encodedstring=" . $encodedstring . " " . base64_encode($stringtotest) . "\n";
$this->assertEquals($stringtotest, $decodedstring);
return 0;
}