function extractFile($str) {
// extract filename w/o path
return substr($str, strrpos($str, "/")+1);
}
function mungeString($str) {
global $PHP_SELF;
$filename = extractFile($PHP_SELF);
if ($filename=="featured_scores.php" || $filename=="hs~featured_scores.php")
return htmlspecialchars(wordwrap(stripslashes($str), 20, ' ', 1));
else
return htmlspecialchars(wordwrap(stripslashes($str), 40, ' ', 1));
}
function rightLinksControl($loggedIn, $filename, $signInBtn, $uploadBtn, $editBtn) {
global $signInBtn, $uploadBtn, $editBtn;
if ($loggedIn) {
$signInBtn = "
";
$uploadBtn = "
";
$editBtn = "
";
}
else {
$signInBtn = "
";
$uploadBtn = "
";
$editBtn = "
";
}
}
function signIn($signout, $Cake, $sessRemember, $sessUserId, $sessUserName, $sessAdmin) {
// calling php: featured_scores.php, user_scores.php
// 1) is this a returning user who has the 'Cake' cookie set?
// 2) or is this a user who has just 'signed in' and selected the 'rememberMe' checkbox
// so that we should now set the 'Cake' cookie?
global $Cake, $sessUserId, $sessUserName, $sessAdmin;
if ( (!isset($signout)) AND ( (@$Cake!="") OR (@$sessRemember==True) ) ) {
// has the cookie been set already?
if (@$Cake!="") {
$query = "select * from users where user_id=".$Cake."";
} // has the checkbox been selected?
else {
setcookie("Cake", $sessUserId, time()+31536000 , "/");
$query = "select * from users where user_id=".$sessUserId;
}
$result = mysql_query($query) or die("Error: This site requires that cookies are enabled on your computer. Cake cookie= $Cake");
$row = mysql_fetch_array($result);
session_register('sessUserId');
session_register('sessUserName');
session_register('sessAdmin');
$sessUserId = $row["user_id"];
$sessUserName = $row["user_name"];
$sessAdmin = $row["user_admin"];
}
}
function calculatePrevNext($query, $page, $firstRecord, $totalRows, $constantRows) {
// calling php: featured_scores.php, user_scores.php
global $firstRecord, $totalRows;
$result = mysql_query($query) or die("Invalid query");
$row = mysql_fetch_row($result);
$totalRows = $row[0];
// set $firstRecord so we know which score to begin displaying in the table
// $page wont be set the first time this window is displayed
if (@$page) {
switch ($page) {
case "prev":
$firstRecord -= $constantRows;
if ($firstRecord < 0) {
$firstRecord = $totalRows-1;
$firstRecord -= $firstRecord % $constantRows;
}
break;
case "next":
$firstRecord += $constantRows;
if ($firstRecord >= $totalRows)
$firstRecord = 0;
break;
default:
$firstRecord = 0;
}
} else {
// when the user visits the page for the first time
// there is no firstRecord selected so give them the first record.
$firstRecord = 0;
}
}
class Score {
var $exists = false;
var $scoreId = 0;
var $scoreLink = "#";
var $listenLink = "#";
var $thumbnail = "images/spacer.gif";
var $nickname = " ";
var $country = " ";
var $dispDate = " ";
var $length = " ";
var $hits = " ";
var $title = " ";
var $desc = " ";
function Score($record) {
if ($record) {
$this->exists = true;
$this->scoreId = $record['score_id'];
$this->scoreLink =
"count_download.php?file=${record['score_filename']}"
."&scoreid=${record['score_id']}";
// strip off .hsc extension
$this->scoreLink = str_replace(" ","%20", $this->scoreLink);
$filenameMinExt = substr($record['score_filename'], 0, -4);
$this->listenLink = MIDIBINPATH.$filenameMinExt.".mid";
$this->listenLink = str_replace(" ","%20", $this->listenLink);
$this->thumbnail = THUMBBINPATH.$filenameMinExt.".gif";
$this->thumbnail = str_replace(" ","%20", $this->thumbnail);
// $this->thumbnail = 'images/spacer.gif';
$this->nickname = mungeString($record['user_name']);
$this->country = mungeString($record['user_country']);
$this->dispDate = date('m.d.y',
strtotime(substr($record['score_date'], 0, 10)));
// if shatter program is not creating the info txt file, then the length will be -1
if ($record['score_length'] == -1)
$this->length = " ";
else
$this->length = mungeString($record['score_length'])." secs";
$this->hits = mungeString($record['score_downloads']);
$this->title = mungeString($record['score_title']);
$this->desc = mungeString($record['score_desc']);
}
}
}
class Column {
var $colLink;
var $imageExt = "";
var $imageOverExt = "";
var $myIndex = 4;
function Column($myIndex, $sortOn, $sortOrder) {
global $PHP_SELF;
$filename = extractFile($PHP_SELF);
if ($myIndex == $sortOn) {
if ($sortOrder == 1) {
$this->imageExt = "_up";
$this->imageOverExt = "_up";
$sortOrder = 2;
}
else {
$this->imageExt = "_down";
$this->imageOverExt = "_down";
$sortOrder = 1;
}
if ($filename=="user_scores.php" || $filename=="hs~user_scores.php")
$this->colLink = "user_scores.php?sortOn=$myIndex&sortOrder=$sortOrder";
else
$this->colLink = "my_scores.php?sortOn=$myIndex&sortOrder=$sortOrder";
}
else {
$this->imageOverExt = "_over";
if ($filename=="user_scores.php" || $filename=="hs~user_scores.php")
$this->colLink = "user_scores.php?sortOn=$myIndex&sortOrder=1";
else
$this->colLink = "my_scores.php?sortOn=$myIndex&sortOrder=1";
}
}
}
function CheckIfDownLoading() {
//if (@$acceptCopyRight)
echo "";
}
?>