1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
|
<?php
/**
* browse.php -- Browse page
*
* Author: Steve Bourgeois <owl@bozzit.com>
* Project Founder: Chris Vincent <cvincent@project802.net>
*
* Copyright (c) 1999-2004 The Owl Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
*/
$dStartTime = time();
require_once(dirname(__FILE__) . "/config/owl.php");
require_once($default->owl_fs_root . "/lib/disp.lib.php");
require_once($default->owl_fs_root . "/lib/owl.lib.php");
require_once($default->owl_fs_root . "/lib/readhd.php");
require_once($default->owl_fs_root . "/lib/security.lib.php");
if (!isset($expand) or !is_numeric($expand))
{
$expand = $default->expand;
}
include_once($default->owl_fs_root . "/lib/header.inc");
include_once($default->owl_fs_root . "/lib/userheader.inc");
if (empty($parent) || !is_numeric($parent))
{
$iHomeDir = $default->HomeDir;
$iFirstDir = $default->FirstDir;
if ( $iHomeDir <> $iFirstDir)
{
$sql->query("SELECT * from $default->owl_folders_table where id = '$iFirstDir'");
$numrows = $sql->num_rows($sql);
if ($numrows == "1")
{
$parent = $iFirstDir;
}
else
{
$parent = $iHomeDir;
}
}
else
{
$parent= $iHomeDir;
}
if(isset($fileid))
{
$parent = owlfileparent($fileid);
}
}
else
{
// Check to see if the user tried to go outside his home directory
if ($parent != $default->HomeDir )
{
$bIsWithinHomeDir = false;
fCheckWithinHomeDir ( $parent );
if (!$bIsWithinHomeDir)
{
printError($owl_lang->err_unauthorized);
}
}
}
if (empty($curview) || !is_numeric($curview))
{
$curview = 0;
}
$CheckPass = new Owl_DB;
$CheckPass->query("select password from " . $default->owl_folders_table . " where id='$parent'");
$CheckPass->next_record();
$password = $CheckPass->f("password");
$bPasswordFailed = false;
if ($password == md5($docpassword))
{
$bDownloadAllowed = true;
}
else
{
if(!empty($docpassword))
{
$bPasswordFailed = true;
}
$bDownloadAllowed = false;
}
if (!isset($nextfiles))
{
$nextfiles = 0;
}
if (!isset($nextfolders))
{
$nextfolders = 0;
}
if (!isset($bDisplayFiles))
{
$bDisplayFiles = false;
}
// Initialize Page count Variables
if (!isset($iCurrentPage))
{
$iCurrentPage = 0;
}
if (!isset($next))
{
$next = 0;
}
if (!isset($prev))
{
$prev = 0;
}
if ($next == 1)
{
$iCurrentPage++;
$nextfiles = $nextfiles + $default->records_per_page;
$nextfolders = $nextfolders + $default->records_per_page;
}
if ($prev == 1)
{
$iCurrentPage--;
$nextfiles = $nextfiles - $default->records_per_page;
if ($nextfiles < 0)
{
$nextfiles = 0;
}
$nextfolders = $nextfolders - $default->records_per_page;
if ($nextfolders < 0)
{
$nextfolders = 0;
}
}
// V4B RNG Start
$urlArgs = array();
$urlArgs['sess'] = $sess;
$urlArgs['parent'] = $parent;
$urlArgs['expand'] = $expand;
$urlArgs['order'] = $order;
$urlArgs['curview'] = $curview;
$urlArgs[${sortorder}] = $sort;
// V4B RNG End
if (check_auth($parent, "folder_view", $userid, false, false) != "1" and !$bDownloadAllowed)
{
$sql->query("select password from " . $default->owl_folders_table . " where id='$parent'");
$sql->next_record();
$password = $sql->f("password");
if (empty($password) or (!empty($password) and $bPasswordFailed))
{
printError($owl_lang->err_nofolderaccess);
}
else
{
include_once($default->owl_fs_root . "/lib/header.inc");
include_once($default->owl_fs_root . "/lib/userheader.inc");
if ($expand == 1)
{
print("<table class=\"border1\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"$default->table_expand_width\"><tr><td align=\"center\" valign=\"top\" width=\"100%\">\n");
}
else
{
print("<table class=\"border1\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"$default->table_collapse_width\"><tr><td align=\"center\" valign=\"top\" width=\"100%\">\n");
}
fPrintButtonSpace(12, 1);
print("<table class=\"border2\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td align=\"left\" valign=\"top\" width=\"100%\">\n");
if ($default->show_prefs == 1 or $default->show_prefs == 3)
{
fPrintPrefs("infobar1", "top", true);
}
fPrintButtonSpace(12, 1);
print("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n");
print("<form action=\"browse.php\" method=\"post\">\n");
print fGetHiddenFields ($urlArgs);
fPrintFormTextLine($owl_lang->password , "docpassword", "", "", "", false, "password");
print("<tr>\n");
print("<td class=\"form1\">");
fPrintButtonSpace(1, 1);
print("</td>\n");
print("<td class=\"form2\" width=\"100%\">");
fPrintSubmitButton($owl_lang->btn_submit, $owl_lang->btn_submit, "submit");
fPrintSubmitButton($owl_lang->btn_reset, $owl_lang->alt_reset_form, "reset");
print("</td>\n");
print("</tr>\n");
print("</form>\n");
print("</table>\n");
fPrintButtonSpace(12, 1);
if ($default->show_prefs == 2 or $default->show_prefs == 3)
{
fPrintPrefs("infobar2", "", true);
}
print("</td></tr></table>\n");
include_once($default->owl_fs_root. "/lib/footer.inc");
}
exit;
}
// Tiian changes 2003-07-31
$sql_bro = new Owl_DB;
$sql_bro->query("SELECT id FROM $default->owl_folders_table WHERE id = '$parent' AND name = '$default->version_control_backup_dir_name'");
if ($sql_bro->num_rows() > 0)
{
$is_backup_folder = true;
}
else
{
$is_backup_folder = false;
}
// **************************************
// Get File statistics for the status bar
// and for controling Pages
// **************************************
$lastlogin = fGetLastLogin();
//if ($default->show_file_stats == 1)
//{
fGetStatusBarCount();
//}
$iFileCount = $iFolderCount + $iFileCount;
$whereclause = "";
$DBFolderCount = 0;
$sql = new Owl_DB;
if ($default->hide_backup == 1 and !fIsAdmin())
{
$sql->query("SELECT * from $default->owl_folders_table where parent = '$parent' AND name = '$default->version_control_backup_dir_name'");
if ($sql->num_rows() > 0)
{
$DBFolderCount++; //count number of filez in db 2 use with array
$DBFolders[$DBFolderCount] = '$default->version_control_backup_dir_name'; //create list if files in
}
$whereclause = " AND name <> '$default->version_control_backup_dir_name'";
}
if (isset($page))
{
$iCurrentPage = $page;
$nextfolders = ($default->records_per_page * $page);
$nextfiles = 0;
}
if ($default->records_per_page > 0)
{
$sLimit = "LIMIT $nextfolders,$default->records_per_page";
$sql->query("SELECT * from $default->owl_folders_table where parent = '$parent' $whereclause order by name $sLimit");
$iNumberFoldersDisplayed = $sql->num_rows();
$iSaveNextfolders = $nextfolders;
$iSaveNextfiles = $nextfiles - $iNumberFoldersDisplayed;
$iSaveDisplayFiles = $bDisplayFiles;
$iSaveFileCount = $iFileCount;
$iSaveCurrentPage = $iCurrentPage;
if ($iNumberFoldersDisplayed < $default->records_per_page)
{
$bDisplayFiles = true;
if (isset($page))
{
$iNumberOfPages = (int) (($iFolderCount / $default->records_per_page));
//$iNumberOfPages = ($iNumberOfPages == 0) ? 1 :((int) round($iNumberOfPages + 0.4999));
$iNumberOfPages = ($iNumberOfPages == 0) ? 1 :((int) round($iNumberOfPages + 0.51111));
$iPageLeft = $page - $iNumberOfPages;
if ($iFolderCount == 0 );
{
if($iPageLeft < 0)
{
$iPageLeft = 0;
}
else
{
$iPageLeft++;
}
}
$iCorrection = 0;
if($iFolderCount <> 0)
{
$iCorrection = $iFolderCount % $default->records_per_page;
}
if ($nextfiles == 0 and $iNumberFoldersDisplayed > 0)
{
$nextfiles = 0;
}
else
{
$nextfiles = ($default->records_per_page * $iPageLeft) - $iNumberFoldersDisplayed - $iCorrection ;
}
if ($nextfiles < 0)
{
$nextfiles = $nextfiles + $default->records_per_page;
}
}
}
else
{
$bDisplayFiles = false;
}
if ($iNumFilesPerPage != $default->records_per_page)
{
$inextfiles = $nextfiles - $iNumberFoldersDisplayed;
}
}
// *********************************
// Display the Header Tool Bar BEGIN
// *********************************
print("<center>");
if ($default->owl_version_control == 1 && ! $default->owl_use_fs)
{
$qGetFiles = "SELECT f1.id as file_id , f1.major_revision, f1.minor_revision, f1.major_revision+(f1.minor_revision/1000.0) AS mval FROM files f1, files f2 WHERE f1.name=f2.name AND f1.parent=f2.parent AND f1.parent='$parent' AND f1.approved ='1' GROUP BY f1.id, f1.major_revision, f1.minor_revision, f1.$order HAVING f1.major_revision+(f1.minor_revision/1000.0) = max(f2.major_revision+(f2.minor_revision/1000.0)) ORDER BY f1.$order $sort";
$sql->query($qGetFiles);
$FileQuery = ("SELECT * FROM $default->owl_files_table where '1' = '0'");
while ($sql->next_record())
{
$FileQuery .= " OR id = '" . $sql->f("file_id") ."'";
}
//$FileQuery = "select f1.*, f1.major_revision+(f1.minor_revision/1000.0) as mval from $default->owl_files_table f1, $default->owl_files_table f2 where f1.approved = '1' and f1.name=f2.name AND f1.parent=f2.parent AND f1.parent=$parent group by f1.id having f1.major_revision+(f1.minor_revision/1000.0) = max(f2.major_revision+(f2.minor_revision/1000.0)) order by f1.$order $sort";
//$FileQuery = "select f1.*, f1.major_revision+(f1.minor_revision/1000.0) as mval from $default->owl_files_table f1, $default->owl_files_table f2 where f1.name=f2.name AND f1.parent=f2.parent AND f1.parent=$parent group by f1.id having f1.major_revision+(f1.minor_revision/1000.0) = max(f2.major_revision+(f2.minor_revision/1000.0)) order by f1.$order $sort";
$MenuFileQuery = $FileQuery;
}
else
{
if ($order == "major_minor_revision")
{
$order_clause = "major_revision $sort, minor_revision $sort";
}
else
{
$order_clause = "$order $sort";
}
$sLimit = "";
if ($default->records_per_page > 0)
{
$iNumFilesPerPage = $default->records_per_page - $iNumberFoldersDisplayed;
$sLimit = "LIMIT $nextfiles,$iNumFilesPerPage";
}
// Query TO retreive the Files in the current Folder
$FileQuery = "select * from $default->owl_files_table where parent = '$parent' order by $order_clause $sLimit";
$MenuFileQuery = "select * from $default->owl_files_table where parent = '$parent' and approved = '1' order by $order_clause $sLimit";
}
$CountLines = 0;
$sLimit = '';
if ($default->records_per_page > 0)
{
$sLimit = "LIMIT $nextfolders,$default->records_per_page";
}
if ($order == "creatorid")
{
$FolderQuery = "SELECT * from $default->owl_folders_table where parent = '$parent' $whereclause order by $order $sortname $sLimit";
}
else
{
$FolderQuery = "SELECT * from $default->owl_folders_table where parent = '$parent' $whereclause order by name $sortname $sLimit";
}
if(!$default->old_action_icons)
{
$mid = new LayersMenu();
$mid->setDirroot($default->owl_fs_root . "/scripts/phplayersmenu/");
$mid->setImgwww($default->owl_root_url . '/scripts/phplayersmenu/menuimages/');
if (substr(php_uname(), 0, 7) != "Windows")
{
$mid->setIcondir($default->owl_fs_root . "/graphics/$default->sButtonStyle/icon_action/");
}
else
{
$mid->setIcondir(ereg_replace("([A-Z]\:|[a-z]\:)", "", ereg_replace("[\\]", "/",$default->owl_fs_root)) . "/graphics/$default->sButtonStyle/icon_action/");
}
$mid->setIconwww($default->owl_graphics_url . "/$default->sButtonStyle/icon_action/");
$mid->setIconsize(17, 20);
fSetupFileActionMenus($MenuFileQuery);
fSetupFolderActionMenus($FolderQuery);
$mid->printHeader();
}
//FOR_FOLDERS
if ($expand == 1)
{
print("<table class=\"border1\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"$default->table_expand_width\"><tr><td align=\"center\" valign=\"top\" width=\"100%\">\n");
}
else
{
print("<table class=\"border1\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"$default->table_collapse_width\"><tr><td align=\"center\" valign=\"top\" width=\"100%\">\n");
}
fPrintButtonSpace(4, 1);
print("<table class=\"border2\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td align=\"left\" valign=\"top\" width=\"100%\">\n");
if ($default->show_prefs == 1 or $default->show_prefs == 3)
{
fPrintPrefs("infobar1", "top");
}
// *******************************
// Display the Header Tool Bar END
// *******************************
fPrintPanel($default->display_file_info_panel_wide);
if ($default->show_search == 1 or $default->show_search == 3 or (fIsAdmin() and $default->show_search == 0))
{
fPrintSearch();
fPrintSpacer();
}
fPrintVaroriteLink();
if (check_auth($parent, "folder_create", $userid, false, false) == 1 or check_auth($parent, "folder_view", $userid, false, false) == 1 && !$is_backup_folder)
{
if ($sess != "0" || ($sess == "0" && $default->anon_ro == 0))
{
if ($default->show_bulk > 0 or (fIsAdmin() and $default->show_bulk == 0 ))
{
if (check_auth($parent, "folder_view", $userid, false, false) == 1)
{
fPrintBulkButtons();
}
}
if ($default->show_action == 1 or $default->show_action == 3 or (fIsAdmin() and $default->show_action == 0))
{
//if (check_auth($parent, "folder_create", $userid, false, false) == 1)
//{
fPrintActionButtons();
//}
}
}
}
if ($default->show_folder_tools == 1 or $default->show_folder_tools == 3)
{
fPrintFolderTools($nextfolders, $inextfiles, $bDisplayFiles, $iFileCount, $iCurrentPage);
}
fPrintNavBar($parent);
if ($curview == 0)
{
require_once ($default->owl_fs_root . "/view_default.php");
}
else
{
require_once ($default->owl_fs_root . "/view_thumb.php");
}
if ($default->show_folder_tools == 2 or $default->show_folder_tools == 3)
{
fPrintFolderTools($iSaveNextfolders, $inextfiles, $iSaveDisplayFiles, $iSaveFileCount, $iSaveCurrentPage);
}
if (check_auth($parent, "folder_create", $userid, false, false) == 1 or check_auth($parent, "folder_view", $userid, false, false) == 1 && !$is_backup_folder)
//if (check_auth($parent, "folder_modify", $userid, false, false) == 1 or check_auth($parent, "folder_upload", $userid, false, false) == 1 && !$is_backup_folder)
{
if ($sess != "0" || ($sess == "0" && $default->anon_ro == 0))
{
if ($default->show_action == 2 or $default->show_action == 3 )
{
//if (check_auth($parent, "folder_create", $userid, false, false) == 1)
//{
fPrintActionButtons(1);
//}
}
if ($default->show_bulk > 0)
{
if (check_auth($parent, "folder_view", $userid, false, false) == 1)
{
fPrintBulkButtons(1);
}
}
else
{
print("</form>");
}
}
}
else
{
print("</form>");
}
if ($default->show_search == 2 or $default->show_search == 3)
{
fPrintSearch(1);
fPrintSpacer();
fPrintButtonSpace(12, 12);
}
fPrintButtonSpace(12, 1);
if ($default->show_prefs == 2 or $default->show_prefs == 3)
{
fPrintPrefs("infobar2");
}
print("</td></tr>");
print("</table>");
// *******************************
// If the refresh from hard drive
// feature is enabled
// *******************************
//
if ($default->owl_use_fs)
{
if ($default->owl_LookAtHD != "false")
{
//print_r($DBFiles);
//exit;
if ($RefreshPage == true)
{
CompareDBnHD('file', $default->owl_FileDir . "/" . get_dirpath($parent), $DBFiles, $parent, $default->owl_files_table);
}
else
{
$RefreshPage = CompareDBnHD('file', $default->owl_FileDir . "/" . get_dirpath($parent), $DBFiles, $parent, $default->owl_files_table);
}
if ($RefreshPage == true)
{
print('<script type="text/javascript">');
print('window.location.reload(true);');
print('</script>');
}
}
}
if(!$default->old_action_icons)
{
$mid->printFooter();
}
if($default->debug == true)
{
$diff = time()-$dStartTime;
$minsDiff = floor($diff/60);
$diff -= $minsDiff*60;
$secsDiff = $diff;
print("<div class=\"owlbar1\">($owl_lang->elapsed_time ".$minsDiff.'m '.$secsDiff.'s)'."</div>");
}
include_once($default->owl_fs_root. "/lib/footer.inc");
?>
|