client = "Word Distribution"; $this->domain = "worddistribution.com"; $this->dbName = "wr_worddist"; $this->templatePath = "/content/www/worddistribution.com/docs/_templates"; $this->newTemplatePath = apache_getenv("DOCUMENT_ROOT") ."/docs/_templates"; $this->templateUrl = "_templates"; $this->productIMGpath = apache_getenv("DOCUMENT_ROOT") ."/docs/images/products"; $this->productIMGurl = "/docs/images/products"; $this->merchandiseIMGpath = apache_getenv("DOCUMENT_ROOT") ."/docs/images/merchandise"; $this->merchandiseIMGurl = "/docs/images/merchandise"; $this->folioIMGpath = apache_getenv("DOCUMENT_ROOT") ."/docs/images/folio"; $this->folioIMGurl = "/docs/images/folio"; $this->songIMGpath = apache_getenv("DOCUMENT_ROOT") ."/docs/_audio"; $this->songIMGurl = "/docs/_audio"; $this->audioPath = apache_getenv("DOCUMENT_ROOT") ."/docs/_audio"; $this->audioUrl = "/docs/_audio"; $this->pdfPath = apache_getenv("DOCUMENT_ROOT") ."/docs/_pdf"; $this->pdfUrl = "/docs/_pdf"; $this->newsPath = apache_getenv("DOCUMENT_ROOT") ."/docs/_news"; $this->newsUrl = "/docs/_news"; $this->filePath = apache_getenv("DOCUMENT_ROOT") ."/docs/_files"; $this->filePath2 = apache_getenv("DOCUMENT_ROOT") ."/docs/FILES"; $this->fileUrl = "/docs/_files"; $this->cfilePath = apache_getenv("DOCUMENT_ROOT") ."/docs/_files2"; $this->cfileUrl = "/docs/_files2"; $this->SongbookIMGpath = apache_getenv("DOCUMENT_ROOT") ."/docs/images/folio"; $this->SongbookIMGurl= "/docs/images/folio"; $this->maxPhotoWidth = 300; $this->maxPhotoHeight = 300; $this->limit = 30; } // ERROR CHECKING FUNCTIONS function returnError($msg){ print "
\n"; print "ERROR
\n"; print $msg.".
\n"; exit; } function sendEmail($subj, $body, $from){ mail("tony.thompson@wmg.com", stripslashes($subj), stripslashes($body), "From: $from"); } function reportError($msg, $subj){ $this->sendEmail("$this->client Error: $subj", "Here is the error:\n".stripslashes($msg), "errors@$this->domain"); } function testArray($array){ if($array){ foreach($array as $name => $value){ print "array[$name] = $value
\n"; } exit; } } function savePostData($data, $file){ if(file_exists($file) && $data){ $fp = fopen($file, "w"); foreach($data as $name => $value){ fwrite($fp, "$name=$value\n"); } fclose($fp); } else { $this->returnError("File: \"$file\" does not exist OR no \$data sent on call to savePostData()"); } } /* DATABASE FUNCTIONS */ function connectMySQL($db=""){ @mysql_connect("wmgmysql-dpv432.wmg.com", "wr_worddistUser", "wr_worddistP@ssWd") or $this->returnError("Unable to connect to SQL server"); // @mysql_connect("localhost", "root", "") or $this->returnError("Unable to connect to SQL server"); @mysql_select_db(!$db ? $this->dbName : $db); } function disconnectMySQL(){ @mysql_close(); } function mySQL_Query($query){ $result = mysql_query($query) or $this->returnError(mysql_error()); return $result; } function mySQL_Array($query){ $result = mysql_fetch_array($this->mySQL_Query($query)); return $result; } /* ARRAYS */ function stateArray(){ $states = array( "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" ); return $states; } function monthArray($int=""){ if($int==1){ $months = array( "Jan" => "01", "Feb" => "02", "Mar" => "03", "Apr" => "04", "May" => "05", "Jun" => "06", "Jul" => "07", "Aug" => "08", "Sep" => "09", "Oct" => "10", "Nov" => "11", "Dec" => "12" ); } else { $months = array( "January" => "01", "February" => "02", "March" => "03", "April" => "04", "May" => "05", "June" => "06", "July" => "07", "August" => "08", "September" => "09", "October" => "10", "November" => "11", "December" => "12" ); } return $months; } function creditCardMonthArray(){ $array = array( "1-Jan" => "01", "2-Feb" => "02", "3-Mar" => "03", "4-Apr" => "04", "5-May" => "05", "6-Jun" => "06", "7-Jul" => "07", "8-Aug" => "08", "9-Sep" => "09", "10-Oct" => "10", "11-Nov" => "11", "12-Dec" => "12" ); return $array; } function countryArray(){ $array = array( "United States", "Argentina", "Australia", "Aruba", "Barbados", "Belgium", "Belize", "Bermuda", "Brazil", "Bahamas", "Botswana", "Canada", "Cayman Islands", "Chile", "China", "Costa Rica", "Cyprus", "Denmark", "Egypt", "Finland", "France", "France, Metropolitan", "Germany", "Greece", "Guam", "Guatemala", "Hong Kong", "Iceland", "India", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Kenya", "Korea, Republic of", "Kuwait", "Luxembourg", "Malaysia", "Malawi", "Mexico", "Monaco", "Netherlands", "Netherlands Antilles", "New Zealand", "Norway", "Panama", "Peru", "Philippines", "Poland", "Puerto Rico", "Portugal", "Saudi Arabia", "Singapore", "South Africa", "Spain", "Sweden", "Switzerland", "Taiwan", "Thailand", "Turkey", "Trinidad and Tobago", "United Arab Emirates", "United Kingdom", "United States", "US Minor Outlying Islands", "Venezuela", "Virgin Islands", "Zimbabwe", "Zambia" ); return $array; } // MISCELLANEOUS FUNCTIONS function cacheHeader(){ Header("Cache-Control: cache"); Header("Pragma: cache"); } function noCacheHeader(){ Header("Cache-Control: no-cache, must-revalidate"); Header("Pragma: no-cache"); } function sendDownloadHeader($filename, $type=""){ $type = (!$type)?"application/octetstream":$type; Header("Content-disposition: filename=$filename"); Header("Content-type: $type"); Header("Expires: 0"); } function sendEmailMsg($email, $subj, $body, $from){ if($this->validateEmail($email)){ mail($email, stripslashes($subj), stripslashes($body), "From: $from\nX-Priority: 1\nX-MSMail-Priority: High\nImportance: High"); } } function sendHTMLEmailMsg($email, $subj, $body, $from){ if($this->validateEmail($email)){ mail($email, stripslashes($subj), stripslashes($body), "From: $from\nContent-type: text/html\nX-Priority: 1\nX-MSMail-Priority: High\nImportance: High"); } } function findInArray($array, $value){ for($x=0; $x"; $confirm=""; $x=0; foreach ($array as $key => $value) { if(eregi('^[a-zA-Z0-9._-]+UPC-[0-9]+$', $key) && eregi('^[0-9]+$', $value)){ /*$confirm[$x]["UPC"]=strstr($key, 'UPC-'); $temp=strpos($key, '_UPC-'); $confirm[$x]["Name"]=substr($key, 0, $temp); $x++;*/ $UPC= strstr($key, 'UPC-'); $UPC= str_replace('UPC-', "", $UPC); $temp=strpos($key, '_UPC-'); $Name = substr($key, 0, $temp); $confirm[$x]["Name"] = $Name; $confirm[$x]["UPC"] = $UPC; $confirm[$x]["QTY"] = $value; $x++; } /*if(!eregi('^[a-zA-Z0-9._-]+UPC-[0-9]+$', $key)){ $confirm[$key] = $value; }*/ } return $confirm; } function arrayDropDown($array, $value=""){ for($x=0; $x" : print "\n"; } } function associativeArrayDropDown($array, $value=""){ foreach($array as $key => $svalue){ $value == $svalue ? print "\n"; } } function associativeArrayDropDown2($vArray, $array){ foreach($array as $key => $svalue){ $this->findInArray($vArray, $key) ? print "\n"; } } function stateDropDown($value=""){ $this->arrayDropDown($this->stateArray(), $value); } function countryDropDown($value=""){ $this->arrayDropDown($this->countryArray(), $value); } function convertQueryString($url){ $string = str_replace("&", ";", $url); return stripslashes($string); } function revertQueryString($string){ $string = str_replace(";", "&", $string); $string = str_replace(" ", "+", $string); return stripslashes($string); } function getFileExtension($file){ !$file ? $this->returnError("no \$file on call to getFileExtension()") : ""; $array = explode(".", $file); $extension = $array[count($array)-1]; $ext = ".".strtolower($extension); return $ext; } function scrubText($text){ $text = str_replace("\"", "''", $text); $text = str_replace("\\", "", $text); return $text; } function removeSlashes($text){ $text = stripslashes($text); $text = str_replace("''", "", $text); $text = str_replace("'", "", $text); return $text; } function rs($text){ return $this->scrubText($text); } function formatText($string){ $string = stripslashes($string); $string = str_replace("\n", "
\n", $string); $string = str_replace("\\", "", $string); return $string; } function formatBullets($string){ $result = $this->formatText($string); $result = str_replace("*", "
  • ", $result); return $result; } function removeComma($text=""){ return str_replace(",", ";", $text); } function rc($text=""){ return $this->removeComma($text); } function rc2($text){ return "\"$text\""; } function createString(){ return md5(uniqid(rand())); } function searchFilter($text){ $chars = array("%", "(", ")", "*", "!", "^", "#", "$", "+",); for($x=0; $xsearchFilter($string); if(strstr($string, " ")){ $array = explode(" ", $string); } else { $array[0] = $string; } return $array; } function searchArray($text){ $text = $this->searchFilter($text); $array = $this->explodeValues($text, "all", " "); return $array; } function printWords($int, $string){ $int = ($int<1)?5:$int; $word = split(" ", stripslashes($string)); for($x=0; $x<$int; $x++){ print $word[$x]; if($x != ($int-1)) print " "; } print "...\n"; } function explodeValues($string, $x, $del=""){ !$string ? $this->returnError("no \$string on call to explodeValues()") : ""; strlen($x) < 1 ? $this->returnError("no \$ndx on call to explodeValues()") : ""; $del = (!$del)?"|":$del; $array = explode($del, $string); $value = (strlen($x) == 3)?$array:$array[$x]; return $value; } function theyMatch($array, $value){ for($x=0; $xoneDigit($int); $int = ($int<10)?"0$int":$int; return $int; } function oneDigit($int){ $int = ($int<10)?str_replace("0", "", $int):$int; return $int; } function getGoodDate(){ $d = getdate(); $d[mon] = $this->twoDigit($d[mon]); $d[mday] = $this->twoDigit($d[mday]); $d[year] = $d[year]; $d[hours] = $this->twoDigit($d[hours]); $d[minutes] = $this->twoDigit($d[minutes]); $d[seconds] = $this->twoDigit($d[seconds]); return $d; } function dateToday($int=""){ $d = $this->getGoodDate(); $date = ($int==1)?"$d[mon]/$d[mday]/$d[year]":"$d[month] $d[mday], $d[year]"; $date = ($int==7)?"$d[mon]-$d[mday]-$d[year]":$date; return $date; } function getFutureDate($date, $interval){ $Q = "select " . " date_format(date_add('$date', INTERVAL $interval), '%Y-%m-%d') " . ""; $result = $this->mySQL_Array($Q); return $result[0]; } function validateEmail($email){ if((!strstr($email, "@")) || (!strstr($email, ".")) || (strlen($email) < 6)) { return false; } else { return true; } } function monthDropDown($value, $int=""){ $array = $this->monthArray($int); $this->associativeArrayDropDown($array, $value); } function dayDropDown($value, $int=""){ for($x=0; $x<31; $x++){ $y = ($x+1); $y = $this->twoDigit($y); $value == $y ? print "\n"; } } function yearDropDown($value, $int=""){ $d = $this->getGoodDate(); $start = ($int==1)?2002:1905; $stop = ($int==1)?$d[year]+3:$d[year]+1; for($x=$start; $x<$stop; $x++){ $value == $x ? print "\n"; } } function createRandomString(){ return substr(md5(uniqid(rand())).md5(uniqid(rand())), 0, 30); } function randomString($int=""){ $int = (!$int)?5:$int; $string = $this->createRandomString(); return substr($string, 0, $int); } function isMicrosoftBrowser(){ global $HTTP_USER_AGENT; if(strstr(strtolower($HTTP_USER_AGENT), "msie")){ return true; } else { return false; } } function isMicrosoftBrowser6_0(){ global $HTTP_USER_AGENT; if(strstr(strtolower($HTTP_USER_AGENT), "msie 6.0")){ return true; } else { return false; } } function isNetscapeBrowser6_0(){ global $HTTP_USER_AGENT; if(strstr(strtolower($HTTP_USER_AGENT), "netscape6")){ return true; } else { return false; } } function jump($url="", $int=""){ $url = (!$url)?"/":$url; // this is a netscape refresh BUG if($int==1 || !$this->isMicrosoftBrowser()){ print "\n"; } else { Header("Location: $url\n"); } $this->disconnectMySQL(); exit; } function jump2($url){ $url = (!$url)?"/":$url; Header("Location: $url\n"); $this->disconnectMySQL(); exit; } function removeSpaces($array){ if(is_array($array)){ foreach($array as $name => $value){ $data[$name] = chop($value); } } return $data; } function setPPvalues($count, $skip, $limit){ $this->begin = ($count<1)?"0":($skip+1); $this->end = (($skip+$limit)>$count)?$count:($skip+$limit); $this->count = ($count<1)?"0":$count; $this->skip = $skip; $this->page = $this->nextLinks(); return $this->page; } function createVarArray($array){ if(count($array)>0){ unset($array[skip]); foreach($array as $name => $value){ if($name && chop($value)){ $var[] = $name."=".str_replace(" ", "+", $value); } } return $var; } } function getStartStopVars($pos){ !$pos ? $this->returnError("no \$pos on call to getStartStopVars()") : ""; $start = ($pos<5)?1:($pos-4); $stop = ($pos<5)?10:($pos+5); $max_stop = ceil($this->count/$this->limit); $array[start] = $start; $array[stop] = ($stop>$max_stop)?$max_stop:$stop; return $array; } function nextLinks(){ global $PHP_SELF, $m, $HTTP_GET_VARS; $count = ceil($this->count/$this->limit)+1; $skip = (!$HTTP_GET_VARS[skip])?"0":$HTTP_GET_VARS[skip]; if($count>1 && $count<=10){ $count = ceil($this->count/$this->limit)+1; $pos = $this->createPosition(); #$break = ($count>6)?$this->splitBreak($count):""; $string = "Page: "; $vars = $this->createVarArray($HTTP_GET_VARS); $vars = (is_array($vars))?"&".join("&", $vars):""; for($x=1; $x<$count; $x++){ $skip = ($this->limit*($x-1)); $string .= ($pos != $x) ? "" : ""; $string .= $x; $string .= ($pos != $x) ? "\n" : ""; $string .= (($x != $count-1) && ($x != $break)) ? " | " : "
    \n"; } } elseif($count>10){ $count = ceil($this->count/$this->limit)+1; $pos = $this->createPosition(); $string = "Page: "; $array = $this->getStartStopVars($pos); $start = $array[start]; $stop = $array[stop]+1; $vars = $this->createVarArray($HTTP_GET_VARS); $vars = (is_array($vars))?"&".join("&", $vars):""; for($x=$start; $x<$stop; $x++){ $skip = ($this->limit*($x-1)); $string .= ($pos != $x) ? "" : ""; $string .= $x; $string .= ($pos != $x) ? "\n" : ""; $max_stop = ceil($this->count/$this->limit); $nextSkip = ($skip+($this->limit*5)); $nextSkip = ($nextSkip>$this->count)?($skip+$this->limit):$nextSkip; $next = (($max_stop-$pos)>5)?" | Next ":""; $string .= ($x != ($stop-1)) ? " | " : "$next
    \n"; } } else { $string = " "; } return $string; } function splitBreak($count){ return round($count/2); } function createPosition(){ if($this->skip > 0){ $p = (($this->skip/$this->limit)+1); return $p; } else { return 1; } } function stripQuotes($string){ $string = str_replace("\"", "''", $string); return $string; } /* CUSTOM FUNCTIONS */ function getArtistDropDown($array=""){ $rArray = array(); $Q = "select " . " aID, " . " aName " . "from " . " artists " . "where " . " aName != 'DEFAULT' and " . " aName != '' " . "order by " . " aName " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $this->findInArray($array, $list["aID"]) ? print "\n"; $ndx = $list["aID"]; $rArray[$ndx] = $list["aName"]; } return $rArray; } function getArtistDropDown2($array=""){ $rArray = array(); $Q = "select " . " aID, " . " aName " . "from " . " artists " . "where " . " aName != 'DEFAULT' and " . " aName != '' " . "order by " . " aName " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $this->findInArray($array, $list["aName"]) ? print "\n"; $ndx = $list["aID"]; $rArray[$ndx] = $list["aName"]; } return $rArray; } function yesNoRadioOptions($name, $value=""){ $value = (!$value)?"Y":$value; $array = array( "Y" => "Yes", "N" => "No" ); $this->arrayRadioOptions($name, $array, $value); } function genderRadioOptions($name, $value=""){ $value = (!$value)?"Male":$value; $array = array( "Male" => "Male", "Female" => "Female" ); $this->arrayRadioOptions($name, $array, $value); } function retailerTypeRadioOptions($name, $value=""){ $value = (!$value)?"Retailer":$value; $array = array( "Retailer" => "Retailer", "Label" => "Label", "Word Employee" => "Word Employee", "Artist" => "Artist", "Salesrep" => "Salesrep", "Other" => "Other:" ); $this->arrayRadioOptions($name, $array, $value); } function reportTypeRadioOptions($name, $value=""){ $value = (!$value)?"Label":$value; $array = array( "Label" => "Label", "Word Employee" => "Word Employee", "Artist" => "Artist", "Salesrep" => "Salesrep", ); $this->arrayRadioOptions($name, $array, $value); } function arrayRadioOptions($name, $array, $value=""){ foreach($array as $key => $svalue){ if($key == "Male"||$key == "Female"){ $key == $value ? print "" : print ""; } else{ $key == $value ? print "" : print ""; } print stripslashes($svalue)." "; } } function getProductDetail($pID){ $Q = "select " . " pTitle, " . " pLabel, " . " pUpc, " . " pManualURL, " . " pCdUpc, " . " pCdPrice, " . " pCdAvail, " . " pCassUpc, " . " pCassPrice, " . " pCassAvail, " . " pVhsUpc, " . " pVhsPrice, " . " pVhsAvail, " . " pDvdUpc, " . " pDvdPrice, " . " pDvdAvail, " . " pCover, " . " pCoverWidth, " . " pCoverHeight, " . " date_format(pStreetDate, '%M %d, %Y') as street_date, " . " date_format(pStreetDate, '%m/%d/%Y') as pStreetDate, " . " pDesc, " . " pPDF, " . " pCMTA, " . " pStyle " . "from " . " products " . "where " . " pID = '$pID' " . ""; $result = $this->mySQL_Array($Q); return $result; } function removeFontDetail($string){ $string = str_replace("", "", $string); //$string = str_replace("", "", $string); //$string = str_replace(" ", " ", $string); //$string = str_replace(" >", " ", $string); $string = str_replace("size=2>", "size=1>", $string); $string = str_replace("size=3>", "size=1>", $string); $string = str_replace("size=4>", "size=1>", $string); /* $string = str_replace("style=\"", "", $string); $string = str_replace("12pt; ", "", $string); $string = str_replace("11pt; ", "", $string); $string = str_replace("10pt; ", "", $string); $string = str_replace("9pt; ", "", $string); $string = str_replace("8pt; ", "", $string); $string = str_replace("12.0pt; ", "", $string); $string = str_replace("11.0pt; ", "", $string); $string = str_replace("10.0pt; ", "", $string); $string = str_replace("9.0pt; ", "", $string); $string = str_replace("8.5pt; ", "", $string); $string = str_replace("FONT-SIZE: ", "", $string); $string = str_replace("FONT-FAMILY: ", "", $string); $string = str_replace("LAYOUT-GRID-MODE:", "", $string); $string = str_replace("Arial; ", "", $string); $string = str_replace("mso-bidi-font-size: ", "", $string); $string = str_replace("mso-bidi-font-family: ", "", $string); $string = str_replace("mso-bidi-language: ", "", $string); $string = str_replace("mso-ansi-language: ", "", $string); $string = str_replace("mso-fareast-font-family: ", "", $string); $string = str_replace("mso-fareast-language: ", "", $string); $string = str_replace("mso-spacerun: yes", "", $string); $string = str_replace("Roman??", "", $string); $string = str_replace("New Times", "", $string); $string = str_replace("", "", $string); $string = str_replace("size=3>", "", $string); $string = str_replace("size=4>", "", $string); $string = str_replace("", "", $string); $string = str_replace("", "", $string); $string = str_replace("", "", $string); $string = str_replace("", "", $string); $string = str_replace("", "", $string); $string = str_replace("line;>", "", $string); $string = str_replace("

    ", "", $string); $string = str_replace("

    ", "

    ", $string); $string = str_replace("\">", "", $string); */ return $string; } function getArtistDetail($aID){ $Q = "select " . " aName, " . " aURL " . "from " . " artists " . "where " . " aID = '$aID' " . ""; $result = $this->mySQL_Array($Q); return $result; } function getProductArtistCount($pID){ $Q = "select " . " count(aID) " . "from " . " product_artists " . "where " . " pID = '$pID' " . ""; $result = $this->mySQL_Array($Q); return $result[0]; } function productArtistCount($pID){ return $this->productArtistCount($pID); } function getTraxArtistCount($tID){ $Q = "select " . " count(tID) " . "from " . " trax_artists " . "where " . " tID = '$tID' " . ""; $result = $this->mySQL_Array($Q); return $result[0]; } function getFolioArtistCount($fID){ $Q = "select " . " count(fID) " . "from " . " folio_artists " . "where " . " fID = '$fID' " . ""; $result = $this->mySQL_Array($Q); return $result[0]; } function getTraxDetail($tID){ $Q = "select " . " tTitle, " . " tUpc, " . " tParentUpc, " . " tSeries, " . " tType, " . " tPrice, " . " tKeywords, " . " date_format(tStreetDate, '%M %d, %Y') as street_date, " . " date_format(tStreetDate, '%m/%d/%Y') as tStreetDate, " . " tAvail " . "from " . " trax " . "where " . " tID = '$tID' " . ""; $result = $this->mySQL_Array($Q); return $result; } function getFolioDetail($fID){ $Q = "select " . " fTitle, " . " fUpc, " . " fParentUpc, " . " fPrice, " . " date_format(fStreetDate, '%M %d, %Y') as street_date, " . " date_format(fStreetDate, '%m/%d/%Y') as fStreetDate, " . " fPhoto, " . " fPhotoWidth, " . " fPhotoHeight, " . " fAvail " . "from " . " folio " . "where " . " fID = '$fID' " . ""; $result = $this->mySQL_Array($Q); return $result; } function getProductArtistDataArray($pID){ $Q = "select " . " aID " . "from " . " product_artists " . "where " . " pID = '$pID' " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array[] = $list["aID"]; } return $array; } # function getTraxArtistDataArray($tID){ # $Q = "select " # . " aID " # . "from " # . " trax_artists " # . "where " # . " tID = '$tID' " # . ""; # # $result = $this->mySQL_Query($Q); # # while($list = mysql_fetch_array($result)){ # $array[] = $list["tID"]; # } # # return $array; # } function getProductSongArtistDataArray($pID){ $Q = "select " . " product_songs.psID, " . " aID " . "from " . " product_song_artists, " . " product_songs " . "where " . " product_song_artists.psID = product_songs.psID and " . " pID = '$pID' " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $psID = $list["psID"]; $array["$psID"][] = $list["aID"]; } return $array; } function getTraxArtistDataArray($tID){ $Q = "select " . " aID " . "from " . " trax_artists " . "where " . " tID = '$tID' " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array[] = $list["aID"]; } return $array; } function getFolioArtistDataArray($fID){ $Q = "select " . " aID " . "from " . " folio_artists " . "where " . " fID = '$fID' " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array[] = $list["aID"]; } return $array; } function getFolioSongDataArray($fID){ $Q = "select " . " fsID, " . " fsTitle " . "from " . " folio_songs " . "where " . " fID = '$fID' " . "order by " . " fsID " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array["fsID"][] = $list["fsID"]; $array["fsTitle"][] = $list["fsTitle"]; } return $array; } function getProductMerchandiseDataArray($pID){ $Q = "select " . " pmID, " . " mUpc, " . " mPrice, " . " mDesc, " . " mPhoto, " . " mPhotoWidth, " . " mPhotoHeight " . "from " . " product_merchandise " . "where " . " pID = '$pID' " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array["pmID"][] = $list["pmID"]; $array["mUpc"][] = $list["mUpc"]; $array["mPrice"][] = $list["mPrice"]; $array["mDesc"][] = $list["mDesc"]; $array["mPhoto"][] = $list["mPhoto"]; $array["mPhotoWidth"][] = $list["mPhotoWidth"]; $array["mPhotoHeight"][] = $list["mPhotoHeight"]; } return $array; } function getProductMerchandiseDataArray2($pID){ $Q = "select " . " pmID, " . " mUpc, " . " mPrice, " . " mDesc, " . " mPhoto, " . " mPhotoWidth, " . " mPhotoHeight " . "from " . " product_merchandise, " . " products " . "where " . " product_merchandise.pID = products.pID and " . " product_merchandise.pID = '$pID' " // . " to_days(products.pStreetDate) - to_days(now()) <= 30 " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array["pmID"][] = $list["pmID"]; $array["mUpc"][] = $list["mUpc"]; $array["mPrice"][] = $list["mPrice"]; $array["mDesc"][] = $list["mDesc"]; $array["mPhoto"][] = $list["mPhoto"]; $array["mPhotoWidth"][] = $list["mPhotoWidth"]; $array["mPhotoHeight"][] = $list["mPhotoHeight"]; } return $array; } function getProductSongDataArray($pID){ $Q = "select " . " psID, " . " psTitle, " . " psAudio " . "from " . " product_songs " . "where " . " pID = '$pID' " . "order by " . " psID " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array["psID"][] = $list["psID"]; $array["psTitle"][] = $list["psTitle"]; $array["psAudio"][] = $list["psAudio"]; } return $array; } function getProductArtistString($pID){ $Q = "select " . " aName " . "from " . " product_artists, " . " artists " . "where " . " product_artists.aID = artists.aID and " . " pID = '$pID' " . "order by " . " aName " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array[] = $list["aName"]; } $string = @join(" / ", $array); return $string; } function getTraxArtistString($tID){ $Q = "select " . " aName " . "from " . " trax_artists, " . " artists " . "where " . " trax_artists.aID = artists.aID and " . " tID = '$tID' " . "order by " . " aName " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array[] = $list["aName"]; } $string = @join(" / ", $array); return $string; } function getFolioArtistString($fID){ $Q = "select " . " aName " . "from " . " folio_artists, " . " artists " . "where " . " folio_artists.aID = artists.aID and " . " fID = '$fID' " . "order by " . " aName " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array[] = $list["aName"]; } $string = @join(" / ", $array); return $string; } function crunchOnOneLine($string){ $string = ereg_replace("\n", "", stripslashes($string)); $string = ereg_replace("\r", "", $string); $string = ereg_replace("\t", "", $string); $string = str_replace("\"", "'", $string); return $string; } function getOldDateArray($string){ $string = str_replace("/", "|", $string); $string = str_replace("-", "|", $string); if(strlen($string)<6){ $this->returnError("The date must be in the mm/dd/yy, mm/dd/yyyy, mm-dd-yy, or mm-dd-yyyy format"); } $array = explode("|", $string); $data[mon] = $this->twoDigit($array[0]); $data[day] = $this->twoDigit($array[1]); $data[year] = $this->swapOutYear($array[2]); return $data; } function formatMySQLdate($string){ $array = $this->getOldDateArray($string); $date = $array[year]."-".$array[mon]."-".$array[day]; return $date; } function swapOutYear($yr){ if(strlen($yr)==4){ return $yr; } elseif($yr<50){ return "20".$yr; } else { return "19".$yr; } } function getNewsDetail($nID){ $Q = "select " . " nID, " . " nTitle, " . " nTeaser, " . " nBody, " . " nDate, " . " date_format(nDate, '%m/%d/%Y') as n_date, " . " date_format(nArchiveDate, '%m/%d/%Y') as a_date, " . " nArchiveDate " . "from " . " news " . "where " . " nID = '$nID' " . ""; $result = $this->mySQL_Array($Q); return $result; } function getOnTourArtistDropDown($value=""){ $Q = "select " . " distinct(aName) as aName " . "from " . " on_tour " . "where " . " otDate >= now() " . "order by " . " aName " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $list[aName] == $value ? print "\n"; } } // function getOnTourArtistSchedule($aName="", $otState=""){ // $ex1 = ($aName)?" and aName = \"$aName\" ":""; // $ex2 = ($otState)?"and otState = \"$otState\" ":""; // // $order = "otDate, otState, otCity"; // // $Q = "select " // . " aID, " // . " aName, " // . " date_format(otDate, '%b') as otMonth, " // . " date_format(otDate, '%b. %d, %Y') as date, " // . " otDate, " // . " otCity, " // . " otState, " // . " otVenue, " // . " otOther " // . "from " // . " on_tour " // . "where " // . " otDate >= now() " // . " $ex1 " // . " $ex2 " // . "order by " // . " $order " // . ""; // // $result[result] = $this->mySQL_Query($Q); // $result[count] = mysql_num_rows($result[result]); // // return $result; // } function getOnTourArtistSchedule($aName="", $otState=""){ if($aName=="null" and $otState=="null") { $ex1 = ""; $ex2 = ""; } else if($aName=="null") { $ex1 = "and otState = \"$otState\""; $ex2 = ""; } else if($otState=="null") { $ex1 = "and aName = \"$aName\""; $ex2 = ""; } else { $ex1 = ($aName)?" and aName = \"$aName\" ":""; $ex2 = ($otState)?"and otState = \"$otState\" ":""; } $order = "otDate, otState, otCity"; $Q = "select " . " aID, " . " aName, " . " date_format(otDate, '%b') as otMonth, " . " date_format(otDate, '%b. %d, %Y') as date, " . " date_format(otDate, '%m/%d/%y') as mdy_date, " . " otDate, " . " otCity, " . " otState, " . " otVenue, " . " otOther " . "from " . " on_tour " . "where " . " otDate >= now() " . " $ex1 " . " $ex2 " . "order by " . " $order " . ""; $result[result] = $this->mySQL_Query($Q); $result[count] = mysql_num_rows($result[result]); return $result; } function getNewsList($type=""){ $ex = ($type=="archives")?"nArchiveDate <= now() ":"nArchiveDate > now() "; $Q = "select " . " nID, " . " nTitle, " . " nTeaser, " . " date_format(nDate, '%M %d, %Y') as date, " . " date_format(nDate, '%m/%d/%y') as mdy_date, " . " nDate, " . " nArchiveDate " . "from " . " news " . "where " . " $ex " . "order by " . " nDate desc, " . " nID desc " . ""; $result[result] = $this->mySQL_Query($Q); $result[count] = mysql_num_rows($result[result]); return $result; } function getNewsFileArray($nID){ $Q = "select " . " nfID, " . " nFile, " . " nName " . "from " . " news_files " . "where " . " nID = '$nID' and " . " nName != '' and " . " nFile != '' " . "order by " . " nfID " . ""; $result = $this->mySQL_Query($Q); while($list = mysql_fetch_array($result)){ $array[nfID][] = $list[nfID]; $array[nFile][] = $list[nFile]; $array[nName][] = $list[nName]; } return $array; } function associativeArrayDropDown3($array, $value=""){ foreach($array as $svalue => $key){ $value==$svalue ? print "\t\t\t\n"; } } function getUSstateArray(){ $array = array ( "AL" => "Alabama", "AK" => "Alaska", "AZ" => "Arizona", "AR" => "Arkansas", "CA" => "California", "CO" => "Colorado", "CT" => "Connecticut", "DE" => "Delaware", "DC" => "District of Columbia", "FL" => "Florida", "GA" => "Georgia", "HI" => "Hawaii", "ID" => "Idaho", "IL" => "Illinois", "IN" => "Indiana", "IA" => "Iowa", "KS" => "Kansas", "KY" => "Kentucky", "LA" => "Louisiana", "ME" => "Maine", "MD" => "Maryland", "MA" => "Massachusetts", "MI" => "Michigan", "MN" => "Minnesota", "MS" => "Mississippi", "MO" => "Missouri", "MT" => "Montana", "NE" => "Nebraska", "NV" => "Nevada", "NH" => "New Hampshire", "NJ" => "New Jersey", "NM" => "New Mexico", "NY" => "New York", "NC" => "North Carolina", "ND" => "North Dakota", "OH" => "Ohio", "OK" => "Oklahoma", "OR" => "Oregon", "PA" => "Pennsylvania", "RI" => "Rhode Island", "SC" => "South Carolina", "SD" => "South Dakota", "TN" => "Tennessee", "TX" => "Texas", "UT" => "Utah", "VT" => "Vermont", "VA" => "Virginia", "WA" => "Washington", "WV" => "West Virginia", "WI" => "Wisconsin", "WY" => "Wyoming" ); return $array; } function getStateDropDown($value=""){ $array = $this->getUSstateArray(); $this->associativeArrayDropDown3($array, $value); } function isValidRetailer($rString){ global $db; $Q = "select " . " count(*) " . "from " . " retailers " . "where " . " rString = \"$rString\" and " . " rStatus = 'Live' " . ""; $result = $db->mySQL_Array($Q); if($result[0]==1){ return true; } else { return false; } } function isValidNewsItem($nID){ global $db; $Q = "select " . " count(*) " . "from " . " news " . "where " . " nID = '$nID' " . ""; $result = $db->mySQL_Array($Q); if($result[0]==1){ return true; } else { return false; } } } ?> getOldDateArray($string); $mon = $db->oneDigit($array[mon]); $days = $this->daysInMonth($mon, $array[year]); //$array[mon] = ""; //$array[day] = ""; //$array[year] = ""; if($array[day] > $days){ return false; } elseif($array[mon] > 12) { return false; } elseif($array[year] >= date("Y")) { return false; } else { return true; } } function validateSignupForm($info){ global $db; $info = $db->removeSpaces($info); if($info[rEmail] && $this->emailExists($info[rEmail])){ $array[] = "A User With The Email \"$info[rEmail]\" Already Exists, You Cannot Have 2 Accounts"; } else { if(!$info[rFname]){ $array[] = "Please Enter Your First Name"; } if(!$info[rLname]){ $array[] = "Please Enter Your Last Name"; } if(!$info[rEmail]){ $array[] = "Please Enter Your E-mail"; } elseif(!$db->validateEmail($info[rEmail])){ $array[] = "Please Enter a Valid E-mail"; } else { // do nothing } if(!$info[rEmail2]){ $array[] = "Please Enter Your E-mail (Re-enter)"; } if($info[rEmail] && $info[rEmail2] && $info[rEmail] != $info[rEmail2]){ $array[] = "Your E-mail and Your Re-entered Email Do Not Match"; } if(!$info[rGender]){ $array[] = "Please Choose Your Gender"; } if($info[rBirthDate] && !$this->isValidDateFormat($info[rBirthDate])){ $array[] = "Please Enter Your Birthdate (in the mm/dd/yyyy format)"; } elseif($info[rBirthDate] && !$this->isValidBirthday($info[rBirthDate])){ $array[] = "Please Enter Your REAL Birthdate (in the mm/dd/yyyy format)"; } else { // do nothing } if(!$info[rUser]){ $array[] = "Please Enter a Username"; } if(!$info[rUser2]){ $array[] = "Please Enter a Username (Re-enter)"; } if($info[rUser] && $info[rUser2] && $info[rUser] != $info[rUser2]){ $array[] = "Your Username and Your Re-entered Username Do Not Match"; } elseif($this->usernameExists($info[rUser])){ $array[] = "The Username \"$info[rUser]\" Already Exists, Please Enter Another Username"; } else { // do nothing } if(!$info[rPass]){ $array[] = "Please Enter a Password"; } if(!$info[rPass2]){ $array[] = "Please Enter a Password (Re-enter)"; } if($info[rPass] && $info[rPass2] && $info[rPass] != $info[rPass2]){ $array[] = "Your Password and Your Re-entered Password Do Not Match"; } if(!$info[rType]){ $array[] = "Please Choose a User Type"; } elseif($info[rType]=="Other" && !$info[rTypeOther]){ $array[] = "Please Specify Your User Type (You Chose Other)"; } else { //do nothing } if(!$info[rBusName]){ $array[] = "Please Enter a Business Name"; } if($info[rType]=="Other"||$info[rType]=="Retailer"){ if(!$info[rActNum]){ $array[] = "Please Enter a Word Distribution Account Number"; } if(!$info[rMailAddress1]){ $array[] = "Please Enter a Mailing Address"; } if(!$info[rMailCity]){ $array[] = "Please Enter a Mailing City"; } if(!$info[rMailState]){ $array[] = "Please Enter a Mailing State"; } if(!$info[rMailZip]){ $array[] = "Please Enter a Mailing Zip"; } if(!$info[rMailCountry]){ $array[] = "Please Enter a Mailing Country"; } if(!$info[rBusAddress1]){ $array[] = "Please Enter a Business Address"; } if(!$info[rBusCity]){ $array[] = "Please Enter a Business City"; } if(!$info[rBusState]){ $array[] = "Please Enter a Business State"; } if(!$info[rBusZip]){ $array[] = "Please Enter a Business Zip"; } if(!$info[rBusCountry]){ $array[] = "Please Enter a Business Country"; } if(!$info[rPhone]){ $array[] = "Please Enter a Phone"; } elseif(strlen($info[rPhone])<10){ $array[] = "Please Enter a Valid Phone"; } else { // do nothing } } } if(is_array($array) & count($array)>0){ return $array; } else { return false; } } function validateEditForm($info){ global $db; $info = $db->removeSpaces($info); if($info[rEmail] && $info[rEmail]!=$info[old_rEmail]){ if($this->emailExists($info[rEmail])){ $array[] = "A User With The Email \"$info[rEmail]\" Already Exists, You Cannot Have 2 Accounts"; } } else { if(!$info[rFname]){ $array[] = "Please Enter Your First Name"; } if(!$info[rLname]){ $array[] = "Please Enter Your Last Name"; } if(!$info[rEmail]){ $array[] = "Please Enter Your E-mail"; } elseif(!$db->validateEmail($info[rEmail])){ $array[] = "Please Enter a Valid E-mail"; } else { // do nothing } if(!$info[rGender]){ $array[] = "Please Choose Your Gender"; } if($info[rBirthDate] && !$this->isValidDateFormat($info[rBirthDate])){ $array[] = "Please Enter Your Birthdate (in the mm/dd/yyyy format)"; } if(!$info[rType]){ $array[] = "Please Choose a User Type"; } elseif($info[rType]=="Other" && !$info[rTypeOther]){ $array[] = "Please Specify Your User Type (You Chose Other)"; } else { //do nothing } if(!$info[rBusName]){ $array[] = "Please Enter a Business Name"; } if(!$info[rActNum]){ $array[] = "Please Enter a Word Distribution Account Number"; } if(!$info[rMailAddress1]){ $array[] = "Please Enter a Mailing Address"; } if(!$info[rMailCity]){ $array[] = "Please Enter a Mailing City"; } if(!$info[rMailState]){ $array[] = "Please Enter a Mailing State"; } if(!$info[rMailZip]){ $array[] = "Please Enter a Mailing Zip"; } if(!$info[rMailCountry]){ $array[] = "Please Enter a Mailing Country"; } if(!$info[rBusAddress1]){ $array[] = "Please Enter a Business Address"; } if(!$info[rBusCity]){ $array[] = "Please Enter a Business City"; } if(!$info[rBusState]){ $array[] = "Please Enter a Business State"; } if(!$info[rBusZip]){ $array[] = "Please Enter a Business Zip"; } if(!$info[rBusCountry]){ $array[] = "Please Enter a Business Country"; } if(!$info[rPhone]){ $array[] = "Please Enter a Phone"; } elseif(strlen($info[rPhone])<10){ $array[] = "Please Enter a Valid Phone"; } else { // do nothing } } if(is_array($array) & count($array)>0){ return $array; } else { return false; } } function validatePasswordForm($info, $rID){ global $db; $info = $db->removeSpaces($info); if(!$info[old_rPass]){ $array[] = "Please Enter Your Current Password"; } if(!$info[rPass]){ $array[] = "Please Enter Your New Password"; } if(!$info[rPass2]){ $array[] = "Please Enter Your New Password (Re-enter)"; } if($info[old_rPass] != $this->getCurrentPassword($rID)){ $array[] = "The Current Password You Entered Is Incorrect"; } if($info[rPass] && $info[rPass2] && $info[rPass] != $info[rPass2]){ $array[] = "Your Password and Your Re-entered Password Do Not Match"; } if(is_array($array) & count($array)>0){ return $array; } else { return false; } } function getCurrentPassword($rID){ global $db; $Q = "select " . " rPass " . "from " . " retailers " . "where " . " rID = \"$rID\" " . ""; $result = $db->mySQL_Array($Q); return $result[0]; } function updatePassword($rPass, $rID){ global $db; $Q = "update " . " retailers " . "set " . " rPass = \"$rPass\" " . "where " . " rID = \"$rID\" " . ""; $db->mySQL_Query($Q); } function saveRetailer($info){ global $db; $info[rBirthDate] = $db->formatMySQLdate($info[rBirthDate]); $info[rMailState] = strtoupper($info[rMailState]); $info[rBusState] = strtoupper($info[rBusState]); if($info[rID]){ $this->updateRetailer($info, $info[rID]); } else { $info[rID] = $this->insertRetailer($info); } return $info[rID]; } function insertRetailer($info){ global $db; $info[rStatus] = (!$info[rStatus])?"Pending":$info[rStatus]; $info[rString] = $db->createString(); $Q = "insert into retailers " . " (rString, " . " rFname, " . " rLname, " . " rEmail, " . " rGender, " . " rBirthDate, " . " rType, " . " rTypeOther, " . " rBusName, " . " rActNum, " . " sameAddr, " . " rMailAddress1, " . " rMailAddress2, " . " rMailCity, " . " rMailState, " . " rMailZip, " . " rMailCountry, " . " rBusAddress1, " . " rBusAddress2, " . " rBusCity, " . " rBusState, " . " rBusZip, " . " rBusCountry, " . " rPhone, " . " rFax, " . " rFaxRec, " . " rEmailRec, " . " rUser, " . " rPass, " . " rDate, " . " rStatus) " . "values " . " (\"$info[rString]\", " . " \"$info[rFname]\", " . " \"$info[rLname]\", " . " \"$info[rEmail]\", " . " \"$info[rGender]\", " . " \"$info[rBirthDate]\", " . " \"$info[rType]\", " . " \"$info[rTypeOther]\", " . " \"$info[rBusName]\", " . " \"$info[rActNum]\", " . " \"$info[sameAddr]\", " . " \"$info[rMailAddress1]\", " . " \"$info[rMailAddress2]\", " . " \"$info[rMailCity]\", " . " \"$info[rMailState]\", " . " \"$info[rMailZip]\", " . " \"$info[rMailCountry]\", " . " \"$info[rBusAddress1]\", " . " \"$info[rBusAddress2]\", " . " \"$info[rBusCity]\", " . " \"$info[rBusState]\", " . " \"$info[rBusZip]\", " . " \"$info[rBusCountry]\", " . " \"$info[rPhone]\", " . " \"$info[rFax]\", " . " \"$info[rFaxRec]\", " . " \"$info[rEmailRec]\", " . " \"$info[rUser]\", " . " \"$info[rPass]\", " . " now(), " . " \"$info[rStatus]\") " . ""; mysql_query($Q); $error = mysql_error(); if(strstr($error, "Duplicate")){ $db->returnError("The username \"$info[rUser]\" already exists--please go back and enter another username"); } return mysql_insert_id(); } function updateRetailer($info, $rID){ global $db; $Q = "update retailers set " . " rFname =\"$info[rFname]\", " . " rLname = \"$info[rLname]\", " . " rEmail = \"$info[rEmail]\", " . " rGender = \"$info[rGender]\", " . " rBirthDate= \"$info[rBirthDate]\", " . " rType = \"$info[rType]\", " . " rTypeOther = \"$info[rTypeOther]\", " . " rBusName = \"$info[rBusName]\", " . " rActNum = \"$info[rActNum]\", " . " rMailAddress1 = \"$info[rMailAddress1]\", " . " rMailAddress2 = \"$info[rMailAddress2]\", " . " rMailCity = \"$info[rMailCity]\", " . " rMailState = \"$info[rMailState]\", " . " rMailZip = \"$info[rMailZip]\", " . " rMailCountry = \"$info[rMailCountry]\", " . " rBusAddress1 = \"$info[rBusAddress1]\", " . " rBusAddress2 = \"$info[rBusAddress2]\", " . " rBusCity = \"$info[rBusCity]\", " . " rBusState = \"$info[rBusState]\", " . " rBusZip = \"$info[rBusZip]\", " . " rBusCountry = \"$info[rBusCountry]\", " . " rPhone = \"$info[rPhone]\", " . " rFax = \"$info[rFax]\", " . " rFaxRec = \"$info[rFaxRec]\", " . " rEmailRec = \"$info[rEmailRec]\", " . " rStatus = \"$info[rStatus]\" " . "where " . " rID = '$info[rID]' " . ""; $db->mySQL_Query($Q); } function sendWordEmail($info, $to=""){ global $db; $from = "retailers@WordEntertainment.com"; $to = (!$to)?"Josh.Mullenix@WordEntertainment.com":$to; // $to = (!$to)?"John.Chapman@wmg.com":$to; $subj = "Retailer Application (Pending)"; if($info[rFaxRec]=="Y") $act[] = "By Fax"; if($info[rEmailRec]=="Y") $act[] = "By Email"; $act = @join(", ", $act); $body = "Matt, here's a retailer application that is pending your approval:\n\n" . "Name: $info[rFname] $info[rLname]\n" . "Email: $info[rEmail]\n" . "Gender: $info[rGender]\n" . "Birthdate: $info[rBirthDate]\n" . "Username: $info[rUser]\n\n" . "Type: $info[rType] $info[rTypeOther]\n" . "Business Name: $info[rBusName]\n" . "Act. Number: $info[rActNum]\n\n" . "Mailing Address:\n" . "$info[rMailAddress1]\n" . "$info[rMailAddress2]\n" . "$info[rMailCity] $info[rMailState] $info[rMailZip]\n" . "$info[rMailCountry]\n\n" . "Business Address:\n" . "$info[rBusAddress1]\n" . "$info[rBusAddress2]\n" . "$info[rBusCity] $info[rBusState] $info[rBusZip]\n" . "$info[rBusCountry]\n\n" . "Phone: $info[rPhone]\n" . "Fax: $info[rFax]\n\n" . "Receive Info:\n" . "$act\n\n" . "This retailer is pending your approval:\n" . "http://www.worddistribution.com/docs/admin/retailersCMS.php?mode=edit&rID=$info[rID]" . ""; $db->sendEmailMsg($to, $subj, $body, $from); } function validateLogin($info){ global $db; $info = $db->removeSpaces($info); if(!$info[rUser]){ $array[] = "Please Enter Your Username"; } if(!$info[rPass]){ $array[] = "Please Enter Your Password"; } if($info[rUser] && $info[rPass] && $this->isOtherLogin($info[rUser], $info[rPass], 'Pending')){ $array[] = "Your Account Has Not Been Approved Yet"; } elseif($info[rUser] && $info[rPass] && $this->isOtherLogin($info[rUser], $info[rPass], 'Declined')){ $array[] = "Your Account Has Been Declined"; } elseif($info[rUser] && $info[rPass] && !$this->isValidLogin($info[rUser], $info[rPass])){ $array[] = "That Username / Password Combination Does Not Match Our Records"; } else { // do nothing } if(is_array($array) & count($array)>0){ return $array; } else { return false; } } function validateEmailLogin($info){ global $db; $info = $db->removeSpaces($info); if(!$info[rEmail]){ $array[] = "Please Enter Your E-mail"; } elseif(!$db->validateEmail($info[rEmail])){ $array[] = "Please Enter a Valid E-mail"; } elseif($this->isOtherLogin2($info[rEmail], 'Pending')){ $array[] = "Your Account Has Not Been Approved Yet. You Cannot Login Yet"; } elseif($this->isOtherLogin2($info[rEmail], 'Declined')){ $array[] = "Your Account Has Been Declined. You Cannot Login"; } elseif(!$this->emailExists($info[rEmail])){ $array[] = "There Is No User With With An E-mail of \"$info[rEmail]\""; } else { // do nothing } if(is_array($array) & count($array)>0){ return $array; } else { return false; } } function isValidLogin($rUser, $rPass){ global $db; $Q = "select " . " count(*) " . "from " . " retailers " . "where " . " rUser = \"$rUser\" and " . " rPass = \"$rPass\" and " . " rStatus = 'Live' " . ""; $result = $db->mySQL_Array($Q); if($result[0]==1){ return true; } else { return false; } } function isOtherLogin($rUser, $rPass, $rStatus){ global $db; $Q = "select " . " count(*) " . "from " . " retailers " . "where " . " rUser = \"$rUser\" and " . " rPass = \"$rPass\" and " . " rStatus = \"$rStatus\" " . ""; $result = $db->mySQL_Array($Q); if($result[0]==1){ return true; } else { return false; } } function isOtherLogin2($rEmail, $rStatus){ global $db; $Q = "select " . " count(*) " . "from " . " retailers " . "where " . " rEmail = \"$rEmail\" and " . " rStatus = \"$rStatus\" " . ""; $result = $db->mySQL_Array($Q); if($result[0]==1){ return true; } else { return false; } } function getRetailerLoginString($rUser, $rPass){ global $db; $Q = "select " . " rString " . "from " . " retailers " . "where " . " rUser = \"$rUser\" and " . " rPass = \"$rPass\" " . ""; $result = $db->mySQL_Array($Q); if($result[0]){ return $result[0]; } else { return false; } } function usernameExists($rUser){ global $db; $Q = "select " . " count(*) " . "from " . " retailers " . "where " . " rUser = \"$rUser\" " . ""; $result = $db->mySQL_Array($Q); if($result[0]==1){ return true; } else { return false; } } function emailExists($rEmail){ global $db; $Q = "select " . " count(*) " . "from " . " retailers " . "where " . " rEmail = \"$rEmail\" " . ""; $result = $db->mySQL_Array($Q); if($result[0]==1){ return true; } else { return false; } } # function getRetailerDetail($rString){ # # } function sendRetailerLoginInfo($rEmail, $from=""){ global $db; if($db->validateEmail($rEmail)){ $Q = "select " . " rFname, " . " rUser, " . " rPass " . "from " . " retailers " . "where " . " rEmail =\"$rEmail\" " . ""; $result = $db->mySQL_Array($Q); $subj = "Login Reminder"; $from = (!$from)?"info@worddistribution.com":$from; $body = stripslashes($result[rFname]).",\n\n" . "As requested, here is your username & password:\n\n" . "Username: $result[rUser]\n" . "Password: $result[rPass]\n\n" . "Login At:\n" . "http://www.worddistribution.com/docs/_retailers/loginCMS.php" . ""; $db->sendEmailMsg($rEmail, $subj, $body, $from); } } function getRetailerStatusDropDown($value=""){ global $db; $array = array("Live", "Pending", "Declined"); $db->arrayDropDown($array, $value); } function sendRetailerApprovedEmail($rEmail, $from=""){ global $db; if($db->validateEmail($rEmail)){ $Q = "select " . " rFname, " . " rUser, " . " rPass " . "from " . " retailers " . "where " . " rEmail =\"$rEmail\" " . ""; $result = $db->mySQL_Array($Q); $subj = "Retailer Application (Approved)"; $from = (!$from)?"info@worddistribution.com":$from; $body = stripslashes($result[rFname]).",\n\n" . "Welcome to WordDistribution.com! \n\n" . "Your retailer account for WordDistribution.com has been approved. You now have full access this New Site and New Resources, which includes the comprehensive Song and Product Finder, Final Art/Ad Copy files, Promotions, Programs and More!\n\n" . "Here is your username & password:\n\n" . "Username: $result[rUser]\n" . "Password: $result[rPass]\n\n" . "Login At:\n" . "http://www.worddistribution.com/docs/_retailers/loginCMS.php\n\n" . "Thank you for your support of Word Distribution. Please let us know if we can improve your online experience in anyway.\n\n" . ""; $db->sendEmailMsg($rEmail, $subj, $body, $from); } } function getRetailerDetail($id){ global $db; $field = (is_numeric($id))?"rID":"rString"; $Q = "select" . " rID, " . " rString, " . " rFname, " . " rLname, " . " rEmail, " . " rGender, " . " date_format(rBirthDate, '%m/%d/%Y') as rBirthDate, " . " rType, " . " rTypeOther, " . " rBusName, " . " rActNum, " . " sameAddr, " . " rMailAddress1, " . " rMailAddress2, " . " rMailCity, " . " rMailState, " . " rMailZip, " . " rMailCountry, " . " rBusAddress1, " . " rBusAddress2, " . " rBusCity, " . " rBusState, " . " rBusZip, " . " rBusCountry, " . " rPhone, " . " rFax, " . " rFaxRec, " . " rEmailRec, " . " rUser, " . " rPass, " . " rStatus " . "from " . " retailers " . "where " . " $field = \"$id\" " . ""; $result = $db->mySQL_Array($Q); return $result; } function getRetailerID($rString){ global $db; $Q = "select" . " rID " . "from " . " retailers " . "where " . " rString = \"$rString\" " . ""; $result = $db->mySQL_Array($Q); return $result[0]; } function deleteRetailer($rID){ global $db; $Q = "delete " . "from " . " retailers " . "where " . " rID = '$rID' " . ""; $db->mySQL_Query($Q); } } ?>