home *** CD-ROM | disk | FTP | other *** search
- <?php
- ////////////////////////////////////////////////////////////////////////////////
- // <!--Copyright (c) 2005 Pure Networks Inc. All rights reserved.-->
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Build: 3.0.6121.0 (Stable)
- // $Revision: #2 $
- //
-
- $sNavLocation = "feed";
- require "_folderutils.php";
- require "_session_common.php";
- $iPort = ":8008";
-
- ////////////////////////////////////////////////////
- // do we need to limit the number of returned items?
- ////////////////////////////////////////////////////
- // check the _config file, if no value, set backup default here
- if (!isset($iFeedCountLimit))
- {
- $iFeedCountLimit = 25;
- }
- // should we over-ride the default with a QS value?
- if (isset($_GET['itemlimit']))
- {
- $iFeedCountLimit = $_GET['itemlimit'];
- }
- // now let's cap out the given limit if we have a max value in the _config file
- if (isset($iFeedCountMax) && $iFeedCountLimit > $iFeedCountMax)
- {
- $iFeedCountLimit = $iFeedCountMax;
- }
-
- unset($_SESSION['currentPhotos']);
- $iPictureCount = 0;
- $arFiles = "";
- $cFiles = 0;
- switch($_GET['feed_type'])
- {
- case "sharelist":
- case "whatsnew":
- case "screensaver":
- case "shares":
- $sFeedtype = $_GET['feed_type'];
- break;
- default:
- $sFeedtype = "whatsnew";
- }
-
- switch($_GET['sort'])
- {
- case "none":
- $sSortType = "none";
- break;
- default:
- $sSortType = "date";
- }
-
- $bRandom = false;
- switch($_GET['random'])
- {
- case "yes":
- $bRandom = true;
- break;
- default:
- $bRandom = false;
- }
-
- switch($sFeedtype)
- {
- case "shares":
- ///////////////////////////////////////////////////
- // let's try to get the network places here, because if we have none, we
- // don't want to show certain UI (such as the sort by links)
- ///////////////////////////////////////////////////
- try
- {
- $nmSharedPlaces = $nmNetworkLib->OpenAllShares();
- ///////////////////////////////////////////////////
- // let's remove all but the public shares
- ///////////////////////////////////////////////////
- $nmSharedPlaces = removeSharesFromArray($nmSharedPlaces, 1);
- $nmSharedPlaces = removeSharesFromArray($nmSharedPlaces, 2);
- }
- catch(Exception $ex)
- {
- $nmSharedPlaces = null;
- }
-
- ///////////////////////////////////////////////////
- // We now have the correct shares, let's get their info
- ///////////////////////////////////////////////////
- if (count($nmSharedPlaces) > 0 )
- {
- // We have the shared places array, but they are in computer/folder non-alpha order.
- // we need to be able to sort by computer or folder, so to do this
- // we have to take this array and create a multi-column array to be
- // able to sort on either, as neither are sorted properly in the current returned list.
- //
- // For some reason, PHP is not honoring case insensitivity in the SORT_ASC, so we need
- // to create a 100% lower case array which we will use for sorting, and use the
- // array_multisort below to sort all arrays together based on the right ASC case insensitive
- // order of either folders alone or computers and then folders
-
-
- $j=0;
- $arShareNames = null;
- $arShareLocations = null;
- $arShareNamesCase = null;
- $arShareLocationsCase = null;
- foreach ($nmSharedPlaces as $share)
- {
- try
- {
- $sShareId = $share->Id;
- $sShareUnc = $share->Unc;
- $arShareNames[$j][0] = htmlspecialchars($share->ShareName);
- $arShareNames[$j][1] = $sShareId;
- $arShareNames[$j][2] = $sShareUnc;
- $arShareNames[$j][3] = $share->IsOnline;
- $arShareNames[$j][4] = $share->CountFiles;
- $arShareNames[$j][5] = $share->CountFolders;
- $arShareNames[$j][6] = $share->AccessLevel;
- $arShareNames[$j][7] = htmlspecialchars("/folderview/" . $sShareId . "/" . urlEncodeString($sShareUnc));
-
- $arShareLocations[$j] = $share->Location;
-
- $arShareDescriptions[$j][0] = htmlspecialchars($share->Description);
- $arShareDescriptions[$j][1] = htmlspecialchars($share->FriendlyName);
- $arShareDescriptions[$j][2] = htmlspecialchars($share->ShareName);
- $arShareDescriptions[$j][3] = $share->Thumbnail;
-
- $arShareNamesCase[$j] = strtolower($arShareNames[$j][0]);
- $arShareLocationsCase[$j] = strtolower($arShareLocations[$j]);
- $arShareDescriptionsCase[$j] = strtolower($arShareDescriptions[$j][0]);
- $arShareLevelsCase[$j] = $arShareNames[$j][6];
- $j++;
- }
- catch(Exception $ex)
- {
- log_activity("Collecting share properties", "exception", $ex->getMessage());
- }
- }
- }
- break;
- case "sharelist":
- ///////////////////////////////////////////////////
- // Make sure that we have a valid sharelist passed in.
- ///////////////////////////////////////////////////
- if (!isset($_GET['sharelist']) or $_GET['sharelist'] == "")
- {
- log_activity("QS check", "failure", return_error_text(200, "", $arErrors));
- gotoAbs('/error/200&return=/folders/');
- exit();
- }
- else
- {
- $sShareList = $_GET['sharelist'];
- $arShares = split(";", $sShareList);
- }
- foreach ($arShares as $share)
- {
- ///////////////////////////////////////////////////
- // Let's try to see if we can open the share
- ///////////////////////////////////////////////////
- try
- {
- $nmSharedPlace = $nmNetworkLib->OpenShare($share);
- if ($arShareDescriptions[$i][1] != "")
- {
- $sFeedTitle = htmlspecialchars($nmSharedPlace->FriendlyName);
- }
- else
- {
- $sFeedTitle = htmlspecialchars($nmSharedPlace->ShareName);
- }
- try
- {
- $sAccessLevel = $nmSharedPlace->AccessLevel;
- if ($sAccessLevel <= 0)
- {
- // TODO: throw exception
- }
- }
- catch(Exception $ex)
- {
- log_activity("Attempting nmSharedPlace->AccessLevel", "exception", $ex->getMessage());
- gotoAbs('/error/305/return');
- exit();
- }
- ///////////////////////////////////////////////////
- // let's open up the share(s) on the FS & feed our arrays
- ///////////////////////////////////////////////////
- addFilesAndFolders($nmSharedPlace->Unc, $nmSharedPlace, $arFiles, $cFiles);
- }
- catch(Exception $ex)
- {
- $nmSharedPlaces = null;
- log_activity("Attempting nmNetworkLib->OpenShare()", "exception", $ex->getMessage());
- // TODO: ERROR RSS FEED
- }
- }
- break;
- case "whatsnew":
- case "screensaver":
- $sFeedTitle = $sNetworkName;
- ///////////////////////////////////////////////////
- // let's get the network places
- ///////////////////////////////////////////////////
- try
- {
- $nmSharedPlaces = $nmNetworkLib->OpenAllShares();
- }
- catch(Exception $ex)
- {
- $nmSharedPlaces = null;
- log_activity("Attempting nmNetworkLib->OpenAllShares()", "exception", $ex->getMessage());
- // TODO: ERROR RSS FEED
- }
-
- ///////////////////////////////////////////////////
- // let's remove all but the public shares
- ///////////////////////////////////////////////////
- $nmSharedPlaces = removeSharesFromArray($nmSharedPlaces, 1);
- $nmSharedPlaces = removeSharesFromArray($nmSharedPlaces, 2);
- ///////////////////////////////////////////////////
- // let's open up the share(s) on the FS & feed our arrays
- ///////////////////////////////////////////////////
- foreach ($nmSharedPlaces as $share)
- {
- addFilesAndFolders($share->Unc, $share, $arFiles, $cFiles);
- }
- break;
- default:
- // TODO: what here??
- }
-
- ///////////////////////////////////////////////////
- // Init hte variables we need for teh feed's header
- ///////////////////////////////////////////////////
- try
- {
- $sNetworkName = $nmNetworkLib->NetworkName;
- $sWanIp = $nmRaManager->HomeUrl;
- $sWanIp = str_replace(".networkmagic.com",".home.networkmagic.com",$sWanIp);
- $sWanIp = str_replace(".net2go.com",".home.net2go.com",$sWanIp);
- $sLanIp = "http://" . $nmRaManager->LanIP;
- }
- catch (exception $ex)
- {
- //TODO CATCH LOGIC HERE
- }
-
- switch ($_GET["IP"])
- {
- case "LAN":
- $sIPToUse = $sLanIp;
- break;
- case "WAN":
- $sIPToUse = $sWanIp;
- break;
- default:
- $sIPToUse = $sWanIp;
- }
-
- $arFiles = $_SESSION['currentPhotos'];
-
- if ($bRandom)
- {
- shuffle($arFiles);
- }
- else
- {
- if ($sSortType == "date" && $sFeedtype != "shares")
- {
- $arFileTimes = $_SESSION['currentPhotosTimes'];
- array_multisort($arFileTimes, SORT_DESC, SORT_STRING, $arFiles);
- }
- }
-
- $iCounter = 0;
-
- switch ($_GET["format"])
- {
- case "html":
- foreach ($arFiles as $file)
- {
- $thumbnaillink = "/thumbnail/" . urlEncodeString($file[0]) . "/" . urlEncodeString($file[1]) . "/" . urlEncodeString($file[3]);
- $viewlink = "/fileview/" . urlEncodeString($file[0]) . "/" . urlEncodeString($file[2]) . "/" . urlEncodeString($file[3]);
- $sFileNameForDisplay = $files[3];
- ?>
- <div class="Thumbnailphoto">
- <div id="TN<?php echo ($iCounter); ?>" class="ThumbnailImage" title="View details for file '<?php echo ($sFileNameForDisplay); ?>'.">
- <a class=link href="<?php echo ($viewlink);?>" title="View details for file '<?php echo($sFilenameForDisplay);?>'.">
- <img src="<?php echo $thumbnaillink;?>" border="0" alt="<?php echo ($sFilenameForDisplay);?>"/></a>
- </div>
- </div>
- <?php
- $iCounter++;
- if ($iCounter >= $iFeedCountLimit)
- {
- // we've hit the configured limit on new files, let's break out...
- break;
- }
- }
- break;
- case "xml":
- default:
- ///////////////////////////////////////////////////
- // let's create the feed now
- ///////////////////////////////////////////////////
- header("Content-Type: text/xml");
- ?>
- <?php echo '<?xml version="1.0" encoding="utf-8"?'.'>'; ?>
- <!-- generator="Pure Networks - Net2Go 3.0.6121.0 (Stable)" -->
- <rss version="2.0"
- xmlns:content="http://purl.org/rss/1.0/modules/content/"
- xmlns:Net2Go="http://www.net2go.com/ns/Net2Go#"
- xmlns:media="http://search.yahoo.com/mrss">
- <channel>
- <title><![CDATA[<?php echo ($sFeedTitle); ?>]]></title>
- <link><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>]]></link> <?php //TODO BETTER DOMAIN NAME HRE FOR IN/OUT OF NETWORK USE?? ?>
- <description><![CDATA[<?php echo ($sNetworkName); ?>]]></description>
- <language><![CDATA[en]]></language>
- <copyright><![CDATA[Copyright 2005]]></copyright>
- <pubDate><![CDATA[<?php echo (date("D, d M Y H:i:s O")); ?>]]></pubDate>
- <generator><![CDATA[http://www.net2go.com/]]></generator>
- <?php
- switch($sFeedtype)
- {
- case "shares":
- for ($i=0; $i < count($arShareNames); $i++)
- {
- $imgLocation = $arShareDescriptions[$i][3];
- $iFileNamePos = strpos($imgLocation, strrchr($imgLocation, "\\"));
- $sFile = substr($imgLocation, $iFileNamePos+1);
- $sPathNoFile = substr($imgLocation, 0, (strlen($imgLocation) - strlen($sFile) - 1));
- // We want a generic folder icon for shares without pics (or with a failed pic...)
- if (!file_exists($imgLocation) || !isValidString($imgLocation))
- {
- $sharethumbnaillink = "/styles/" . $sStyleFamily . "/" . $sStyleName . "/place.48.gif";
- $imgMode = "Generic";
- }
- else
- {
- $sharethumbnaillink = "/sharethumbnail/" . $arShareNames[$i][1] . "/" . urlEncodeString(str_replace("\\\\","\\",$sPathNoFile)) . "/" . urlEncodeString($sFile);
- }
- ?>
- <item>
- <title><![CDATA[<?php echo ($arShareDescriptions[$i][2]); ?>]]></title>
- <link><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?><?php echo ($arShareNames[$i][7]); ?>]]></link>
- <Net2Go:share>
- <id><![CDATA[<?php echo ($arShareNames[$i][1]); ?>]]></id>
- <unc><![CDATA[<?php echo ($arShareNames[$i][2]); ?>]]></unc>
- <status><![CDATA[<?php echo ($arShareNames[$i][3]); ?>]]></status>
- <countfiles><![CDATA[<?php echo ($arShareNames[$i][4]); ?>]]></countfiles>
- <countfolders><![CDATA[<?php echo ($arShareNames[$i][5]); ?>]]></countfolders>
- <location><![CDATA[<?php echo ($arShareLocations[$i]); ?>]]></location>
- <thumbnail><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?><?php echo ($sharethumbnaillink); ?>]]></thumbnail>
- <name><![CDATA[<?php echo ($arShareDescriptions[$i][2]); ?>]]></name>
- <friendlyname><![CDATA[<?php echo ($arShareDescriptions[$i][1]); ?>]]></friendlyname>
- <description><![CDATA[<?php echo ($arShareDescriptions[$i][0]); ?>]]></description>
- </Net2Go:share>
- <pubDate><![CDATA[<?php echo(date ("D, d M Y H:i:s O")); ?>]]></pubDate>
- <lastBuildDate><![CDATA[<?php echo(date ("D, d M Y H:i:s O")); ?>]]></lastBuildDate>
- <author><![CDATA[webmaster@net2go.com]]></author>
- <guid isPermaLink="false"><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/<?php echo ($arShareNames[$i][7]); ?>]]></guid>
- <description><![CDATA[<?php echo ($arShareDescriptions[$i][2]); ?>]]></description>
- <content:encoded><![CDATA[<?php echo ($arShareDescriptions[$i][2]); ?><br/><a href="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?><?php echo ($arShareNames[$i][7]); ?>"><img border="0" src="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?><?php echo ($sharethumbnaillink); ?>"/></a>]]></content:encoded>
- </item>
- <?php
- }
- break;
- default:
- foreach ($arFiles as $file)
- {
- $fileExtension = strtolower(strrchr($file[3], "."));
- switch ($fileExtension)
- {
- case ".jpg":
- case ".jpe":
- case ".jpeg":
- case ".jfif":
- case ".gif":
- case ".png":
- $arImageInfo = getimagesize($file[2]);
- ?>
- <item>
- <title><![CDATA[<?php echo (urlEncodeString($file[3])); ?>]]></title>
- <media:title><![CDATA[<?php echo (urlEncodeString($file[3])); ?>]]></media:title>
- <link><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/fileview/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[2]));?>/<?php echo (urlEncodeString($file[3])); ?>]]></link>
- <pubDate><![CDATA[<?php echo(date ("D, d M Y H:i:s O", filectime($file[2]))); ?>]]></pubDate>
- <author><![CDATA[webmaster@net2go.com]]></author>
- <guid isPermaLink="false"><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/fileview/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[2]));?>/<?php echo (urlEncodeString($file[3])); ?>]]></guid>
- <media:content url="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/fileopen/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>" type="<?php echo (image_type_to_mime_type($arImageInfo[2])); ?>" <?php echo ($arImageInfo[3]); ?>/>
- <description><![CDATA[<?php echo (urlEncodeString($file[3])); ?>]]></description>
- <Net2Go:image>
- <fullsize><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/fileopen/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>]]></fullsize>
- <detailsview><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/detailsview/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>]]></detailsview>
- <slideimage><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/slideimage/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>]]></slideimage>
- <thumbnail><![CDATA[<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/thumbnail/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>]]></thumbnail>
- <share_guid><![CDATA[<?php echo (urlEncodeString($file[0])); ?>]]></share_guid>
- </Net2Go:image>
- <media:thumbnail url="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/thumbnail/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>" height="<?php echo ($iThumbnailHeight);?>" width="<?php echo ($iThumbnailWidth);?>"/>
- <media:text type="html"><![CDATA[<p><?php echo (urlEncodeString($file[3])); ?><br/><a href="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/fileview/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[2]));?>/<?php echo (urlEncodeString($file[3])); ?>"><img border="0" src="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/thumbnail/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>"/></a></p>]]></media:text>
- <content:encoded><![CDATA[<p><?php echo (urlEncodeString($file[3])); ?><br/><a href="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/fileview/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[2]));?>/<?php echo (urlEncodeString($file[3])); ?>"><img border="0" src="<?php echo ($sIPToUse); ?><?php echo ($iPort); ?>/thumbnail/<?php echo (urlEncodeString($file[0])); ?>/<?php echo (urlEncodeString($file[1]));?>/<?php echo (urlEncodeString($file[3])); ?>"/></a></p>]]></content:encoded>
- </item>
- <?php
- $iCounter++;
- break;
- }
- if (($iCounter >= $iFeedCountLimit))
- {
- // we've hit the configured limit on new files, let's break out...
- //TODO: only for what's new...
- break;
- }
- }
- }
- ?>
- </channel>
- </rss>
- <?php
- break;
- }
-
- function addFilesAndFolders($sPath, $share, $arFiles, $cFiles)
- {
- global $cFiles, $arFiles, $arFileTimes;
- if ($share->IsOnline)
- {
- $handle = opendir($sPath);
- while (false !== ($file = readdir($handle)))
- {
- $sFullPath = $sPath . "\\" . $file;
- // we've got a directory, make sure it's not the . or .. folder and stuff it's info in the folder array
- if ($share->IsDisplayableItem($sFullPath) && is_dir($sFullPath) && ($file != ".") && ($file != ".."))
- {
- // Got a directory, let's recurse through it
- addFilesAndFolders($sFullPath, $share, $arFiles, $cFiles);
- }
- // we've got a file, let's grab the extension and stuff it's info in either the photo or the non photo array
- if (is_file($sFullPath) && is_readable($sFullPath) && $share->IsDisplayableItem($sFullPath))
- {
- $arFiles[$cFiles][0] = $share->Id;
- $arFiles[$cFiles][1] = $sPath;
- $arFiles[$cFiles][2] = $sFullPath;
- $arFiles[$cFiles][3] = $file;
- $arFiles[$cFiles][4] = filectime($sFullPath);
- $arFileTimes[$cFiles] = filectime($sFullPath);
- $cFiles++; // increment the array position counter
- }
- }
- $_SESSION['currentPhotos'] = $arFiles;
- $_SESSION['currentPhotosTimes'] = $arFileTimes;
- }
- }
-
- function printErrorFeed($iErrorCode)
- {
- // TODO create feed here...
- exit();
- }
- ?>