home *** CD-ROM | disk | FTP | other *** search
/ PCNet 2006 April / PCnet 2006-06.4.iso / shareware / nmsetup.exe / WebServer / web / shareview.php < prev    next >
Encoding:
PHP Script  |  2006-05-01  |  36.1 KB  |  830 lines

  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // <!--Copyright (c) 2005 Pure Networks Inc.  All rights reserved.-->
  4. ////////////////////////////////////////////////////////////////////////////////
  5. //
  6. // Build: 3.0.6121.0 (Stable)
  7. // $Revision: #3 $
  8. //
  9.  
  10. $sNavLocation       =   "folders";
  11. $sNavPage           =   "folders";
  12. $sLocation          =   ""; // later defined after we connect to the share
  13. $bReadOnly          =   true;
  14. $bUploadsEnabled    =   false;
  15. require '_session_common.php';
  16.  
  17. ///////////////////////////////////////////////////
  18. // Has to be here so that the cookies are first header wise...
  19. // Let's see if the view_mode cookie (thumbnail versus file list) is set and pull the value
  20. // if it's not set, we set it here, this determines which UI we will show
  21. ///////////////////////////////////////////////////
  22. $sViewMode = "photo";
  23. if (!isset($_COOKIE['view_mode']))
  24. {
  25.     // not set, likely first time here on this machine, give them file view
  26.     setcookie("view_mode", "photo", time()+(60*60*24*365*5),"/"); // 60 seconds * 60 minutes * 24 hours * 365 days * 5 years
  27. }
  28. else
  29. {
  30.     // let's get the cookie value first and assign it to our global
  31.     $sViewMode = $_COOKIE['view_mode'];
  32.     // now let's see if our QS has a value
  33.     if (isset($_GET['mode']))
  34.     {
  35.         // We have a QS value - is it valid?
  36.         switch($_GET['mode'])
  37.         {
  38.             case "file":
  39.             case "photo":
  40.                 $sGetVarMode = $_GET['mode'];
  41.                 break;
  42.             default:
  43.                 $sGetVarMode = "photo";
  44.         }
  45.         // does it differ from the cookie? - If so, rewrite the cookie and change our global to the QS value
  46.         if ($sViewMode != $sGetVarMode)
  47.         {
  48.             setcookie("view_mode", $sGetVarMode, time()+(60*60*24*365*5),"/"); // 60 seconds * 60 minutes * 24 hours * 365 days * 5 years
  49.             $sViewMode = $sGetVarMode;
  50.         }
  51.     }
  52. }
  53. ///////////////////////////////////////////////////
  54. // Import the folderutil functions, 
  55. // DEPENDS: needs access to $sGetVarMode
  56. ///////////////////////////////////////////////////
  57. require '_folderutils.php';
  58. ///////////////////////////////////////////////////
  59. // Make sure that we have a valid share passed in.
  60. ///////////////////////////////////////////////////
  61. if (!isset($_GET['share']) or $_GET['share'] == "")
  62. {
  63.     log_activity("QS check", "failure", return_error_text(200, "", $arErrors));
  64.     gotoAbs('/error/200&return=/folders/');
  65.     exit();
  66. }
  67. else
  68. {
  69.     $sShare = $_GET['share'];
  70.     log_activity("view folder share", "info", $sShare);
  71. }
  72. ///////////////////////////////////////////////////
  73. // Make sure that we have a valid page passed in.
  74. ///////////////////////////////////////////////////
  75. if (!isset($_GET['page']) or $_GET['page'] == "")
  76. {
  77.     $iPage = 0;
  78. }
  79. else
  80. {
  81.     $iPage = $_GET['page'];
  82. }
  83.  
  84. ///////////////////////////////////////////////////
  85. // Make sure that we have a valid path passed in.
  86. ///////////////////////////////////////////////////
  87. if (!isset($_GET['path']) or $_GET['path'] == "")
  88. {
  89.     log_activity("QS check", "failure", return_error_text(201, "", $arErrors));
  90.     gotoAbs('/error/201/return');
  91.     exit();
  92. }
  93. else
  94. {
  95.     $sPath = urlDecodeString($_GET['path']);
  96.     log_activity("view folder path", "info", $sPath);
  97. }
  98.  
  99. /////////////////////////////////////////////////////////////////////////////////////////////////
  100. /////////////////////////////////////////////////////////////////////////////////////////////////
  101. // NOTE: we do several try catch blocks so we know exactly which function threw the exception. //
  102. /////////////////////////////////////////////////////////////////////////////////////////////////
  103. /////////////////////////////////////////////////////////////////////////////////////////////////
  104.  
  105. ///////////////////////////////////////////////////
  106. // Let's try to see if we can open the share
  107. ///////////////////////////////////////////////////
  108. try
  109. {
  110.     $nmSharedPlace = $nmNetworkLib->OpenShare($sShare);
  111. }
  112. catch(Exception $ex)
  113. {
  114.     log_activity("Attempting nmNetworkLib->OpenShare($sShare)", "exception", $ex->getMessage());
  115.     gotoAbs('/error/305/return');
  116.     exit();
  117. }
  118. ///////////////////////////////////////////////////
  119. // double check the access level and react
  120. ///////////////////////////////////////////////////
  121. try
  122. {
  123.     $sAccessLevel = $nmSharedPlace->AccessLevel;
  124. }
  125. catch(Exception $ex)
  126. {
  127.     log_activity("Attempting nmSharedPlace->AccessLevel", "exception", $ex->getMessage());
  128.     gotoAbs('/error/305/return');
  129.     exit();
  130. }
  131.  
  132. switch ($sAccessLevel)
  133. {
  134.     case 0:
  135.         ///////////////////////////////////////////////////
  136.         // Public share, show away.
  137.         ///////////////////////////////////////////////////
  138.         break;
  139.     case 1:
  140.         if (!$bLoggedIn)
  141.         {
  142.             ///////////////////////////////////////////////////
  143.             // Private share and user is not logged in, go away.
  144.             ///////////////////////////////////////////////////
  145.             log_activity("private folder request without session", "error", return_error_text(308, "", $arErrors));
  146.             gotoAbs('/login/308');
  147.             exit();
  148.         }
  149.         break;
  150.     case 2:
  151.         ///////////////////////////////////////////////////
  152.         // Restricted share, go away.
  153.         ///////////////////////////////////////////////////
  154.         log_activity("restricted share request", "error", return_error_text(310, "", $arErrors));
  155.         gotoAbs('/login/310');
  156.         exit();
  157.         break;
  158.     default:
  159.         log_activity("Undefined share access level", "error", return_error_text(311, "", $arErrors));
  160.         gotoAbs('/login/311');
  161.         exit();
  162. }
  163.  
  164. ///////////////////////////////////////////////////
  165. // Increment the share viewings counter
  166. ///////////////////////////////////////////////////
  167. try
  168. {
  169.     $nmNetworkLib->IncrementViewingCount($nmSharedPlace);
  170. }
  171. catch (exception $ex)
  172. {
  173.     log_activity("share view counter", "exception", $ex->getMessage());
  174. }
  175.  
  176. ///////////////////////////////////////////////////
  177. // 1) see if it is offline and shuttle to error with proper code.
  178. // 2) see if we can get the share information off the filesystem
  179. // 3) validate that the path is contained within the filesystem.
  180. // 4) Get a pointer to a folder - don't read it into arrays yet.
  181. ///////////////////////////////////////////////////
  182. try
  183. {
  184.     if (!$nmSharedPlace->IsOnline)
  185.     {
  186.         log_activity("folder view", "error", return_error_text(303, "", $arErrors));
  187.         gotoAbs('/error/303/return');
  188.         exit();
  189.     }
  190.     $sContainer = getShareTitle($nmSharedPlace);
  191.     $sLocation = $nmSharedPlace->Location; // we now have the info needed to define this
  192.     $sUnc = $nmSharedPlace->Unc;
  193.     $sFolderPath = $sPath;
  194.     $sFolderShortPath = basename($sFolderPath);
  195. }
  196. catch(Exception $ex)
  197. {
  198.     log_activity("folder view", "exception", $ex->getMessage());
  199.     gotoAbs('/error/306/return');
  200.     exit();
  201. }
  202. ///////////////////////////////////////////////////
  203. // the path does not match up to the share path 
  204. // NOTE - Possible security attack. - error page
  205. ///////////////////////////////////////////////////
  206.  
  207. if (strncasecmp($sFolderPath, $sUnc, strlen($sUnc)) != 0)
  208. {
  209.     log_activity("folder view", "error", return_error_text(301, "", $arErrors));
  210.     gotoAbs('/error/301');
  211.     exit();
  212. }
  213.  
  214. ///////////////////////////////////////////////////
  215. // Need to verify that the folder still exists
  216. // This only works if this is a real folder path - not the root UNC path
  217. ///////////////////////////////////////////////////
  218. if ((strcmp($sFolderPath, $sUnc) != 0) && !file_exists($sFolderPath))
  219. {
  220.     $return = "";
  221.     if (isset($_SERVER['HTTP_REFERER']))
  222.     {
  223.         $return = $_SERVER['HTTP_REFERER'];
  224.     }
  225.     
  226.     // folder couldn't be found, so we wipe the folder session vars, and ship them to error page
  227.     unset($_SESSION['currentFolderInfo']);
  228.     unset($_SESSION['currentFolderFiles']);
  229.     log_activity("folder view", "failure", return_error_text(302, "", $arErrors));
  230.     gotoAbs('/error/302/return');
  231.     exit();
  232. }
  233.  
  234. createSessionFileArrays($sShare, $sPath, $sFolderPath, $nmSharedPlace, true, $iPage);
  235.  
  236. $count = count($arFiles);
  237. $pageNumber = returnPageNumber($count, $ObjectsPerPage, $iPage);
  238. $sPagination = returnPaginationString($count, $ObjectsPerPage, $iPaginationBuffer, $pageNumber);
  239.  
  240. ///////////////////////////////////////////////////
  241. // 1) see if uploads are enabled
  242. // 2) see if the folder is read only
  243. ///////////////////////////////////////////////////
  244. try
  245. {
  246.     $bUploadEnabled = $nmRaManager->UploadsEnabled;
  247.     $bReadOnly      = $nmSharedPlace->ReadOnly;
  248. }
  249. catch (exception $ex)
  250. {
  251.     log_activity("RO & Uploads enabled check", "exception", $ex->getMessage());
  252.     gotoAbs('/error/307/return');
  253.     exit();
  254. }
  255. //set up variables needed by the header file.
  256. if (file_exists($sFolderPath . "\folderheader.n2g"))
  257. {
  258.     $filename = $sFolderPath . "\folderheader.n2g";
  259.     $handle = fopen($filename, "rb");
  260.     $sIntroText = str_replace("\r\n","<br/>",fread($handle, filesize($filename)));
  261.     fclose($handle);
  262.     // if we're in public view, let's display welcome text and/or message.
  263.     $sIntroRow = "<tr><td colspan=\"4\">";
  264.     $sIntroRow .= "<div class=\"WelcomeMessage\">";
  265.     $sIntroRow .= $sIntroText;
  266.     $sIntroRow .= "</div>";
  267.     $sIntroRow .= "</td></tr>";
  268. }
  269. ///////////////////////////////////////////////////
  270. // start printing out the HTML to the browser
  271. ///////////////////////////////////////////////////
  272. require "_header.php";
  273. ?>
  274.     <table cellspacing="0" cellpadding="0" border="0" width="100%">
  275.         <tr>
  276.             <td valign="top" width="100%">
  277.                 <?php require "_public_error_states.php"; ?>
  278.                 <!-- Start Folder view table -->
  279.                     <table cellspacing="0" cellpadding="0" border="0" class="ContentTable"> 
  280.                     <?php echo ($sIntroRow); ?>
  281.                         <tr>
  282.                             <td class="ContentTableTL"><div><img src="/images/pixel.trans.gif" width="1" height="1" alt=""></div></td>
  283.                                 <?php printBreadcrumbs($sShare, $sUnc, $sFolderPath, $sContainer, $iBreadCrumbTruncateLength, $count, $ObjectsPerPage, $iPage, false); ?>
  284.                                             <?php
  285.                                             if (count($arFiles) > 0)
  286.                                             {
  287.                                             ?>
  288.                                 <form method="get" name="viewform" id="viewform" action="shareview.php">
  289.                             <td class="ContentTableTM3">
  290.                             <nobr>
  291.                                 <div class="ContentTableHeadRight">
  292.                                 View:
  293.                                         <select id="mode" name="mode" onchange="submitFolderViewForm();">
  294.                                             <option value="file" <?php if ($sViewMode == "file") { echo (" selected"); } ?>>  List
  295.                                             <option value="photo" <?php if ($sViewMode == "photo") { echo (" selected"); } ?>>  Thumbnails  
  296.                                         </select>
  297.                                         <input type="hidden" id="page" name="page" value="<?php echo($pageNumber);?>">
  298.                                         <input type="hidden" id="share" name="share" value="<?php echo($sShare);?>">
  299.                                         <input type="hidden" id="path" name="path" value="<?php echo(urlEncodeString($sFolderPath));?>">
  300.                                 </div>
  301.                             </nobr>
  302.                             </td>
  303.                                 </form>
  304.                                 <script type="text/javascript" language="JavaScript">
  305.                                     function submitFolderViewForm()
  306.                                     {
  307.                                         sShare = document.getElementById('share').value;
  308.                                         sPath  = document.getElementById('path').value;
  309.                                         sUrl = "/folderview/" + sShare + "/" + sPath
  310.                                         sUrl += "?mode=" + document.getElementById('mode').value + 
  311.                                                 "&page=" + document.getElementById('page').value;
  312.                                         location.href = sUrl;
  313.                                     }
  314.                                 </script>
  315.                                             <?php
  316.                                             }
  317.                                             else
  318.                                             {
  319.                                             ?>
  320.                             <td class="ContentTableTM3"> </td>                                            
  321.                                             <?php
  322.                                             }
  323.                                             ?>
  324.                                 </div>
  325.                             </td>
  326.                             <td class="ContentTableTR"><div> </div></td>
  327.                         </tr>
  328.                         <tr>
  329.                             <td class="ContentTableML"><div> </div></td>
  330.                             <td class="ContentTableMM" colspan="3">
  331. <!--<hr align=left style="border: solid gray 0.5px; width: 400px; margin-left: 60px">-->
  332. <div class="ShareContents">
  333. <?php
  334.     if ($bPagination)
  335.     {
  336.         echo $sPagination;
  337.         echo ("        <br/><div class=\"FolderHR\"> </div>");
  338.     }
  339.     
  340.     // MAC OSX IE requires a different style for the thumbnail contain that does not have a clear in it since
  341.     // it wronlgy inherits this to child elements
  342.     $sNoClear = "";
  343.     if ($btBrowserType == "macosxie")
  344.     {
  345.         $sNoClear = "NoClear";
  346.     }
  347.     
  348. ?>
  349.     <div class="ThumbnailContain<?php echo($sNoClear);?>">
  350.     <?php
  351.         // since we're in fileview mode, we start the table that we use to display the info in nice fixed width columns
  352.         if ($sViewMode == "file")
  353.         {
  354. ?>        
  355.             <table border="0" cellspacing="0" cellpadding="0" id="FileList" name="FileList" class="FileViewTable">
  356. <?php        
  357.         }
  358.         else
  359.         {
  360. ?>
  361.             <table width="0" height="0" border="0" cellspacing="0" cellpadding="0" id="FileList" name="FileList"><tr><td></td></tr></table>
  362. <?php
  363.         }
  364.         
  365.         // we have a file array, let's display the folder/files information
  366.         if (count($arFiles) > 0)
  367.         {
  368.             // Display the current page of files $arFolder) - $iSubFolderCount
  369.             $pageArray = array_slice($arFiles, (($pageNumber-1) * $ObjectsPerPage), $ObjectsPerPage);
  370.         
  371.             $j = 0;
  372.  
  373.             //display the header row for file view mode
  374.             if ($sViewMode == "file")
  375.             {
  376.             ?>
  377.             <tr id="FileListHeader" name="FileListHeader">
  378.                 <th class="FileViewFilename FileViewHeader ThumbnailTextfile">Name</th>
  379.                 <?php
  380.                 if (!$bForceFileAction)
  381.                 {
  382.                 ?>
  383.                     <th class="FileViewAction FileViewHeader ThumbnailTextfile">Action</th>                
  384.                 <?php
  385.                 }
  386.                 ?>
  387.                 <th class="FileViewSize FileViewHeader ThumbnailTextfile">Size</th>
  388.                 <th class="FileViewType FileViewHeader ThumbnailTextfile">Type</th>
  389.             </tr>
  390.             <?php
  391.             }
  392.             // setup the filetype of teh first item.
  393.             $sLastFileType = $pageArray[0][1];
  394.             $iCount = 0;
  395.             foreach($pageArray as $fileName)
  396.             {
  397.                 $iCount++;
  398.                 $sFile = $fileName[0];
  399.                 // we use the info that if the file is a photo or file multiple times, let's only check once.
  400.                 $sCurrentFileType = $fileName[1];
  401.                 $bFileIsDirectory = false;
  402.                 if ($fileName[1] == "0") // per (file types) legend 0 = folder
  403.                 {
  404.                     $bFileIsDirectory = true;
  405.                 }
  406.                 $sFileExtension = strrchr($sFile, ".");
  407.                 $bSupportedExtension = true;
  408.                 if (isValidString($sFileExtension))
  409.                 {
  410.                     $bSupportedExtension = isSupportedDownloadExtension($sDownloadUnsupportedExtensions, $sFileExtension);
  411.                 }
  412.                 $sFilenameForDisplay = urlDecodeString($fileName[0]);
  413.                 $sFullFilePath = $sFolderPath . "\\" . $sFile;
  414.                 // file view file size column.  Files (photo and non photo) get their true size, while
  415.                 // directories display the text "(Directory)"
  416.                 if (!$bFileIsDirectory) 
  417.                 {
  418.                     $sFileSize =  str_replace(" ", " ", bytesToHumanReadableUsage(filesize(urlDecodeString($sFullFilePath)),1));
  419.                 }
  420.                 else
  421.                 {
  422.                     $sFileSize = ("--");
  423.                 }
  424.                 $detailslink    =   "/filedetails/" . $sShare . "/" . urlEncodeString($sFullFilePath);
  425.                 // now we have to scramble the format a bit and pop the filename on teh end of the URL.
  426.                 $iFileNamePos   = strpos($sFullFilePath, strrchr($sFullFilePath, "\\"));
  427.                 //$sFile          = substr($sFullFilePath, $iFileNamePos+1);
  428.                 $sPathNoFile    = substr($sFullFilePath, 0, (strlen($sFullFilePath) - strlen($sFile) - 1));
  429.                 $downloadlink = "/filesave/" . $sShare . "/" . urlEncodeString($sPathNoFile) . "/" . urlEncodeString($sFile);
  430.                 $folderlink = "/folderview/" . $sShare . "/" . urlEncodeString($sFolderPath . "\\" . $sFile);
  431.                 $thumbnaillink = "/thumbnail/" . $sShare . "/" . urlEncodeString($sPathNoFile) . "/" . urlEncodeString($sFile);
  432.                 if ($bSupportedExtension)
  433.                 {
  434.                     $viewlink = "/fileview/" . $sShare . "/" . urlEncodeString($sFullFilePath)
  435.                         . "/" . urlEncodeString($fileName[0]) . "?fileNum=" 
  436.                         . ((($pageNumber - 1)*$ObjectsPerPage) + $iCount) . "&page=" . $pageNumber;
  437.                     if ($bForceFileAction)
  438.                     {
  439.                         $openlink = $downloadlink;
  440.                     }
  441.                     else
  442.                     {
  443.                         $openlink = "/fileopen/" . $sShare . "/" . urlEncodeString($sPathNoFile) . "/" . urlEncodeString($sFile);
  444.                     }
  445.  
  446.                 }
  447.                 else
  448.                 {
  449.                     $viewlink = "javascript:alertFileNotAvailable();";
  450.                     $openlink = "javascript:alertFileNotAvailable();";
  451.                 }
  452.                 // we'll target new if this is an internet shortcut, so it opens the link in a new browser
  453.                 $sTarget = " target=\"_new\" ";
  454.  
  455.                 if ($sViewMode == "photo")
  456.                 {
  457.                     // check to see current vs last file type
  458.                     if ($sLastFileType <> $sCurrentFileType)
  459.                     {
  460.                         // last file is of different type, let's end the current thumbnail div container and start a new one
  461.                         // so that the differnt types appear separated instead of on the same line/.
  462.                         echo ("</div><br/><div class=\"FolderHR\"> </div><div class=\"ThumbnailContain" . $sNoClear . "\"><!--xxc-->");
  463.                     }
  464.                     $sLastFileType = $sCurrentFileType;
  465.  
  466.                     if ($bFileIsDirectory) 
  467.                     {
  468.                         // thumbnail view, folder thumbnails
  469.                     ?>
  470.                             <div class="Folder">
  471.                                 <div class="FolderImage" onclick="location.href='<?php echo ($folderlink); ?>'"> </div>
  472.                     <?php
  473.                     }
  474.                     else if ($sCurrentFileType == "1") // 1 is a photo per the (file types) legend
  475.                     {
  476.                         // thumbnail view, photo file thumbnails
  477.                         $sTextType = "";
  478.                     ?>
  479.             <div class="Thumbnail<?php echo($sViewMode . $sTextType);?>"> <!-- Start of div xx -->
  480.                     <div id="TN<?php echo ($iCount); ?>" class="ThumbnailImage<?php echo($imgMode);?>" onmouseover="javascript:(mouseoverSelection('TN<?php echo ($iCount); ?>', 'ThumbnailImage<?php echo($imgMode);?>Hover'));" onmouseout="javascript:(mouseoutSelection('TN<?php echo ($iCount); ?>', 'ThumbnailImage<?php echo($imgMode);?>'));" onclick="javascript:(changeSelection('TN<?php echo ($iCount); ?>', 'ThumbnailImage<?php echo($imgMode);?>Select', '<?php echo ($viewlink);?>', false, '<?php echo ($bSupportedExtension); ?>'));" title="View details for file '<?php echo($sFilenameForDisplay);?>'.">
  481.                             <a class=link href="<?php echo ($viewlink);?>" title="View details for file '<?php echo($sFilenameForDisplay);?>'.">
  482.                             <img src="<?php echo $thumbnaillink;?>" border="0" alt="<?php echo ($sFilenameForDisplay);?>"/></a>
  483.                     </div>
  484.                     <?php
  485.                     }
  486.                     else
  487.                     {
  488.                         // thumbnail view, non photo file thumbnails
  489.                         // icon text is wider and appears to the right in thumbnail view
  490.                         $sTextType = "Icon";
  491.                     ?>
  492.             <div id="TN<?php echo ($iCount); ?>" class="Thumbnail<?php echo($sViewMode . $sTextType);?>" onmouseover="javascript:(mouseoverSelection('TN<?php echo ($iCount); ?>', 'Thumbnail<?php echo($sViewMode . $sTextType);?>Hover'));" onmouseout="javascript:(mouseoutSelection('TN<?php echo ($iCount); ?>', 'Thumbnail<?php echo($sViewMode . $sTextType);?>'));" onclick="javascript:(changeSelection('TN<?php echo ($iCount); ?>', 'Thumbnail<?php echo($sViewMode . $sTextType);?>Select', '<?php echo ($openlink);?>', true, '<?php echo ($bSupportedExtension); ?>'));" title="Open file '<?php echo($sFilenameForDisplay);?>'."> <!-- Start of div xx -->
  493.                     <div class="ThumbnailIcon"><img src="<?php echo $thumbnaillink;?>" border="0" alt="<?php echo ($sFilenameForDisplay);?>" border="0" /></div>
  494.                     <?php
  495.                     }
  496.                     // Different truncation widths for thumbnail view versus file view
  497.                     $iFileNameTruncateLength = $iFileNameThumbnailTruncateLength;
  498.                     if ($bFileIsDirectory) 
  499.                     {
  500.                         // thumbnail view folder text info and links
  501.                 ?>
  502.                         <div class="FolderText Clip">
  503.                             <a class=link href="<?php echo ($folderlink); ?>" title="Open folder '<?php echo($sFilenameForDisplay);?>'."><?php echo htmlentities(truncate_string($sFilenameForDisplay, $iFolderNameTruncateLength, "...", "right",true)); ?></a>
  504.                         </div>
  505.                 <?php
  506.                     }
  507.                     else 
  508.                     {
  509.                         if ($sCurrentFileType == "1") // 1 is a photo per the (file types) legend
  510.                         {
  511.                             $iFileNameTruncateLength    = $iFileNameThumbnailTruncateLength;
  512.                             $sFileDetailsLine1          = "<span><a class=\"ThumbnailTextfile\" href=\"" . $viewlink . "\">" . htmlspecialchars(truncate_string($sFilenameForDisplay, $iFileNameTruncateLength, "...", "right", true)) . "</a></span>";
  513.                             $sFileDetailsLine2          = "<a class=link href=\"" . htmlentities($downloadlink) . "\" title=\"Save file '" . $sFilenameForDisplay . "'.\">Save</a>";
  514.                             $sViewFileLink              = $viewlink;
  515.                         }
  516.                         else
  517.                         {
  518.                             $iFileNameTruncateLength    = $iFileNameThumbIconTruncateLength;
  519.                             $sFileDetailsLine1          = "<span style=\"color:#0A2966; font-weight:bold;\">" . htmlspecialchars(truncate_string($sFilenameForDisplay, $iFileNameTruncateLength, "...", "right", true)) . "</span>";
  520.                             $sFileDetailsLine2          = $sFileSize;
  521.                             $sViewFileLink              = $openlink;
  522.                         }
  523.                         // thumbnail view photo file and non photo file text info and links
  524.                     ?>
  525.                         <div class="ThumbnailText<?php echo($sViewMode . $sTextType);?>"> <!--  $iFileNameTruncateLength  -->
  526.                             <?php echo($sFileDetailsLine1);?>
  527.                             <br/>
  528.                             <?php echo($sFileDetailsLine2);?>
  529.                         </div>
  530.                     <?php
  531.                     }
  532.                     echo ("</div> <!-- end of thumnbail div -->");
  533.                 }
  534.                 else
  535.                 {
  536.                     // file view file (photo and non photo) text info and links
  537.                     $iFileNameTruncateLength = $iFileNameFileViewTruncateLength;
  538.                     if ($bFileIsDirectory)
  539.                     {
  540.                         $sViewLink  = $folderlink;
  541.                         $sViewTitle = "Open folder ";
  542.                         $sViewTarget= "";
  543.                         $sViewJscriptLaunch = "javascript:location.href='" . $sViewLink . "';";
  544.                     }
  545.                     else
  546.                     {
  547.                         if ($sCurrentFileType == "1") // 1 is a photo per the (file types) legend
  548.                         {
  549.                             $sViewLink  = $viewlink;
  550.                             $sViewTitle = "View";
  551.                             $sViewTarget= "";
  552.                             $sViewJscriptLaunch = "javascript:location.href='" . $sViewLink . "';";
  553.                         }
  554.                         else
  555.                         {
  556.                             $sViewLink  = $openlink;
  557.                             $sViewTitle = "Open";
  558.                             $sViewTarget= "_new";
  559.                             if (!$bSupportedExtension)
  560.                             {
  561.                                 $sViewJscriptLaunch = "javascript:alertFileNotAvailable();";
  562.                             }
  563.                             else
  564.                             {
  565.                                 $sViewJscriptLaunch = "javascript:openContentWindow('" . $sViewLink . "');";
  566.                             }
  567.                         }
  568.                         
  569.  
  570.                     }
  571.                 ?>
  572.                 <tr class="FileViewRow">
  573.                     <td class="FileViewFilename ThumbnailTextfile" onclick="<?php echo ($sViewJscriptLaunch);?>" title="<?php echo($sViewTitle); ?> '<?php echo($sFilenameForDisplay);?>'.">
  574.                         <?php echo(htmlspecialchars(truncate_string($sFilenameForDisplay, $iFileNameFileViewTruncateLength, "...", "right", true)));?>
  575.                     </td>
  576.                 <?php
  577.                 if (!$bForceFileAction)
  578.                 {
  579.                 ?>
  580.                     <td class="FileViewAction ThumbnailTextfile">
  581.                         <?php 
  582.                         if ($bFileIsDirectory)
  583.                         {
  584.                             // file view directory link information
  585.                         ?>
  586.                             <a class=link href="<?php echo ($folderlink); ?>" title="Open folder '<?php echo($sFilenameForDisplay);?>'">Open Folder</a>
  587.                         <?php
  588.                         }
  589.                         else
  590.                         {
  591.                             if ($bSupportedExtension)
  592.                             {
  593.                         ?>
  594.                                 <a class=link href="<?php echo (htmlentities($sViewLink));?>" target="<?php echo $sViewTarget;?>" title="<?php echo $sViewTitle;?> '<?php echo($sFilenameForDisplay);?>'."><?php echo $sViewTitle;?></a> |
  595.                                 <a class=link href="<?php echo (htmlentities($downloadlink));?>" target="<?php echo $sViewTarget;?>"  title="Download file '<?php echo($sFilenameForDisplay);?>'.">Download</a>
  596.                         <?php
  597.                             }
  598.                             else
  599.                             {
  600.                         ?>
  601.                                 not available
  602.                         <?php
  603.                             }
  604.                         }
  605.                         ?>
  606.                     </td>
  607.                 <?php
  608.                 }
  609.                 ?>
  610.                     <td class="FileViewSize ThumbnailTextfile" onclick="<?php echo ($sViewJscriptLaunch);?>" title="<?php echo($sViewTitle); ?> '<?php echo($sFilenameForDisplay);?>'.">
  611.                         <?php
  612.                             echo $sFileSize;
  613.                          ?>
  614.                     </td>
  615.                     <td class="FileViewType ThumbnailTextfile" onclick="<?php echo ($sViewJscriptLaunch);?>" title="<?php echo($sViewTitle); ?> '<?php echo($sFilenameForDisplay);?>'.">
  616.                         <?php 
  617.                         $sFileTypeDescription = "";
  618.                         try
  619.                         {
  620.                             $sFileTypeDescription = str_replace(" ", " ", truncate_string($nmSharedPlace->GetFileTypeDescription($sFullFilePath), $iFileTypeFileViewTruncateLength, "...", "right", true));
  621.                         }
  622.                         catch (exception $ex)
  623.                         {
  624.                             // log here?
  625.                         }
  626.                          if (!$bFileIsDirectory)
  627.                          {
  628.                             echo($sFileTypeDescription);
  629.                          }
  630.                          else
  631.                          {
  632.                             echo ("Folder");
  633.                          }
  634.                         ?>
  635.                     </td>
  636.                 </tr>
  637.                 <?php
  638.                 }
  639.             }
  640.             if ($sViewMode == "file")
  641.             {
  642.                 echo ("</table>"); // end the table we started for fileview mode
  643.             }
  644.         }
  645.         else
  646.         {
  647.             writeNoContentMessage($bUploadEnabled, $bReadOnly, $sAccessLevel);
  648.         }
  649. ?>
  650.         </div> <!-- ThumbnailContain -->
  651. <?php
  652.     if ($bPagination)
  653.     {
  654.         echo ("        <div class=\"FolderHR\"> </div>");
  655.         echo $sPagination;
  656.     }
  657. ?>
  658.             <div class="ClearNbsp"> </div>
  659. </div> <!--ShareContents-->
  660.                             </td>
  661.                             <td class="ContentTableMR"> </td>
  662.                         </tr>
  663.                         <tr>
  664.                             <td class="ContentTableBL"> </td>
  665.                             <td class="ContentTableBM" colspan="3"> </td>
  666.                             <td class="ContentTableBR"> </td>
  667.                         </tr>
  668.                     </table> <!-- End Folder View Table -->
  669.                 </td>
  670.                 <td valign="top">
  671. <?php   
  672. ///////////////////////////////////////////////////
  673. // Define the tasks for this page
  674. ///////////////////////////////////////////////////
  675. $iTaskCount = 0;
  676. if ($arSharePath[3]) // this is the slideshow true or false information
  677. {
  678.     $arTasks[$iTaskCount][0] = "View slideshow";
  679.     $arTasks[$iTaskCount][1] = "javascript:openSlideshow('/slideshow/" . $sShare . "/" . urlEncodeString($sFolderPath) . "/');";
  680.     $arTasks[$iTaskCount][2] = "SlideshowLink";
  681.     $arTasks[$iTaskCount][3] = "";
  682.     $iTaskCount++;
  683. }
  684. if ($bUploadEnabled && !$bReadOnly && $bLoggedIn)
  685. {
  686.     $arTasks[$iTaskCount][0] = "Upload a file";
  687.     $arTasks[$iTaskCount][1] = "javascript:openUploadWindow();";
  688.     $arTasks[$iTaskCount][2] = "UploadLink";
  689.     $arTasks[$iTaskCount][3] = "";
  690.     $iTaskCount++;
  691. }
  692.  
  693. $bLimitLocations = true;
  694. require "panels.php";
  695. ?>
  696.                 </td>
  697.             </tr>
  698.         </table>
  699. <script type="text/javascript">
  700.     var childOpen = false;
  701.     function openUploadWindow()
  702.     {
  703.         childOpen = true;
  704.         openWindow('/uploadform.php?share=<?php echo ($sShare); ?>&path=<?php echo (urlEncodeString($sPath)); ?>&page=');
  705.     }
  706.     var sSelectedId = '';
  707.     var sSelectedClass = '';
  708.  
  709.     writePrepCookie();
  710.     
  711.     startHighlight = function()
  712.     {
  713.         if (document.all && document.getElementById)
  714.         {  
  715.             navRoot = document.getElementById('FileList');
  716.             
  717.             // Get a reference to the TBODY element 
  718.             tbody = navRoot.childNodes[0];
  719.             
  720.             for (i = 1; i < tbody.childNodes.length; i++)
  721.             {
  722.                 node = tbody.childNodes[i];
  723.                 if (node.nodeName == "TR")
  724.                 {
  725.                     node.onmouseover=function()
  726.                     {
  727.                         if (node.id != 'FileListHeader')
  728.                         {
  729.                             this.className = "FileViewRowOver";                
  730.                         }
  731.                     }
  732.                     
  733.                     node.onmouseout=function()
  734.                     {
  735.                         this.className = this.className.replace("FileViewRowOver", "");
  736.                     }
  737.                 }
  738.             }
  739.         }
  740.     }
  741.  
  742.     function changeSelection(sId, sClass, sHref, bNewWindow, bSupported)
  743.     {
  744.         if (sSelectedId != '')
  745.         {
  746.             switch (sSelectedClass)
  747.             {
  748.                 case 'ThumbnailImageSelect':
  749.                     document.getElementById(sSelectedId).className = 'ThumbnailImage';
  750.                     break;
  751.                 case 'ThumbnailImageBadSelect':
  752.                     document.getElementById(sSelectedId).className = 'ThumbnailImageBad';
  753.                     break;
  754.                 case 'ThumbnailphotoIconSelect':
  755.                     document.getElementById(sSelectedId).className = 'ThumbnailphotoIcon';
  756.                     break;
  757.             }
  758.         }
  759.         sSelectedId                             = sId;
  760.         sSelectedClass                          = sClass;
  761.         document.getElementById(sId).className  = sClass;
  762.         if (bSupported)
  763.         {
  764.             if (bNewWindow)
  765.             {
  766.                 openContentWindow(sHref);
  767.             }
  768.             else
  769.             {
  770.                 location.href                           = sHref;
  771.             }
  772.         }
  773.         else
  774.         {
  775.             alertFileNotAvailable();
  776.         }
  777.     }
  778.     
  779.     function mouseoverSelection(sId, sClass)
  780.     {
  781.         if (sSelectedId !=sId)
  782.         {
  783.             document.getElementById(sId).className = sClass;
  784.         }
  785.     }
  786.     
  787.     function mouseoutSelection(sId, sClass)
  788.     {
  789.         if (sSelectedId !=sId)
  790.         {
  791.             document.getElementById(sId).className = sClass;
  792.         }
  793.     }
  794.     
  795.     function alertFileNotAvailable()
  796.     {
  797.         alert ("Files with this extension are not available via <?php echo ($sProductNameInformal); ?>");
  798.     }
  799.   
  800.   window.onload = startHighlight;      
  801. </script>
  802.  
  803. <?php 
  804. ///////////////////////////////////////////////////
  805. // Finish printing out the HTML to the browser
  806. ///////////////////////////////////////////////////
  807. require "_footer.php";
  808.  
  809. ///////////////////////////////////////////////////
  810. // Get the next page of thumbnails if one exists
  811. ///////////////////////////////////////////////////
  812. if ($pageNumber <= $iMaxPage && $sViewMode == "photo")
  813. {
  814.     $pageArray = array_slice($arFiles, (($pageNumber) * $ObjectsPerPage), $ObjectsPerPage);
  815.     foreach($pageArray as $fileName)
  816.     {
  817.         $sFullFilePath = $sFolderPath . "\\" . $fileName[0];
  818.         try
  819.         {
  820.             $imgLocation = $nmRaManager->GetThumbnailForFile($sFullFilePath, $iThumbnailWidth, 
  821.                                                              $iThumbnailHeight, $sContentBackground);
  822.         }
  823.         catch(com_exception $ex)
  824.         {
  825.             log_activity("get thumbnail for " . $sFullFilePath, "exception", $ex->getMessage());
  826.         }
  827.     }
  828.     log_activity("get thumbnails ahead", "info", "");
  829. }
  830.  ?>