require '_functions.php';
$URLData = processURI(); //load up them fake directories
//print_r($URLData);
$siteName = ereg_replace('-', ' ',$URLData['arg1']);
$sql = ($URLData['arg1'] != "") ? "SELECT siteName, ninjitoSites.contentDirectory, ninjitoSites.templateDirectory, refURL, adminRefCode, rootDirectory,LicenseKey FROM ninjitoSites,ninjitoConfig WHERE ninjitoSites.siteName='$siteName'" : "SELECT siteName, ninjitoSites.contentDirectory, ninjitoSites.templateDirectory, refURL, adminRefCode, rootDirectory,LicenseKey FROM ninjitoSites,ninjitoConfig order by RAND() limit 1"; //get the dirs relating to the current site.
$query = mysql_query($sql);
if ($row = mysql_fetch_assoc($query)) {
$siteName=$row[siteName];
$siteName = ereg_replace(' ', '-', $siteName);
$rootDirectory=$row[rootDirectory];
$contentDirectory=$rootDirectory."/".$siteName."/".$row[contentDirectory];
$templateDirectory=$rootDirectory."/".$siteName."/".$row[templateDirectory];
$smallTemplateDirectory = $row[templateDirectory];
$smallContentDirectory = $row[contentDirectory];
$refURL=$row[refURL];
$adminRefCode=$row[adminRefCode];
$decrypt_result = $crypt->decrypt("zoidberg", $key);
$decrypt_result = explode("+",$decrypt_result);
}
//echo "$smallTemplateDirectory
";
//echo "$smallContentDirectory
";
$numTemplates = count(glob($siteName."/".$smallTemplateDirectory."/*"));
$numSets = count(glob($siteName."/".$smallContentDirectory."/*"));
//echo $numSets;
//echo "
".$numTemplates;
if ($URLData["arg5"] == "PD" || $URLData["arg5"] == "GD") {
$seed = floor(time()/86400);
srand($seed);
}
$refURL = explode('@',$refURL);
$refcode = ($URLData["arg4"] == "") ? $adminRefCode : $refURL[0].$URLData["arg4"]. $refURL[1];
$template = ($URLData['arg2'] == "" || $URLData['arg2'] == "X" || $URLData['arg2'] == "x") ? rand(1, $numTemplates) : $URLData['arg2'];
$template = ($template > $numTemplates) ? rand(1, $numTemplates) : $template;
$contentSet = ($URLData['arg3'] == "" || $URLData['arg3'] == "X" || $URLData['arg3'] == "x") ? rand(1, $numSets) : $URLData['arg3'];
$numPics = (count(glob($siteName."/".$smallContentDirectory."/".$contentSet."/*"))/2);
$contentSet = ($contentSet > $numSets) ? rand(1, $numSets) : $contentSet;
$smallContentSet = $contentSet;
$contentSet = "http://".$decrypt_result[0]."/".$contentDirectory."/".$contentSet."/";
$relDir = "http://".$decrypt_result[0]."/".$templateDirectory."/".$template."/";
switch ($URLData["arg5"]) {
case "PD":
//$includePicture = $siteName."/".$smallContentDirectory."/".$contentSet."/*.jpg";
$pictureArr = @globr($siteName."/".$smallContentDirectory."/".$smallContentSet,'*');
$pictureArr = array_diff($pictureArr, array(''));
$pictureSize = array();
/*$c = 0;
for ($i=0; $i < (count($pictureArr)-1); $i++) {
if (filesize($pictureArr[$i]) > 25000) {
$pictureSize[$c][0] = $pictureArr[$i];
$pictureSize[$c][1] = filesize($pictureArr[$i]);
$c++;
}
}*/
$j = 0;
for ($i=0; $i < (count($pictureArr)-1); $i++) {
if ((filesize($pictureArr[$i]) > 15000) && (filesize($pictureArr[$i]) != 0) && ($pictureArr[$i] != "") ) {
$pictureSize[$j][0] = $pictureArr[$i];
$pictureSize[$j][1] = filesize($pictureArr[$i]);
$j++;
}
}
$finalSource = $pictureSize[(rand(1, count($pictureSize)-1))][0];
$includePicture = "http://".$decrypt_result[0]."/".$rootDirectory."/".$pictureSize[(rand(1, count($pictureSize)-1))][0];
if (file_exists($siteName."/_POD.php")) { include ($siteName."/_POD.php"); }
else { include ("images/_POD.php"); }
break;
case "GD":
include $siteName."/".$smallTemplateDirectory."/".$template."/index.php";
break;
default:
include $siteName."/".$smallTemplateDirectory."/".$template."/index.php";
}
?>