| 31 |
31 |
* @from http://www.php.net/manual/de/function.rmdir.php#98499
|
| 32 |
32 |
*/
|
| 33 |
33 |
function rm_full_dir($directory, $empty = false) {
|
| 34 |
|
|
| 35 |
|
if(substr($directory,-1) == "/")
|
| 36 |
|
{
|
|
34 |
|
|
35 |
if(substr($directory,-1) == "/") {
|
| 37 |
36 |
$directory = substr($directory,0,-1);
|
| 38 |
37 |
}
|
| 39 |
|
|
| 40 |
38 |
// If suplied dirname is a file then unlink it
|
| 41 |
|
if (is_file( $directory ))
|
| 42 |
|
{
|
|
39 |
if (is_file( $directory )) {
|
| 43 |
40 |
return unlink($directory);
|
| 44 |
41 |
}
|
| 45 |
|
|
| 46 |
|
if(!file_exists($directory) || !is_dir($directory))
|
| 47 |
|
{
|
|
42 |
if(!file_exists($directory) || !is_dir($directory)) {
|
| 48 |
43 |
return false;
|
| 49 |
|
} elseif(!is_readable($directory))
|
| 50 |
|
{
|
|
44 |
} elseif(!is_readable($directory)) {
|
| 51 |
45 |
return false;
|
| 52 |
46 |
} else {
|
| 53 |
47 |
$directoryHandle = opendir($directory);
|
| 54 |
|
|
| 55 |
48 |
while ($contents = readdir($directoryHandle))
|
| 56 |
49 |
{
|
| 57 |
50 |
if($contents != '.' && $contents != '..')
|
| 58 |
51 |
{
|
| 59 |
52 |
$path = $directory . "/" . $contents;
|
| 60 |
|
|
| 61 |
|
if(is_dir($path))
|
| 62 |
|
{
|
|
53 |
if(is_dir($path)) {
|
| 63 |
54 |
rm_full_dir($path);
|
| 64 |
55 |
} else {
|
| 65 |
56 |
unlink($path);
|
| 66 |
57 |
}
|
| 67 |
58 |
}
|
| 68 |
59 |
}
|
| 69 |
|
|
| 70 |
60 |
closedir($directoryHandle);
|
| 71 |
|
|
| 72 |
|
if($empty == false)
|
| 73 |
|
{
|
| 74 |
|
if(!rmdir($directory))
|
| 75 |
|
{
|
|
61 |
if($empty == false) {
|
|
62 |
if(!rmdir($directory)) {
|
| 76 |
63 |
return false;
|
| 77 |
64 |
}
|
| 78 |
65 |
}
|
| 79 |
|
|
| 80 |
66 |
return true;
|
| 81 |
67 |
}
|
| 82 |
68 |
}
|
| ... | ... | |
| 106 |
92 |
{
|
| 107 |
93 |
if($entry == '.' || $entry == '..') { continue; } // Skip pointers
|
| 108 |
94 |
if($entry[0] == '.' && $show_hidden == false) { continue; } // Skip hidden files
|
| 109 |
|
if (is_dir("$directory/$entry")) // Add dir and contents to list
|
| 110 |
|
{
|
|
95 |
if (is_dir("$directory/$entry")) { // Add dir and contents to list
|
| 111 |
96 |
$result_list = array_merge($result_list, directory_list("$directory/$entry"));
|
| 112 |
97 |
$result_list[] = "$directory/$entry";
|
| 113 |
98 |
}
|
| 114 |
99 |
}
|
| 115 |
100 |
$dir->close();
|
| 116 |
101 |
}
|
| 117 |
|
|
| 118 |
102 |
// sorting
|
| 119 |
|
if(natcasesort($result_list))
|
| 120 |
|
{
|
|
103 |
if(natcasesort($result_list)) {
|
| 121 |
104 |
// new indexing
|
| 122 |
105 |
$result_list = array_merge($result_list);
|
| 123 |
106 |
}
|
| ... | ... | |
| 138 |
121 |
// Skip pointers
|
| 139 |
122 |
if($entry[0] == '.') { continue; }
|
| 140 |
123 |
// Chmod the sub-dirs contents
|
| 141 |
|
if(is_dir("$directory/$entry"))
|
| 142 |
|
{
|
|
124 |
if(is_dir("$directory/$entry")) {
|
| 143 |
125 |
chmod_directory_contents($directory.'/'.$entry, $file_mode);
|
| 144 |
126 |
}
|
| 145 |
127 |
change_mode($directory.'/'.$entry);
|
| ... | ... | |
| 176 |
158 |
{
|
| 177 |
159 |
if (substr($file, 0, 1) != '.' && $file != 'index.php')
|
| 178 |
160 |
{
|
| 179 |
|
if (is_dir($root.'/'.$file))
|
| 180 |
|
{
|
|
161 |
if (is_dir($root.'/'.$file)) {
|
| 181 |
162 |
$FILE['path'][] = $file;
|
| 182 |
|
} elseif (preg_match($search, $file, $array) )
|
| 183 |
|
{
|
|
163 |
} elseif (preg_match($search, $file, $array) ) {
|
| 184 |
164 |
$FILE['filename'][] = $array[0];
|
| 185 |
165 |
}
|
| 186 |
166 |
}
|
| 187 |
167 |
}
|
| 188 |
168 |
$close_verz = closedir($handle);
|
| 189 |
169 |
}
|
| 190 |
|
|
| 191 |
170 |
// sorting
|
| 192 |
|
if (isset ($FILE['path']) && natcasesort($FILE['path']))
|
| 193 |
|
{
|
|
171 |
if (isset ($FILE['path']) && natcasesort($FILE['path'])) {
|
| 194 |
172 |
// new indexing
|
| 195 |
173 |
$FILE['path'] = array_merge($FILE['path']);
|
| 196 |
174 |
}
|
| 197 |
175 |
// sorting
|
| 198 |
|
if (isset ($FILE['filename']) && natcasesort($FILE['filename']))
|
| 199 |
|
{
|
|
176 |
if (isset ($FILE['filename']) && natcasesort($FILE['filename'])) {
|
| 200 |
177 |
// new indexing
|
| 201 |
178 |
$FILE['filename'] = array_merge($FILE['filename']);
|
| 202 |
179 |
}
|
| ... | ... | |
| 216 |
193 |
if($entry == '.' || $entry == '..') { continue; } // Skip pointers
|
| 217 |
194 |
if($entry[0] == '.' && $show_hidden == false) { continue; } // Skip hidden files
|
| 218 |
195 |
if( sizeof($skip) > 0 && in_array($entry, $skip) ) { continue; } // Check if we to skip anything else
|
| 219 |
|
if(is_file( $directory.'/'.$entry)) // Add files to list
|
| 220 |
|
{
|
|
196 |
if(is_file( $directory.'/'.$entry)) { // Add files to list
|
| 221 |
197 |
$result_list[] = $directory.'/'.$entry;
|
| 222 |
198 |
}
|
| 223 |
199 |
}
|
| ... | ... | |
| 225 |
201 |
}
|
| 226 |
202 |
|
| 227 |
203 |
// make the list nice. Not all OS do this itself
|
| 228 |
|
if(natcasesort($result_list))
|
| 229 |
|
{
|
|
204 |
if(natcasesort($result_list)) {
|
| 230 |
205 |
$result_list = array_merge($result_list);
|
| 231 |
|
}
|
| 232 |
|
|
|
206 |
}
|
| 233 |
207 |
return $result_list;
|
| 234 |
208 |
}
|
| 235 |
209 |
|
| ... | ... | |
| 243 |
217 |
// if(HOME_FOLDERS AND ($_SESSION['GROUP_ID']!='1')) {
|
| 244 |
218 |
if(HOME_FOLDERS AND (!in_array('1',explode(',', $_SESSION['GROUPS_ID']))))
|
| 245 |
219 |
{
|
| 246 |
|
$sql = 'SELECT `home_folder` FROM `'.TABLE_PREFIX.'users` WHERE `home_folder` != "'.$admin->get_home_folder().'"';
|
|
220 |
$sql = 'SELECT `home_folder` FROM `'.TABLE_PREFIX.'users` ';
|
|
221 |
$sql .= 'WHERE `home_folder`!=\''.$admin->get_home_folder().'\'';
|
| 247 |
222 |
$query_home_folders = $database->query($sql);
|
| 248 |
223 |
if($query_home_folders->numRows() > 0)
|
| 249 |
224 |
{
|
| 250 |
|
while($folder = $query_home_folders->fetchRow())
|
| 251 |
|
{
|
|
225 |
while($folder = $query_home_folders->fetchRow()) {
|
| 252 |
226 |
$home_folders[$folder['home_folder']] = $folder['home_folder'];
|
| 253 |
227 |
}
|
| 254 |
228 |
}
|
| ... | ... | |
| 263 |
237 |
{
|
| 264 |
238 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file))
|
| 265 |
239 |
{
|
| 266 |
|
if($directory != '/')
|
| 267 |
|
{
|
|
240 |
if($directory != '/') {
|
| 268 |
241 |
$file = $directory.'/'.$file;
|
| 269 |
|
}
|
| 270 |
|
else
|
| 271 |
|
{
|
|
242 |
}else {
|
| 272 |
243 |
$file = '/'.$file;
|
| 273 |
244 |
}
|
| 274 |
245 |
foreach($home_folders AS $hf)
|
| 275 |
246 |
{
|
| 276 |
247 |
$hf_length = strlen($hf);
|
| 277 |
|
if($hf_length > 0)
|
| 278 |
|
{
|
| 279 |
|
if(substr($file, 0, $hf_length+1) == $hf)
|
| 280 |
|
{
|
|
248 |
if($hf_length > 0) {
|
|
249 |
if(substr($file, 0, $hf_length+1) == $hf) {
|
| 281 |
250 |
$home_folders[$file] = $file;
|
| 282 |
251 |
}
|
| 283 |
252 |
}
|
| ... | ... | |
| 316 |
285 |
global $database;
|
| 317 |
286 |
// if user is admin or home-folders not activated then there are no restrictions
|
| 318 |
287 |
$allow_list = array();
|
| 319 |
|
if( $wb->get_user_id() == 1 || !HOME_FOLDERS )
|
| 320 |
|
{
|
|
288 |
if( $wb->get_user_id() == 1 || !HOME_FOLDERS ) {
|
| 321 |
289 |
return array();
|
| 322 |
290 |
}
|
| 323 |
291 |
// at first read any dir and subdir from /media
|
| 324 |
292 |
$full_list = directory_list( WB_PATH.MEDIA_DIRECTORY );
|
| 325 |
293 |
// add own home_folder to allow-list
|
| 326 |
|
if( $wb->get_home_folder() )
|
| 327 |
|
{
|
|
294 |
if( $wb->get_home_folder() ) {
|
| 328 |
295 |
// old: $allow_list[] = get_home_folder();
|
| 329 |
296 |
$allow_list[] = $wb->get_home_folder();
|
| 330 |
297 |
}
|
| 331 |
298 |
// get groups of current user
|
| 332 |
299 |
$curr_groups = $wb->get_groups_id();
|
| 333 |
300 |
// if current user is in admin-group
|
| 334 |
|
if( ($admin_key = array_search('1', $curr_groups)) !== false)
|
|
301 |
if( ($admin_key = array_search('1', $curr_groups)) !== false)
|
| 335 |
302 |
{
|
| 336 |
303 |
// remove admin-group from list
|
| 337 |
304 |
unset($curr_groups[$admin_key]);
|
| ... | ... | |
| 340 |
307 |
{
|
| 341 |
308 |
$sql = 'SELECT `home_folder` FROM `'.TABLE_PREFIX.'users` ';
|
| 342 |
309 |
$sql .= 'WHERE (FIND_IN_SET(\''.$group.'\', `groups_id`) > 0) AND `home_folder` <> \'\' AND `user_id` <> '.$wb->get_user_id();
|
| 343 |
|
if( ($res_hf = $database->query($sql)) != null )
|
| 344 |
|
{
|
| 345 |
|
while( $rec_hf = $res_hf->fetchrow() )
|
| 346 |
|
{
|
|
310 |
if( ($res_hf = $database->query($sql)) != null ) {
|
|
311 |
while( $rec_hf = $res_hf->fetchrow() ) {
|
| 347 |
312 |
$allow_list[] = $rec_hf['home_folder'];
|
| 348 |
313 |
}
|
| 349 |
314 |
}
|
| ... | ... | |
| 356 |
321 |
{
|
| 357 |
322 |
$tmp = array_shift($tmp_array);
|
| 358 |
323 |
$x = 0;
|
| 359 |
|
while($x < sizeof($allow_list))
|
| 360 |
|
{
|
|
324 |
while($x < sizeof($allow_list)) {
|
| 361 |
325 |
if(strpos ($tmp,$allow_list[$x])) {
|
| 362 |
326 |
$array[] = $tmp;
|
| 363 |
327 |
}
|
| 364 |
328 |
$x++;
|
| 365 |
329 |
}
|
| 366 |
330 |
}
|
| 367 |
|
|
| 368 |
331 |
$full_list = array_diff( $full_list, $array );
|
| 369 |
332 |
$tmp = array();
|
| 370 |
333 |
$full_list = array_merge($tmp,$full_list);
|
| 371 |
|
|
| 372 |
334 |
return $full_list;
|
| 373 |
335 |
}
|
| 374 |
336 |
|
| ... | ... | |
| 385 |
347 |
$full_list = directory_list( WB_PATH.MEDIA_DIRECTORY );
|
| 386 |
348 |
$array = array();
|
| 387 |
349 |
$allow_list = array();
|
| 388 |
|
if( ($wb->ami_group_member('1')) && !HOME_FOLDERS )
|
| 389 |
|
{
|
|
350 |
if( ($wb->ami_group_member('1')) && !HOME_FOLDERS ) {
|
| 390 |
351 |
return $full_list;
|
| 391 |
352 |
}
|
| 392 |
353 |
// add own home_folder to allow-list
|
| 393 |
|
if( $wb->get_home_folder() )
|
| 394 |
|
{
|
|
354 |
if( $wb->get_home_folder() ) {
|
| 395 |
355 |
$allow_list[] = $wb->get_home_folder();
|
| 396 |
356 |
} else {
|
| 397 |
357 |
$array = $full_list;
|
| ... | ... | |
| 408 |
368 |
{
|
| 409 |
369 |
$sql = 'SELECT `home_folder` FROM `'.TABLE_PREFIX.'users` ';
|
| 410 |
370 |
$sql .= 'WHERE (FIND_IN_SET(\''.$group.'\', `groups_id`) > 0) AND `home_folder` <> \'\' AND `user_id` <> '.$wb->get_user_id();
|
| 411 |
|
if( ($res_hf = $database->query($sql)) != null )
|
| 412 |
|
{
|
| 413 |
|
while( $rec_hf = $res_hf->fetchrow() )
|
| 414 |
|
{
|
|
371 |
if( ($res_hf = $database->query($sql)) != null ) {
|
|
372 |
while( $rec_hf = $res_hf->fetchrow() ) {
|
| 415 |
373 |
$allow_list[] = $rec_hf['home_folder'];
|
| 416 |
374 |
}
|
| 417 |
375 |
}
|
| ... | ... | |
| 424 |
382 |
{
|
| 425 |
383 |
$tmp = array_shift($tmp_array);
|
| 426 |
384 |
$x = 0;
|
| 427 |
|
while($x < sizeof($allow_list))
|
| 428 |
|
{
|
|
385 |
while($x < sizeof($allow_list)) {
|
| 429 |
386 |
if(strpos ($tmp,$allow_list[$x])) {
|
| 430 |
387 |
$array[] = $tmp;
|
| 431 |
388 |
}
|
| 432 |
389 |
$x++;
|
| 433 |
390 |
}
|
| 434 |
391 |
}
|
| 435 |
|
|
| 436 |
392 |
$tmp = array();
|
| 437 |
393 |
$array = array_unique($array);
|
| 438 |
394 |
$full_list = array_merge($tmp,$array);
|
| 439 |
395 |
unset($array);
|
| 440 |
396 |
unset($allow_list);
|
| 441 |
|
|
| 442 |
397 |
return $full_list;
|
| 443 |
398 |
}
|
| 444 |
399 |
|
| ... | ... | |
| 452 |
407 |
umask($umask);
|
| 453 |
408 |
return true;
|
| 454 |
409 |
} else {
|
| 455 |
|
return false;
|
|
410 |
return false;
|
| 456 |
411 |
}
|
| 457 |
412 |
}
|
| 458 |
413 |
|
| ... | ... | |
| 462 |
417 |
if(OPERATING_SYSTEM != 'windows')
|
| 463 |
418 |
{
|
| 464 |
419 |
// Only chmod if os is not windows
|
| 465 |
|
if(is_dir($name))
|
| 466 |
|
{
|
|
420 |
if(is_dir($name)) {
|
| 467 |
421 |
$mode = OCTAL_DIR_MODE;
|
| 468 |
|
}
|
| 469 |
|
else
|
| 470 |
|
{
|
|
422 |
}else {
|
| 471 |
423 |
$mode = OCTAL_FILE_MODE;
|
| 472 |
424 |
}
|
| 473 |
|
|
| 474 |
|
if(file_exists($name))
|
| 475 |
|
{
|
|
425 |
if(file_exists($name)) {
|
| 476 |
426 |
$umask = umask(0);
|
| 477 |
427 |
chmod($name, $mode);
|
| 478 |
428 |
umask($umask);
|
| 479 |
429 |
return true;
|
|
430 |
}else {
|
|
431 |
return false;
|
| 480 |
432 |
}
|
| 481 |
|
else
|
| 482 |
|
{
|
| 483 |
|
return false;
|
| 484 |
|
}
|
| 485 |
|
}
|
| 486 |
|
else
|
| 487 |
|
{
|
|
433 |
}else {
|
| 488 |
434 |
return true;
|
| 489 |
435 |
}
|
| 490 |
436 |
}
|
| ... | ... | |
| 497 |
443 |
$sql = 'SELECT `parent` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
|
| 498 |
444 |
$parent = $database->get_one($sql);
|
| 499 |
445 |
// If parent isnt 0 return its ID
|
| 500 |
|
if(is_null($parent))
|
| 501 |
|
{
|
|
446 |
if(is_null($parent)) {
|
| 502 |
447 |
return false;
|
| 503 |
|
}
|
| 504 |
|
else
|
| 505 |
|
{
|
|
448 |
}else {
|
| 506 |
449 |
return $parent;
|
| 507 |
450 |
}
|
| 508 |
451 |
}
|
| ... | ... | |
| 514 |
457 |
// Get page parent
|
| 515 |
458 |
$sql = 'SELECT `parent` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
|
| 516 |
459 |
$parent = $database->get_one($sql);
|
| 517 |
|
if($parent > 0)
|
|
460 |
if($parent > 0)
|
| 518 |
461 |
{ // Get the level of the parent
|
| 519 |
462 |
$sql = 'SELECT `level` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$parent;
|
| 520 |
463 |
$level = $database->get_one($sql);
|
| 521 |
464 |
return $level+1;
|
| 522 |
|
}
|
| 523 |
|
else
|
| 524 |
|
{
|
|
465 |
}else {
|
| 525 |
466 |
return 0;
|
| 526 |
467 |
}
|
| 527 |
468 |
}
|
| ... | ... | |
| 535 |
476 |
$query_page = $database->query($sql);
|
| 536 |
477 |
$fetch_page = $query_page->fetchRow();
|
| 537 |
478 |
$parent = $fetch_page['parent'];
|
| 538 |
|
$level = $fetch_page['level'];
|
| 539 |
|
if($level == 1)
|
| 540 |
|
{
|
|
479 |
$level = $fetch_page['level'];
|
|
480 |
if($level == 1) {
|
| 541 |
481 |
return $parent;
|
| 542 |
|
}
|
| 543 |
|
elseif($parent == 0)
|
| 544 |
|
{
|
|
482 |
}elseif($parent == 0) {
|
| 545 |
483 |
return $page_id;
|
| 546 |
|
}
|
| 547 |
|
else
|
| 548 |
|
{ // Figure out what the root parents id is
|
|
484 |
}else { // Figure out what the root parents id is
|
| 549 |
485 |
$parent_ids = array_reverse(get_parent_ids($page_id));
|
| 550 |
486 |
return $parent_ids[0];
|
| 551 |
487 |
}
|
| ... | ... | |
| 575 |
511 |
function get_parent_titles($parent_id)
|
| 576 |
512 |
{
|
| 577 |
513 |
$titles[] = get_menu_title($parent_id);
|
| 578 |
|
if(is_parent($parent_id) != false)
|
| 579 |
|
{
|
|
514 |
if(is_parent($parent_id) != false) {
|
| 580 |
515 |
$parent_titles = get_parent_titles(is_parent($parent_id));
|
| 581 |
516 |
$titles = array_merge($titles, $parent_titles);
|
| 582 |
517 |
}
|
| ... | ... | |
| 587 |
522 |
function get_parent_ids($parent_id)
|
| 588 |
523 |
{
|
| 589 |
524 |
$ids[] = $parent_id;
|
| 590 |
|
if(is_parent($parent_id) != false)
|
| 591 |
|
{
|
|
525 |
if(is_parent($parent_id) != false) {
|
| 592 |
526 |
$parent_ids = get_parent_ids(is_parent($parent_id));
|
| 593 |
527 |
$ids = array_merge($ids, $parent_ids);
|
| 594 |
528 |
}
|
| ... | ... | |
| 596 |
530 |
}
|
| 597 |
531 |
|
| 598 |
532 |
// Function to genereate page trail
|
| 599 |
|
function get_page_trail($page_id) {
|
|
533 |
function get_page_trail($page_id)
|
|
534 |
{
|
| 600 |
535 |
return implode(',', array_reverse(get_parent_ids($page_id)));
|
| 601 |
536 |
}
|
| 602 |
537 |
|
| ... | ... | |
| 610 |
545 |
$query = $database->query($sql);
|
| 611 |
546 |
if($query->numRows() > 0)
|
| 612 |
547 |
{
|
| 613 |
|
while($fetch = $query->fetchRow())
|
| 614 |
|
{
|
|
548 |
while($fetch = $query->fetchRow()) {
|
| 615 |
549 |
$subs[] = $fetch['page_id'];
|
| 616 |
550 |
// Get subs of this sub
|
| 617 |
551 |
$subs = get_subs($fetch['page_id'], $subs);
|
| ... | ... | |
| 759 |
693 |
|
| 760 |
694 |
function rebuildFolderProtectFile($dir='')
|
| 761 |
695 |
{
|
| 762 |
|
$retVal = array();
|
| 763 |
|
$dir = rtrim(str_replace('\/\\', '/', $dir), '/');
|
| 764 |
|
try {
|
| 765 |
|
$files = array();
|
| 766 |
|
$files[] = $dir;
|
| 767 |
|
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $fileInfo){
|
| 768 |
|
$files[] = $fileInfo->getPath();
|
| 769 |
|
}
|
| 770 |
|
$files = array_unique($files);
|
| 771 |
|
foreach( $files as $file){
|
| 772 |
|
$protect_file = rtrim(str_replace('\/\\', '/', $file), '/');
|
| 773 |
|
$retVal[] = createFolderProtectFile($protect_file,false);
|
| 774 |
|
}
|
| 775 |
|
} catch ( Exception $e ) {
|
| 776 |
|
$retVal[] = $MESSAGE['MEDIA_DIR_ACCESS_DENIED'];
|
| 777 |
|
}
|
| 778 |
|
return $retVal;
|
|
696 |
$retVal = array();
|
|
697 |
$dir = rtrim(str_replace('\/\\', '/', $dir), '/');
|
|
698 |
try {
|
|
699 |
$files = array();
|
|
700 |
$files[] = $dir;
|
|
701 |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $fileInfo) {
|
|
702 |
$files[] = $fileInfo->getPath();
|
|
703 |
}
|
|
704 |
$files = array_unique($files);
|
|
705 |
foreach( $files as $file) {
|
|
706 |
$protect_file = rtrim(str_replace('\/\\', '/', $file), '/');
|
|
707 |
$retVal[] = createFolderProtectFile($protect_file,false);
|
|
708 |
}
|
|
709 |
} catch ( Exception $e ) {
|
|
710 |
$retVal[] = $MESSAGE['MEDIA_DIR_ACCESS_DENIED'];
|
|
711 |
}
|
|
712 |
return $retVal;
|
| 779 |
713 |
}
|
| 780 |
714 |
|
| 781 |
715 |
// Create a new file in the pages directory
|
| 782 |
716 |
function create_access_file($filename,$page_id,$level)
|
| 783 |
717 |
{
|
| 784 |
718 |
global $admin, $MESSAGE;
|
| 785 |
|
/*
|
| 786 |
|
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/'))
|
|
719 |
// First make sure parent folder exists
|
|
720 |
$parent_folders = explode('/',str_replace(WB_PATH.PAGES_DIRECTORY, '', dirname($filename)));
|
|
721 |
$parents = '';
|
|
722 |
foreach($parent_folders AS $parent_folder)
|
| 787 |
723 |
{
|
| 788 |
|
$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
|
| 789 |
|
} else {
|
| 790 |
|
}
|
| 791 |
|
*/
|
| 792 |
|
// First make sure parent folder exists
|
| 793 |
|
$parent_folders = explode('/',str_replace(WB_PATH.PAGES_DIRECTORY, '', dirname($filename)));
|
| 794 |
|
$parents = '';
|
| 795 |
|
foreach($parent_folders AS $parent_folder)
|
|
724 |
if($parent_folder != '/' AND $parent_folder != '')
|
| 796 |
725 |
{
|
| 797 |
|
if($parent_folder != '/' AND $parent_folder != '')
|
| 798 |
|
{
|
| 799 |
|
$parents .= '/'.$parent_folder;
|
| 800 |
|
$acces_file = WB_PATH.PAGES_DIRECTORY.$parents;
|
| 801 |
|
// can only be dirs
|
| 802 |
|
if(!file_exists($acces_file)) {
|
| 803 |
|
if(!make_dir($acces_file)) {
|
| 804 |
|
$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE_FOLDER']);
|
| 805 |
|
}
|
|
726 |
$parents .= '/'.$parent_folder;
|
|
727 |
$acces_file = WB_PATH.PAGES_DIRECTORY.$parents;
|
|
728 |
// can only be dirs
|
|
729 |
if(!file_exists($acces_file)) {
|
|
730 |
if(!make_dir($acces_file)) {
|
|
731 |
$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE_FOLDER']);
|
| 806 |
732 |
}
|
| 807 |
733 |
}
|
| 808 |
734 |
}
|
| 809 |
|
// The depth of the page directory in the directory hierarchy
|
| 810 |
|
// '/pages' is at depth 1
|
| 811 |
|
$pages_dir_depth=count(explode('/',PAGES_DIRECTORY))-1;
|
| 812 |
|
// Work-out how many ../'s we need to get to the index page
|
| 813 |
|
$index_location = '';
|
| 814 |
|
for($i = 0; $i < $level + $pages_dir_depth; $i++)
|
| 815 |
|
{
|
| 816 |
|
$index_location .= '../';
|
| 817 |
|
}
|
| 818 |
|
$content =
|
| 819 |
|
'<?php'."\n".
|
| 820 |
|
'// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n".
|
| 821 |
|
'// *** Creation date: '.date('c')."\n".
|
| 822 |
|
'// *** Do not modify this file manually'."\n".
|
| 823 |
|
'// *** WB will rebuild this file from time to time!!'."\n".
|
| 824 |
|
'// *************************************************'."\n".
|
| 825 |
|
"\t".'$page_id = '.$page_id.';'."\n".
|
| 826 |
|
"\t".'require(\''.$index_location.'index.php\');'."\n".
|
| 827 |
|
'// *************************************************'."\n";
|
|
735 |
}
|
|
736 |
// The depth of the page directory in the directory hierarchy
|
|
737 |
// '/pages' is at depth 1
|
|
738 |
$pages_dir_depth = count(explode('/',PAGES_DIRECTORY))-1;
|
|
739 |
// Work-out how many ../'s we need to get to the index page
|
|
740 |
$index_location = '';
|
|
741 |
for($i = 0; $i < $level + $pages_dir_depth; $i++) {
|
|
742 |
$index_location .= '../';
|
|
743 |
}
|
|
744 |
$content =
|
|
745 |
'<?php'."\n".
|
|
746 |
'// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n".
|
|
747 |
'// *** Creation date: '.date('c')."\n".
|
|
748 |
'// *** Do not modify this file manually'."\n".
|
|
749 |
'// *** WB will rebuild this file from time to time!!'."\n".
|
|
750 |
'// *************************************************'."\n".
|
|
751 |
"\t".'$page_id = '.$page_id.';'."\n".
|
|
752 |
"\t".'require(\''.$index_location.'index.php\');'."\n".
|
|
753 |
'// *************************************************'."\n";
|
| 828 |
754 |
|
| 829 |
|
if ($handle = fopen($filename, 'w')) {
|
| 830 |
|
fwrite($handle, $content);
|
| 831 |
|
fclose($handle);
|
| 832 |
|
// Chmod the file
|
| 833 |
|
change_mode($filename);
|
| 834 |
|
} else {
|
| 835 |
|
$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
|
| 836 |
|
}
|
|
755 |
if( ($handle = fopen($filename, 'w')) ) {
|
|
756 |
fwrite($handle, $content);
|
|
757 |
fclose($handle);
|
|
758 |
// Chmod the file
|
|
759 |
change_mode($filename);
|
|
760 |
} else {
|
|
761 |
$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
|
|
762 |
}
|
| 837 |
763 |
return;
|
| 838 |
764 |
}
|
| 839 |
765 |
|
| ... | ... | |
| 897 |
823 |
'odt' => 'application/vnd.oasis.opendocument.text',
|
| 898 |
824 |
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
| 899 |
825 |
);
|
| 900 |
|
|
| 901 |
826 |
$temp = explode('.',$filename);
|
| 902 |
827 |
$ext = strtolower(array_pop($temp));
|
| 903 |
|
|
| 904 |
|
if (array_key_exists($ext, $mime_types))
|
| 905 |
|
{
|
|
828 |
if (array_key_exists($ext, $mime_types)) {
|
| 906 |
829 |
return $mime_types[$ext];
|
| 907 |
|
}
|
| 908 |
|
elseif (function_exists('finfo_open'))
|
| 909 |
|
{
|
|
830 |
}elseif (function_exists('finfo_open')) {
|
| 910 |
831 |
$finfo = finfo_open(FILEINFO_MIME);
|
| 911 |
832 |
$mimetype = finfo_file($finfo, $filename);
|
| 912 |
833 |
finfo_close($finfo);
|
| 913 |
834 |
return $mimetype;
|
| 914 |
|
}
|
| 915 |
|
else
|
| 916 |
|
{
|
|
835 |
}else {
|
| 917 |
836 |
return 'application/octet-stream';
|
| 918 |
837 |
}
|
| 919 |
838 |
}
|
| ... | ... | |
| 927 |
846 |
{
|
| 928 |
847 |
// First figure out the size of the thumbnail
|
| 929 |
848 |
list($original_x, $original_y) = getimagesize($source);
|
| 930 |
|
if ($original_x > $original_y)
|
| 931 |
|
{
|
|
849 |
if ($original_x > $original_y) {
|
| 932 |
850 |
$thumb_w = $size;
|
| 933 |
851 |
$thumb_h = $original_y*($size/$original_x);
|
| 934 |
852 |
}
|
| 935 |
|
if ($original_x < $original_y)
|
| 936 |
|
{
|
|
853 |
if ($original_x < $original_y) {
|
| 937 |
854 |
$thumb_w = $original_x*($size/$original_y);
|
| 938 |
855 |
$thumb_h = $size;
|
| 939 |
856 |
}
|
| 940 |
|
if ($original_x == $original_y)
|
| 941 |
|
{
|
|
857 |
if ($original_x == $original_y) {
|
| 942 |
858 |
$thumb_w = $size;
|
| 943 |
|
$thumb_h = $size;
|
|
859 |
$thumb_h = $size;
|
| 944 |
860 |
}
|
| 945 |
861 |
// Now make the thumbnail
|
| 946 |
862 |
$source = imageCreateFromJpeg($source);
|
| ... | ... | |
| 968 |
884 |
function extract_permission($octal_value, $who, $action)
|
| 969 |
885 |
{
|
| 970 |
886 |
// Make sure that all arguments are set and $octal_value is a real octal-integer
|
| 971 |
|
if( ($who == '') || ($action == '') || (preg_match( '/[^0-7]/', (string)$octal_value )) )
|
| 972 |
|
{
|
|
887 |
if(($who == '') || ($action == '') || (preg_match( '/[^0-7]/', (string)$octal_value ))) {
|
| 973 |
888 |
return false; // invalid argument, so return false
|
| 974 |
889 |
}
|
| 975 |
890 |
// convert $octal_value into a decimal-integer to be sure having a valid value
|
| 976 |
891 |
$right_mask = octdec($octal_value);
|
| 977 |
892 |
$action_mask = 0;
|
| 978 |
893 |
// set the $action related bit in $action_mask
|
| 979 |
|
switch($action[0]) // get action from first char of $action
|
| 980 |
|
{
|
|
894 |
switch($action[0]) { // get action from first char of $action
|
| 981 |
895 |
case 'r':
|
| 982 |
896 |
case 'R':
|
| 983 |
897 |
$action_mask = 4; // set read-bit only (2^2)
|
| ... | ... | |
| 996 |
910 |
return false; // undefined action name, so return false
|
| 997 |
911 |
}
|
| 998 |
912 |
// shift action-mask into the right position
|
| 999 |
|
switch($who[0]) // get who from first char of $who
|
| 1000 |
|
{
|
|
913 |
switch($who[0]) { // get who from first char of $who
|
| 1001 |
914 |
case 'u':
|
| 1002 |
915 |
case 'U':
|
| 1003 |
916 |
$action_mask <<= 3; // shift left 3 bits
|
| ... | ... | |
| 1019 |
932 |
{
|
| 1020 |
933 |
global $admin, $database, $MESSAGE;
|
| 1021 |
934 |
// Find out more about the page
|
| 1022 |
|
$sql = 'SELECT `page_id`, `menu_title`, `page_title`, `level`, `link`, `parent`, `modified_by`, `modified_when` ';
|
| 1023 |
|
$sql .= 'FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
|
|
935 |
$sql = 'SELECT `page_id`, `menu_title`, `page_title`, `level`, ';
|
|
936 |
$sql .= '`link`, `parent`, `modified_by`, `modified_when` ';
|
|
937 |
$sql .= 'FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.$page_id;
|
| 1024 |
938 |
$results = $database->query($sql);
|
| 1025 |
939 |
if($database->is_error()) { $admin->print_error($database->get_error()); }
|
| 1026 |
940 |
if($results->numRows() == 0) { $admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); }
|
| ... | ... | |
| 1030 |
944 |
$link = $results_array['link'];
|
| 1031 |
945 |
$page_title = $results_array['page_title'];
|
| 1032 |
946 |
$menu_title = $results_array['menu_title'];
|
| 1033 |
|
|
| 1034 |
947 |
// Get the sections that belong to the page
|
| 1035 |
|
$sql = 'SELECT `section_id`, `module` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.$page_id;
|
|
948 |
$sql = 'SELECT `section_id`, `module` FROM `'.TABLE_PREFIX.'sections` ';
|
|
949 |
$sql .= 'WHERE `page_id`='.$page_id;
|
| 1036 |
950 |
$query_sections = $database->query($sql);
|
| 1037 |
951 |
if($query_sections->numRows() > 0)
|
| 1038 |
952 |
{
|
| 1039 |
|
while($section = $query_sections->fetchRow())
|
| 1040 |
|
{
|
|
953 |
while($section = $query_sections->fetchRow()) {
|
| 1041 |
954 |
// Set section id
|
| 1042 |
955 |
$section_id = $section['section_id'];
|
| 1043 |
956 |
// Include the modules delete file if it exists
|
| 1044 |
|
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php'))
|
| 1045 |
|
{
|
|
957 |
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
| 1046 |
958 |
include(WB_PATH.'/modules/'.$section['module'].'/delete.php');
|
| 1047 |
959 |
}
|
| 1048 |
960 |
}
|
| 1049 |
961 |
}
|
| 1050 |
962 |
// Update the pages table
|
| 1051 |
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
|
|
963 |
$sql = 'DELETE FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.$page_id;
|
| 1052 |
964 |
$database->query($sql);
|
| 1053 |
|
if($database->is_error())
|
| 1054 |
|
{
|
|
965 |
if($database->is_error()) {
|
| 1055 |
966 |
$admin->print_error($database->get_error());
|
| 1056 |
967 |
}
|
| 1057 |
968 |
// Update the sections table
|
| 1058 |
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.$page_id;
|
|
969 |
$sql = 'DELETE FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.$page_id;
|
| 1059 |
970 |
$database->query($sql);
|
| 1060 |
971 |
if($database->is_error()) {
|
| 1061 |
972 |
$admin->print_error($database->get_error());
|
| ... | ... | |
| 1070 |
981 |
$directory .= '/';
|
| 1071 |
982 |
if(file_exists($filename))
|
| 1072 |
983 |
{
|
| 1073 |
|
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/'))
|
| 1074 |
|
{
|
|
984 |
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
|
| 1075 |
985 |
$admin->print_error($MESSAGE['PAGES']['CANNOT_DELETE_ACCESS_FILE']);
|
| 1076 |
|
}
|
| 1077 |
|
else
|
| 1078 |
|
{
|
|
986 |
}else {
|
| 1079 |
987 |
unlink($filename);
|
| 1080 |
988 |
if( file_exists($directory) &&
|
| 1081 |
989 |
(rtrim($directory,'/') != WB_PATH.PAGES_DIRECTORY) &&
|
| ... | ... | |
| 1097 |
1005 |
$file_content = '';
|
| 1098 |
1006 |
if( file_exists($file) && is_file($file) && is_readable($file))
|
| 1099 |
1007 |
{
|
| 1100 |
|
if($size == 0)
|
| 1101 |
|
{
|
|
1008 |
if($size == 0) {
|
| 1102 |
1009 |
$size = filesize($file);
|
| 1103 |
1010 |
}
|
| 1104 |
|
if(($fh = fopen($file, 'rb')))
|
| 1105 |
|
{
|
| 1106 |
|
if( ($file_content = fread($fh, $size)) !== false )
|
| 1107 |
|
{
|
|
1011 |
if(($fh = fopen($file, 'rb'))) {
|
|
1012 |
if( ($file_content = fread($fh, $size)) !== false ) {
|
| 1108 |
1013 |
return $file_content;
|
| 1109 |
1014 |
}
|
| 1110 |
1015 |
fclose($fh);
|
| ... | ... | |
| 1124 |
1029 |
{
|
| 1125 |
1030 |
if(is_array($replace))
|
| 1126 |
1031 |
{
|
| 1127 |
|
foreach ($replace as $key => $value)
|
| 1128 |
|
{
|
|
1032 |
foreach ($replace as $key => $value) {
|
| 1129 |
1033 |
$subject = str_replace("{{".$key."}}", $value, $subject);
|
| 1130 |
1034 |
}
|
| 1131 |
1035 |
}
|
| ... | ... | |
| 1149 |
1053 |
// Check that it doesn't already exist
|
| 1150 |
1054 |
$sqlwhere = 'WHERE `type` = \'module\' AND `directory` = \''.$module_directory.'\'';
|
| 1151 |
1055 |
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` '.$sqlwhere;
|
| 1152 |
|
if( $database->get_one($sql) )
|
| 1153 |
|
{
|
|
1056 |
if( $database->get_one($sql) ) {
|
| 1154 |
1057 |
$sql = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
|
| 1155 |
1058 |
}else{
|
| 1156 |
1059 |
// Load into DB
|
| 1157 |
1060 |
$sql = 'INSERT INTO `'.TABLE_PREFIX.'addons` SET ';
|
| 1158 |
1061 |
$sqlwhere = '';
|
| 1159 |
1062 |
}
|
| 1160 |
|
$sql .= '`directory` = \''.$module_directory.'\', ';
|
| 1161 |
|
$sql .= '`name` = \''.$module_name.'\', ';
|
| 1162 |
|
$sql .= '`description`= \''.addslashes($module_description).'\', ';
|
| 1163 |
|
$sql .= '`type`= \'module\', ';
|
| 1164 |
|
$sql .= '`function` = \''.$module_function.'\', ';
|
| 1165 |
|
$sql .= '`version` = \''.$module_version.'\', ';
|
| 1166 |
|
$sql .= '`platform` = \''.$module_platform.'\', ';
|
| 1167 |
|
$sql .= '`author` = \''.addslashes($module_author).'\', ';
|
| 1168 |
|
$sql .= '`license` = \''.addslashes($module_license).'\'';
|
|
1063 |
$sql .= '`directory`=\''.$module_directory.'\', ';
|
|
1064 |
$sql .= '`name`=\''.$module_name.'\', ';
|
|
1065 |
$sql .= '`description`=\''.addslashes($module_description).'\', ';
|
|
1066 |
$sql .= '`type`=\'module\', ';
|
|
1067 |
$sql .= '`function`=\''.$module_function.'\', ';
|
|
1068 |
$sql .= '`version`=\''.$module_version.'\', ';
|
|
1069 |
$sql .= '`platform`=\''.$module_platform.'\', ';
|
|
1070 |
$sql .= '`author`=\''.addslashes($module_author).'\', ';
|
|
1071 |
$sql .= '`license`=\''.addslashes($module_license).'\'';
|
| 1169 |
1072 |
$sql .= $sqlwhere;
|
| 1170 |
1073 |
$retVal = $database->query($sql);
|
| 1171 |
1074 |
// Run installation script
|
| 1172 |
|
if($install == true)
|
| 1173 |
|
{
|
| 1174 |
|
if(file_exists($directory.'/install.php'))
|
| 1175 |
|
{
|
|
1075 |
if($install == true) {
|
|
1076 |
if(file_exists($directory.'/install.php')) {
|
| 1176 |
1077 |
require($directory.'/install.php');
|
| 1177 |
1078 |
}
|
| 1178 |
1079 |
}
|
| ... | ... | |
| 1190 |
1091 |
require($directory.'/info.php');
|
| 1191 |
1092 |
if(isset($template_name))
|
| 1192 |
1093 |
{
|
| 1193 |
|
if(!isset($template_license))
|
| 1194 |
|
{
|
|
1094 |
if(!isset($template_license)) {
|
| 1195 |
1095 |
$template_license = 'GNU General Public License';
|
| 1196 |
1096 |
}
|
| 1197 |
|
if(!isset($template_platform) && isset($template_designed_for))
|
| 1198 |
|
{
|
|
1097 |
if(!isset($template_platform) && isset($template_designed_for)) {
|
| 1199 |
1098 |
$template_platform = $template_designed_for;
|
| 1200 |
1099 |
}
|
| 1201 |
|
if(!isset($template_function))
|
| 1202 |
|
{
|
|
1100 |
if(!isset($template_function)) {
|
| 1203 |
1101 |
$template_function = 'template';
|
| 1204 |
1102 |
}
|
| 1205 |
1103 |
// Check that it doesn't already exist
|
| 1206 |
|
$sqlwhere = 'WHERE `type` = \'template\' AND `directory` = \''.$template_directory.'\'';
|
|
1104 |
$sqlwhere = 'WHERE `type`=\'template\' AND `directory`=\''.$template_directory.'\'';
|
| 1207 |
1105 |
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` '.$sqlwhere;
|
| 1208 |
|
if( $database->get_one($sql) )
|
| 1209 |
|
{
|
|
1106 |
if( $database->get_one($sql) ) {
|
| 1210 |
1107 |
$sql = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
|
| 1211 |
1108 |
}else{
|
| 1212 |
1109 |
// Load into DB
|
| 1213 |
1110 |
$sql = 'INSERT INTO `'.TABLE_PREFIX.'addons` SET ';
|
| 1214 |
1111 |
$sqlwhere = '';
|
| 1215 |
1112 |
}
|
| 1216 |
|
$sql .= '`directory` = \''.$template_directory.'\', ';
|
| 1217 |
|
$sql .= '`name` = \''.$template_name.'\', ';
|
| 1218 |
|
$sql .= '`description`= \''.addslashes($template_description).'\', ';
|
| 1219 |
|
$sql .= '`type`= \'template\', ';
|
| 1220 |
|
$sql .= '`function` = \''.$template_function.'\', ';
|
| 1221 |
|
$sql .= '`version` = \''.$template_version.'\', ';
|
| 1222 |
|
$sql .= '`platform` = \''.$template_platform.'\', ';
|
| 1223 |
|
$sql .= '`author` = \''.addslashes($template_author).'\', ';
|
| 1224 |
|
$sql .= '`license` = \''.addslashes($template_license).'\' ';
|
|
1113 |
$sql .= '`directory`=\''.$template_directory.'\', ';
|
|
1114 |
$sql .= '`name`=\''.$template_name.'\', ';
|
|
1115 |
$sql .= '`description`=\''.addslashes($template_description).'\', ';
|
|
1116 |
$sql .= '`type`=\'template\', ';
|
|
1117 |
$sql .= '`function`=\''.$template_function.'\', ';
|
|
1118 |
$sql .= '`version`=\''.$template_version.'\', ';
|
|
1119 |
$sql .= '`platform`=\''.$template_platform.'\', ';
|
|
1120 |
$sql .= '`author`=\''.addslashes($template_author).'\', ';
|
|
1121 |
$sql .= '`license`=\''.addslashes($template_license).'\' ';
|
| 1225 |
1122 |
$sql .= $sqlwhere;
|
| 1226 |
1123 |
$retVal = $database->query($sql);
|
| 1227 |
1124 |
}
|
| ... | ... | |
| 1251 |
1148 |
if(!isset($language_license)) { $language_license = 'GNU General Public License'; }
|
| 1252 |
1149 |
if(!isset($language_platform) && isset($language_designed_for)) { $language_platform = $language_designed_for; }
|
| 1253 |
1150 |
// Check that it doesn't already exist
|
| 1254 |
|
$sqlwhere = 'WHERE `type` = \'language\' AND `directory` = \''.$language_code.'\'';
|
|
1151 |
$sqlwhere = 'WHERE `type`=\'language\' AND `directory`=\''.$language_code.'\'';
|
| 1255 |
1152 |
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` '.$sqlwhere;
|
| 1256 |
|
if( $database->get_one($sql) )
|
| 1257 |
|
{
|
|
1153 |
if( $database->get_one($sql) ) {
|
| 1258 |
1154 |
$sql = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
|
| 1259 |
1155 |
}else{
|
| 1260 |
1156 |
// Load into DB
|
| 1261 |
1157 |
$sql = 'INSERT INTO `'.TABLE_PREFIX.'addons` SET ';
|
| 1262 |
1158 |
$sqlwhere = '';
|
| 1263 |
1159 |
}
|
| 1264 |
|
$sql .= '`directory` = \''.$language_code.'\', ';
|
| 1265 |
|
$sql .= '`name` = \''.$language_name.'\', ';
|
| 1266 |
|
$sql .= '`type`= \'language\', ';
|
| 1267 |
|
$sql .= '`version` = \''.$language_version.'\', ';
|
| 1268 |
|
$sql .= '`platform` = \''.$language_platform.'\', ';
|
| 1269 |
|
$sql .= '`author` = \''.addslashes($language_author).'\', ';
|
| 1270 |
|
$sql .= '`license` = \''.addslashes($language_license).'\' ';
|
|
1160 |
$sql .= '`directory`=\''.$language_code.'\', ';
|
|
1161 |
$sql .= '`name`=\''.$language_name.'\', ';
|
|
1162 |
$sql .= '`type`=\'language\', ';
|
|
1163 |
$sql .= '`version`=\''.$language_version.'\', ';
|
|
1164 |
$sql .= '`platform`=\''.$language_platform.'\', ';
|
|
1165 |
$sql .= '`author`=\''.addslashes($language_author).'\', ';
|
|
1166 |
$sql .= '`license`=\''.addslashes($language_license).'\' ';
|
| 1271 |
1167 |
$sql .= $sqlwhere;
|
| 1272 |
1168 |
$retVal = $database->query($sql);
|
| 1273 |
1169 |
}
|
| ... | ... | |
| 1291 |
1187 |
$module_function = strtolower($module_function);
|
| 1292 |
1188 |
// Check that it does already exist
|
| 1293 |
1189 |
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` ';
|
| 1294 |
|
$sql .= 'WHERE `directory` = \''.$module_directory.'\'';
|
|
1190 |
$sql .= 'WHERE `directory`=\''.$module_directory.'\'';
|
| 1295 |
1191 |
if( $database->get_one($sql) )
|
| 1296 |
1192 |
{
|
| 1297 |
1193 |
// Update in DB
|
| 1298 |
1194 |
$sql = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
|
| 1299 |
|
$sql .= '`version` = "'.$module_version.'", ';
|
| 1300 |
|
$sql .= '`description` = "'.addslashes($module_description).'", ';
|
| 1301 |
|
$sql .= '`platform` = \''.$module_platform.'\', ';
|
| 1302 |
|
$sql .= '`author` = \''.addslashes($module_author).'\', ';
|
| 1303 |
|
$sql .= '`license` = \''.addslashes($module_license).'\' ';
|
| 1304 |
|
$sql .= 'WHERE `directory` = \''.$module_directory.'\' ';
|
|
1195 |
$sql .= '`version`=\''.$module_version.'\', ';
|
|
1196 |
$sql .= '`description`=\''.addslashes($module_description).'\', ';
|
|
1197 |
$sql .= '`platform`=\''.$module_platform.'\', ';
|
|
1198 |
$sql .= '`author`=\''.addslashes($module_author).'\', ';
|
|
1199 |
$sql .= '`license`=\''.addslashes($module_license).'\' ';
|
|
1200 |
$sql .= 'WHERE `directory`=\''.$module_directory.'\' ';
|
| 1305 |
1201 |
$database->query($sql);
|
| 1306 |
1202 |
if($database->is_error()) {
|
| 1307 |
1203 |
$admin->print_error($database->get_error());
|
| 1308 |
1204 |
}
|
| 1309 |
|
|
| 1310 |
1205 |
// Run upgrade script
|
| 1311 |
|
if($upgrade == true)
|
| 1312 |
|
{
|
| 1313 |
|
if(file_exists($mod_directory.'/upgrade.php'))
|
| 1314 |
|
{
|
|
1206 |
if($upgrade == true) {
|
|
1207 |
if(file_exists($mod_directory.'/upgrade.php')) {
|
| 1315 |
1208 |
require($mod_directory.'/upgrade.php');
|
| 1316 |
1209 |
}
|
| 1317 |
1210 |
}
|
| ... | ... | |
| 1331 |
1224 |
// the variable name is returned in $match[1], the content in $match[3]
|
| 1332 |
1225 |
if (preg_match('/(\$' .$search .')\s*=\s*("|\')(.*)\2\s*;/', $data, $match))
|
| 1333 |
1226 |
{
|
| 1334 |
|
if(strip_tags(trim($match[1])) == '$' .$search)
|
| 1335 |
|
{
|
|
1227 |
if(strip_tags(trim($match[1])) == '$' .$search) {
|
| 1336 |
1228 |
// variable name matches, return it's value
|
| 1337 |
1229 |
$match[3] = ($striptags == true) ? strip_tags($match[3]) : $match[3];
|
| 1338 |
1230 |
$match[3] = ($convert_to_entities == true) ? htmlentities($match[3]) : $match[3];
|
| ... | ... | |
| 1355 |
1247 |
$version = null;
|
| 1356 |
1248 |
if( $source != true )
|
| 1357 |
1249 |
{
|
| 1358 |
|
$sql = 'SELECT `version` FROM `'.TABLE_PREFIX.'addons` WHERE `directory`=\''.$modulname.'\'';
|
|
1250 |
$sql = 'SELECT `version` FROM `'.TABLE_PREFIX.'addons` ';
|
|
1251 |
$sql .= 'WHERE `directory`=\''.$modulname.'\'';
|
| 1359 |
1252 |
$version = $database->get_one($sql);
|
| 1360 |
1253 |
} else {
|
| 1361 |
1254 |
$info_file = WB_PATH.'/modules/'.$modulname.'/info.php';
|
| 1362 |
|
if(file_exists($info_file))
|
| 1363 |
|
{
|
| 1364 |
|
if(($info_file = file_get_contents($info_file)))
|
| 1365 |
|
{
|
|
1255 |
if(file_exists($info_file)) {
|
|
1256 |
if(($info_file = file_get_contents($info_file))) {
|
| 1366 |
1257 |
$version = get_variable_content('module_version', $info_file, false, false);
|
| 1367 |
1258 |
$version = ($version !== false) ? $version : null;
|
| 1368 |
1259 |
}
|
| ... | ... | |
| 1383 |
1274 |
$vars = explode(',', $varlist);
|
| 1384 |
1275 |
foreach( $vars as $var)
|
| 1385 |
1276 |
{
|
| 1386 |
|
if( isset($GLOBALS[$var]) )
|
| 1387 |
|
{
|
|
1277 |
if( isset($GLOBALS[$var]) ){
|
| 1388 |
1278 |
ErrorLog::write( 'variabe $'.$var.' already defined in global space!!',__FILE__, __FUNCTION__, __LINE__);
|
| 1389 |
1279 |
$retval = false;
|
| 1390 |
|
}else
|
| 1391 |
|
{
|
|
1280 |
}else {
|
| 1392 |
1281 |
global $$var;
|
| 1393 |
1282 |
}
|
| 1394 |
1283 |
}
|
| ... | ... | |
| 1404 |
1293 |
*/
|
| 1405 |
1294 |
function check_media_path($directory, $with_media_dir = true)
|
| 1406 |
1295 |
{
|
| 1407 |
|
$md = ($with_media_dir) ? MEDIA_DIRECTORY : '';
|
|
1296 |
$md = ($with_media_dir) ? MEDIA_DIRECTORY : '';
|
| 1408 |
1297 |
$dir = realpath(WB_PATH . $md . '/' . utf8_decode($directory));
|
| 1409 |
1298 |
$required = realpath(WB_PATH . MEDIA_DIRECTORY);
|
| 1410 |
1299 |
if (strstr($dir, $required)) {
|
| ... | ... | |
| 1426 |
1315 |
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
|
| 1427 |
1316 |
return str_replace($entities,$replacements, rawurlencode($string));
|
| 1428 |
1317 |
}
|
| 1429 |
|
}
|
|
1318 |
}
|
fix SQL-statements to SQL-strict