Revision 1765
Added by Luisehahne about 13 years ago
| functions.php | ||
|---|---|---|
| 34 | 34 |
*/ |
| 35 | 35 |
function rm_full_dir($directory, $empty = false) |
| 36 | 36 |
{
|
| 37 |
$iErrorReporting = error_reporting(0); |
|
| 37 | 38 |
if(substr($directory,-1) == "/") {
|
| 38 | 39 |
$directory = substr($directory,0,-1); |
| 39 | 40 |
} |
| 40 | 41 |
// If suplied dirname is a file then unlink it |
| 41 | 42 |
if (is_file( $directory )&& is_writable( $directory )) {
|
| 42 |
$retval = unlink($directory); |
|
| 43 |
clearstatcache(); |
|
| 44 |
return $retval; |
|
| 43 |
$retval = unlink($directory); |
|
| 44 |
clearstatcache(); |
|
| 45 |
error_reporting($iErrorReporting); |
|
| 46 |
return $retval; |
|
| 45 | 47 |
} |
| 46 | 48 |
if(!is_writable($directory) || !is_dir($directory)) {
|
| 49 |
error_reporting($iErrorReporting); |
|
| 47 | 50 |
return false; |
| 48 | 51 |
} elseif(!is_readable($directory)) {
|
| 52 |
error_reporting($iErrorReporting); |
|
| 49 | 53 |
return false; |
| 50 | 54 |
} else {
|
| 51 | 55 |
$directoryHandle = opendir($directory); |
| ... | ... | |
| 65 | 69 |
closedir($directoryHandle); |
| 66 | 70 |
if($empty == false) {
|
| 67 | 71 |
if(is_dir($directory) && is_writable(dirname($directory))) {
|
| 68 |
return rmdir($directory); |
|
| 72 |
$retval = rmdir($directory); |
|
| 73 |
error_reporting($iErrorReporting); |
|
| 74 |
return $retval; |
|
| 69 | 75 |
} else {
|
| 76 |
error_reporting($iErrorReporting); |
|
| 70 | 77 |
return false; |
| 71 | 78 |
} |
| 72 | 79 |
} |
| 80 |
error_reporting($iErrorReporting); |
|
| 73 | 81 |
return true; |
| 74 | 82 |
} |
| 75 | 83 |
} |
| ... | ... | |
| 407 | 415 |
// Function to create directories |
| 408 | 416 |
function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE, $recursive=true) |
| 409 | 417 |
{
|
| 410 |
$retVal = false;
|
|
| 418 |
$retVal = is_dir($dir_name);
|
|
| 411 | 419 |
if(!is_dir($dir_name)) |
| 412 | 420 |
{
|
| 413 | 421 |
// To create the folder with 0777 permissions, we need to set umask to zero. |
| 414 | 422 |
$oldumask = umask(0) ; |
| 415 |
$retVal = mkdir($dir_name, $dir_mode,$recursive); |
|
| 423 |
$retVal = mkdir($dir_name, $dir_mode, $recursive);
|
|
| 416 | 424 |
umask( $oldumask ) ; |
| 417 | 425 |
} |
| 418 | 426 |
return $retVal; |
| ... | ... | |
| 692 | 700 |
if(file_put_contents($filename, $content)) {
|
| 693 | 701 |
// print 'create => '.str_replace( $wb_path,'',$filename).'<br />'; |
| 694 | 702 |
change_mode($filename, 'file'); |
| 695 |
}else {
|
|
| 703 |
} else {
|
|
| 696 | 704 |
$retVal[] = $MESSAGE['GENERIC_BAD_PERMISSIONS'].' :: '.$filename; |
| 697 | 705 |
} |
| 698 | 706 |
} |
| ... | ... | |
| 728 | 736 |
function create_access_file($filename,$page_id,$level) |
| 729 | 737 |
{
|
| 730 | 738 |
global $admin, $MESSAGE; |
| 739 |
$retVal = array(); |
|
| 731 | 740 |
// First make sure parent folder exists |
| 732 | 741 |
$parent_folders = explode('/',str_replace(WB_PATH.PAGES_DIRECTORY, '', dirname($filename)));
|
| 733 | 742 |
$parents = ''; |
| ... | ... | |
| 740 | 749 |
// can only be dirs |
| 741 | 750 |
if(!file_exists($acces_file)) {
|
| 742 | 751 |
if(!make_dir($acces_file)) {
|
| 743 |
$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE_FOLDER']); |
|
| 752 |
// $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE_FOLDER']); |
|
| 753 |
$retVal[] = $MESSAGE['MEDIA_DIR_ACCESS_DENIED']; |
|
| 744 | 754 |
} |
| 745 | 755 |
} |
| 746 | 756 |
} |
| ... | ... | |
| 770 | 780 |
// Chmod the file |
| 771 | 781 |
change_mode($filename); |
| 772 | 782 |
} else {
|
| 773 |
$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 783 |
// $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 784 |
$retVal[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']; |
|
| 774 | 785 |
} |
| 775 |
return; |
|
| 786 |
return $retVal;
|
|
| 776 | 787 |
} |
| 777 | 788 |
|
| 778 | 789 |
// Function for working out a file mime type (if the in-built PHP one is not enabled) |
| ... | ... | |
| 1082 | 1093 |
$sql .= '`author`=\''.addslashes($module_author).'\', '; |
| 1083 | 1094 |
$sql .= '`license`=\''.addslashes($module_license).'\''; |
| 1084 | 1095 |
$sql .= $sqlwhere; |
| 1085 |
$retVal = $database->query($sql);
|
|
| 1096 |
$retVal = intval($database->query($sql) ? true : false);
|
|
| 1086 | 1097 |
// Run installation script |
| 1087 | 1098 |
if($install == true) {
|
| 1088 | 1099 |
if(file_exists($directory.'/install.php')) {
|
| ... | ... | |
| 1090 | 1101 |
} |
| 1091 | 1102 |
} |
| 1092 | 1103 |
} |
| 1104 |
return $retVal; |
|
| 1093 | 1105 |
} |
| 1094 | 1106 |
} |
| 1095 | 1107 |
|
| ... | ... | |
| 1132 | 1144 |
$sql .= '`author`=\''.addslashes($template_author).'\', '; |
| 1133 | 1145 |
$sql .= '`license`=\''.addslashes($template_license).'\' '; |
| 1134 | 1146 |
$sql .= $sqlwhere; |
| 1135 |
$retVal = $database->query($sql);
|
|
| 1147 |
$retVal = intval($database->query($sql) ? true : false);
|
|
| 1136 | 1148 |
} |
| 1137 | 1149 |
} |
| 1138 | 1150 |
return $retVal; |
| ... | ... | |
| 1179 | 1191 |
$sql .= '`author`=\''.addslashes($language_author).'\', '; |
| 1180 | 1192 |
$sql .= '`license`=\''.addslashes($language_license).'\' '; |
| 1181 | 1193 |
$sql .= $sqlwhere; |
| 1182 |
$retVal = $database->query($sql);
|
|
| 1194 |
$retVal = intval($database->query($sql) ? true : false);
|
|
| 1183 | 1195 |
} |
| 1184 | 1196 |
} |
| 1185 | 1197 |
return $retVal; |
| ... | ... | |
| 1330 | 1342 |
return str_replace($entities,$replacements, rawurlencode($string)); |
| 1331 | 1343 |
} |
| 1332 | 1344 |
} |
| 1345 |
|
|
| 1346 |
if(!function_exists('rebuild_all_accessfiles')){
|
|
| 1347 |
function rebuild_all_accessfiles() {
|
|
| 1348 |
global $database; |
|
| 1349 |
$retVal = array(); |
|
| 1350 |
/** |
|
| 1351 |
* try to remove access files and build new folder protect files |
|
| 1352 |
*/ |
|
| 1353 |
$sTempDir = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
|
|
| 1354 |
if(($sTempDir!='') && is_writeable(WB_PATH.$sTempDir)==true) {
|
|
| 1355 |
if(rm_full_dir (WB_PATH.$sTempDir, true )==false) {
|
|
| 1356 |
$retVal[] = '<span><strong>Could not delete existing access files</strong></span>'; |
|
| 1357 |
} |
|
| 1358 |
} |
|
| 1359 |
$retVal[] = createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') ); |
|
| 1360 |
/** |
|
| 1361 |
* Reformat/rebuild all existing access files |
|
| 1362 |
*/ |
|
| 1363 |
$sql = 'SELECT `page_id`,`root_parent`,`link`, `level` FROM `'.TABLE_PREFIX.'pages` ORDER BY `link`'; |
|
| 1364 |
if (($oPage = $database->query($sql))) |
|
| 1365 |
{
|
|
| 1366 |
$x = 0; |
|
| 1367 |
while (($page = $oPage->fetchRow(MYSQL_ASSOC))) |
|
| 1368 |
{
|
|
| 1369 |
// Work out level |
|
| 1370 |
$level = level_count($page['page_id']); |
|
| 1371 |
// Work out root parent |
|
| 1372 |
$root_parent = root_parent($page['page_id']); |
|
| 1373 |
// Work out page trail |
|
| 1374 |
$page_trail = get_page_trail($page['page_id']); |
|
| 1375 |
// Update page with new level and link |
|
| 1376 |
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET '; |
|
| 1377 |
$sql .= '`root_parent` = '.$root_parent.', '; |
|
| 1378 |
$sql .= '`level` = '.$level.', '; |
|
| 1379 |
$sql .= '`page_trail` = "'.$page_trail.'" '; |
|
| 1380 |
$sql .= 'WHERE `page_id` = '.$page['page_id']; |
|
| 1381 |
|
|
| 1382 |
if(!$database->query($sql)) {}
|
|
| 1383 |
$filename = WB_PATH.PAGES_DIRECTORY.$page['link'].PAGE_EXTENSION; |
|
| 1384 |
$retVal = create_access_file($filename, $page['page_id'], $page['level']); |
|
| 1385 |
$x++; |
|
| 1386 |
} |
|
| 1387 |
$retVal[] = '<span><strong>Number of new formated access files: '.$x.'</strong></span>'; |
|
| 1388 |
} |
|
| 1389 |
return $retVal; |
|
| 1390 |
} |
|
| 1391 |
} |
|
| 1392 |
|
|
| 1393 |
if(!function_exists('upgrade_modules')){
|
|
| 1394 |
function upgrade_modules($aModuleList) {
|
|
| 1395 |
global $database; |
|
| 1396 |
foreach($aModuleList as $sModul) {
|
|
| 1397 |
if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
|
|
| 1398 |
$currModulVersion = get_modul_version ($sModul, false); |
|
| 1399 |
$newModulVersion = get_modul_version ($sModul, true); |
|
| 1400 |
if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
|
|
| 1401 |
require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php'); |
|
| 1402 |
} |
|
| 1403 |
} |
|
| 1404 |
} |
|
| 1405 |
} |
|
| 1406 |
} |
|
| 1407 |
|
|
Also available in: Unified diff
! recoded module news,form,wysiwyg upgrade to work with upgrade-script