. return $output; } #######Aggiorna scores databse inserendo ",accompaniment,mp3," come keywords #######Se l' item include MP3 accomapniment files (script 2-12-09)... function str_replace_once($search, $replace, $subject) { $firstChar = strpos($subject, $search); if($firstChar !== false) { $beforeStr = substr($subject,0,$firstChar); $afterStr = substr($subject, $firstChar + strlen($search)); return $beforeStr.$replace.$afterStr; } else { return $subject; } } //NOTE: This function below is used just by media server! function checkaccompaniments($null) { global $basedir, $GLOBscorestable, $scores_dev, $composerarrayindexrev, $GLOBComposertable; $query = "SELECT composer, ID, keywords FROM $GLOBscorestable WHERE 1"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { while ($row = mysql_fetch_arrayFF($result)) { $accompaniment = 0; $composer = $row["composer"]; $itemid = $row["ID"]; $keywords = $row["keywords"]; #print "ecco: $composer - $itemid - $keywords
"; #Definisce $name_composer da $composer include '/home/webadmin/virtualsheetmusic.com/html/cgi-bin/search/php-includes/composers_exceptions.inc'; $singleoffer = $itemid; $singleoffer = eregi_replaceFF("full$", "", $singleoffer); if ($name_composer and $singleoffer) { #Controlla... $file = $basedir."/Mp3acco/".$name_composer."/".$singleoffer; if (file_exists($file)) { $accompaniment = 1; } } #Se c'e' accompaniment... if ($accompaniment and !eregFF(",accompaniment,mp3,file,", $keywords)) { $keywordsmod = str_replace_once(",",",accompaniment,mp3,file,Mp3 accompaniment files,", $keywords); $query1 = "UPDATE $GLOBscorestable SET keywords = '$keywordsmod' WHERE ID = '$itemid'"; $result1 = mysql_queryFF($query1); $accodone ++; #print "ECCOCILILI: $query1

"; } } } return $accodone; } ##Funzione per ritornare nome composer (finalmente!!! 4-29-09)... function getcomposername($composer) { global $scores_dev, $composerarrayindexrev, $GLOBComposertable; include '/home/webadmin/virtualsheetmusic.com/html/cgi-bin/search/php-includes/composers_exceptions.inc'; if ($name_composer == "Miscellaneous") { $name_composer = "miscellaneous composers"; } elseif ($name_composer == "StraussF") { $name_composer = "Strauss"; } elseif ($name_composer == "Beriot") { $name_composer = "C. De Beriot"; } elseif ($name_composer == "BachCPE") { $name_composer = "Bach"; } return $name_composer; } function getcomposernameFORDIRS($composer, $abbrv = 0) { global $GLOBComposertable; if (strpos($composer, "&#") === false) {//Fix 3/29/24, 7:45 AM for those composers with HTML entities inside!! like: Julius Fuč... $composer = html_entity_decode($composer, ENT_QUOTES | ENT_HTML5); } $composer = escapeMySQL($composer); if ($abbrv) {//If from abbreviated name (i.e. F.J.Haydn)...12-3-2015... $queryHERE = "SELECT ID FROM $GLOBComposertable WHERE abbreviated_name = '$composer'"; } else { $queryHERE = "SELECT ID FROM $GLOBComposertable WHERE name = '$composer'"; } $resultHERE = mysql_queryFF($queryHERE); $nitemsHERE = mysql_num_rowsFF($resultHERE); if ($nitemsHERE) { $name = mysql_resultFF($resultHERE,0, 'ID'); } else { $name = ''; } return $name; } ##Funzione per pulire campo "pages" in scores (usato da score_variables. inc e altri) ##Creata per iPhone implementation on 5-1-09)... function cleanpages($pages) { $pages = str_replace ("\x0B", "
", $pages); $pages = strtolower($pages); $pages = convertinstrumentnames($pages); return $pages; } function convertinstrumentnames($pages) { #converte i: e ii: in I e II per violin I, violin II etc.� $pages = str_replace(" vi:"," VI:",$pages); $pages = str_replace(" v:"," V:",$pages); $pages = str_replace(" iv:"," IV:",$pages); $pages = str_replace(" iii:"," III:",$pages); $pages = str_replace(" ii:"," II:",$pages); $pages = str_replace(" i:"," I:",$pages); $pages = str_replace(" iii in "," III in ",$pages); $pages = str_replace(" ii in "," II in ",$pages); $pages = str_replace(" i in "," I in ",$pages); $pages = str_replace(" vi "," VI ",$pages); $pages = str_replace(" v "," V ",$pages); $pages = str_replace(" iv "," IV ",$pages); $pages = str_replace(" iii "," III ",$pages); $pages = str_replace(" ii "," II ",$pages); $pages = str_replace(" i "," I ",$pages); #Converte in eb con in Eb $pages = str_replace(" in eb:"," in Eb:",$pages); $pages = str_replace(" in eb "," in Eb ",$pages); #Converte in bb con in Bb $pages = str_replace(" in bb:"," in Bb:",$pages); $pages = str_replace(" in bb "," in Bb ",$pages); #Converte in f con in F $pages = str_replace(" in f:"," in F:",$pages); $pages = str_replace(" in f "," in F ",$pages); #Converte in d con in D $pages = str_replace(" in d:"," in D:",$pages); $pages = str_replace(" in d "," in D ",$pages); #Etc... $pages = str_replace(" in c:"," in C:",$pages); $pages = str_replace(" in c "," in C ",$pages); $pages = str_replace(" in a:"," in A:",$pages); $pages = str_replace(" in a "," in A ",$pages); $pages = str_replace(" in g "," in G ",$pages); #Altre conversioni $pages = str_replace("c major","C major",$pages); $pages = str_replace("d major","D major",$pages); $pages = str_replace("version in bb","version in Bb",$pages); $pages = str_replace("version in c","version in C",$pages); return $pages; } function resetaccentate($string) { $string = str_replace("ä","a",$string); $string = str_replace("ë","e",$string); $string = str_replace("é","e",$string); $string = str_replace("ä","a",$string); $string = str_replace("ò","o",$string); return $string; } #Funzione per controllare se si e' su iPhone (7-9-09)... #Torna 1 o 0... function isiphone() { global $HTTP_USER_AGENT; if (eregFF("iPhone", $HTTP_USER_AGENT) or eregFF("iPod", $HTTP_USER_AGENT)) { return 1; } else { return 0; } } #Funzione per forzare download (o no) di qualsiasi file... function downloadauto($finalfile, $name, $force = 1) { #La variabile $finalfile contiene il file (con basedir path completa)... #La variabile $name contiene il nome (opzionale)... #La variabile $force forza download (1) o no (0)... global $GLOBbasedir, $GLOBmedia; //Checks if file exists, otherwise it tries to look on media server... //Check added 9-20-2018... if (!file_exists($finalfile)) { if (file_existsAPI($finalfile)) { //Redirects to downloadauto on media server... $finalfile = str_replace($GLOBbasedir, "", $finalfile); $destino = 'https://'.$GLOBmedia.'/scripts/downloadauto.php?file='.$finalfile; #$destino = "https://www.virtualsheetmusic.com/downloadsstatics/extras/CarolOfTheBells.pdf"; #$destino = "https://media.virtualsheetmusic.com/media/firstpage/First.pdf"; //This block below is a quick fix for old iOS app 4.x 11/11/22, 3:26 PM... if (strpos($_SERVER['HTTP_USER_AGENT'], "Darwin") !== false) { if (preg_match("/\.pdf$/", $destino)) { $fileName = basename($finalfile); $pdfFile = file_get_contents($destino); $dataLength = strlen($pdfFile); #$query2 = "INSERT INTO testing14 (message, message2) VALUES ('$destino', '$dataLength')"; #$result2 = mysql_queryFF($query2); header('Content-Description: File Transfer'); header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename="'.$fileName.'"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: '.$dataLength); print $pdfFile; exit; } } else { header("HTTP/1.1 301 Moved Permanently"); header("Location: $destino"); exit; } } else {//If not on media either... 404! header("HTTP/1.1 301 Moved Permanently"); header("Location: /404.html"); exit; } } #Estrae nome file... $pezzi = array(); $pezzi = explode("/", $finalfile); if ($name) { $filename = $name; } else { $filename = $pezzi[sizeof($pezzi)-1]; } #Sostituisce spazi con underscores per file name (rev. 8-25-09)... $filename = str_replace(" ", "_", $filename); #Estrae extension... list($null, $extension) = explode(".", $filename); $lunghezza = "Content-Length: ".filesize($finalfile); #print "ecco: $extension - $filename"; #exit; #Ora definisce il MIME type... if ($extension == "mp3") { #Se mp3... $MIMEtype = 'audio/mpeg'; } elseif ($extension == "mid") { #Se MIDI... $MIMEtype= 'audio/x-midi'; } elseif ($extension == "wav") { #Se wav... $MIMEtype= 'audio/x-wav'; } elseif ($extension == "aiff" or $extension == "aif") { #Se aiff... $MIMEtype= 'audio/x-aiff'; } elseif ($extension == "mov") { #Se aiff... $MIMEtype= 'video/quicktime'; } elseif ($extension == "mov") { #Se wma... $MIMEtype= 'audio/x-ms-wma'; } elseif ($extension == "gif") { #Se gif... $MIMEtype = 'image/gif'; } elseif ($extension == "jpg" or $extension == "jpeg") { #Se jpg... $MIMEtype= 'image/jpeg'; } elseif ($extension == "png") { #Se png... $MIMEtype= 'image/png'; } elseif ($extension == "sib") { #Se Sibelius... $MIMEtype= 'application/x-sibelius-score'; } elseif ($extension == "pdf") { #Se PDF... $MIMEtype= 'application/pdf'; } elseif ($extension == "xml") { #Se XML... $MIMEtype= 'application/xml'; } elseif ($extension == "mus") { #Se Finale... $MIMEtype= 'application/x-finale-score'; } else { #Altro... $MIMEtype= 'application/octet-stream '; } if ($force) { $contentdisposition = 'Content-disposition: attachment; filename='.$filename; } $contenttype = 'Content-type: '.$MIMEtype; header('Accept-Ranges: bytes'); header($lunghezza); header($contenttype); header($contentdisposition); readfile($finalfile); } #Funzione per validare l' indirizzo e-mail (shared) function SHAREDis_email_valid($email) { if (eregiFF ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}$", $email)) { return FALSE; } else { return TRUE; } } #Like above but with DNS checking 7/8/24, 7:37 AM... function SHAREDis_email_valid_DNS($email) { list($userName, $mailDomain) = explode("@", $email); if (eregiFF("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}$", $email) and checkdnsrr($mailDomain, "MX")) { return false; } else { return true; } } #Funzione per ritornare red style per errors in input fields... function fielderror($flag, $extraclass = "") { if ($flag) { $ritorno = ' style="border:2px solid red" class="focus'; if ($extraclass) { $ritorno .= ' '.$extraclass; } $ritorno .= '"'; return $ritorno; } else { return ''; } } #Funzione per accettare solo lettere e numbers (per passwords...) function lnonly($string) { $eregi = eregi_replaceFF("([A-Z0-9]+)","",$string); if(empty($eregi)){ return true; } return false; } #Funzione per simulare getcompressed cookies del Perl... function GetCompressedCookies($inputvar, $inputcookie) { $parts = array(); $parts = explode ("&", $inputcookie); foreach ($parts as $single) { list ($var, $value) = explode ("::", $single); if ($var == $inputvar) { return $value; } } return 0; } #Funzione pser simulare SetCompressedCookies cookies del Perl... #Definisce fino a 10 cookies... function SetCompressedCookies($expiration, $name, $par1, $val1, $par2, $val2, $par3 = '', $val3 = '', $par4 = '', $val4 = '', $par5 = '', $val5 = '', $par6 = '', $val6 = '', $par7 = '', $val7 = '', $par8 = '', $val8 = '', $par9 = '', $val9 = '', $par10 = '', $val10 = '') { for ($i = 1; $i <=10; $i ++) { $varvarpar = "par".$i; $varvarval = "val".$i; if ($$varvarpar) { $cookiehere = $$varvarpar."::".$$varvarval; $totcookie .= $cookiehere."&"; } } #Toglie & finale... $totcookie = ereg_replaceFF("\&$", "", $totcookie); #print "ecco: $name - $totcookie"; setcookie ($name,$totcookie, $expiration, "/"); } ////// FUNZIONI IPHONE (spostate qui da functions.inc dentro iPhone folder on 10-15-09)... function aggiustaurl($url, $relativeurl = 0) { global $SSLprot; if ($relativeurl) { $url = "/".$url; } else { $url = $SSLprot."://www.virtualsheetmusic.com/".$url; } return $url; } function cleanffstring($title) { #This below removed on 9-13-2012 becaused caused problems with iPhoneiPad feeds! //$title = HTMLcardecode($title);#Added 8-17-2012... $title = str_replace("|","",$title); $title = str_replace("124;","",$title); $title = str_replace(""","'",$title); $title = str_replace("&","and",$title); $title = str_replace(""","'",$title); $title = str_replace("'","'",$title); $title = str_replace("ä","a",$title); $title = str_replace("ò","o",$title); $title = str_replace("ë","e",$title); $title = str_replace("é","e",$title); $title = str_replace("è","e",$title); $title = str_replace("ê","e",$title); $title = str_replace("Ò","'",$title); $title = str_replace("Ó","'",$title); $title = str_replace("&","and",$title); return $title; } function cleanmembername($nome) { $nome = str_replace("|", "", $nome); $nome = str_replace("\"", "", $nome); $nome = str_replace("'", "", $nome); $nome = str_replace("&", "", $nome); $nome = str_replace(chr(43), " ", $nome); return $nome; } function cleanforrss($text) { $text = philsXMLClean($text); return $text; } function addlimit($query) { global $limit; if ($limit) { $query .= " LIMIT $limit"; } return $query; } #Funzione per pulire inputs in maniera definitiva (6-18-08)... function sanitizeSHARED($input, $nopar = 0) { $input = HTMLcardecode($input); $input = cleaninputs($input, 0, $nopar); $input = HTMLcar($input); return $input; } function sanitizeSHAREDURL($input, $rmquotes = 0) { $input = urldecode($input); $input = cleaninputs($input, $rmquotes); $input = htmlspecialchars($input); //Now re-converts & into &... $input = str_replace("&", "&", $input); return $input; } function HTMLcardecode($string) { #Fa anche conversione HTML special characters reverse... $string = html_entity_decode($string, ENT_QUOTES); $string = stripslashes($string); return $string; } function cleaninputsbasic($input) { $input = preg_replace("/<\?(PHP)?.+\?\>/i", "", $input); $input = preg_replace("/<(\/)?SCRIPT( .)*>/i", "", $input); $input = preg_replace("/<(\/)?IFRAME( .)*>/i", "", $input); #Extra security from Trustkeeper test 1-27-2012... $input = preg_replace("/<( *|\/)SCRIPT( *)>/i", "", $input); $input = str_replace("alert(", "", $input); return $input; } #Funzione per pulire campi di inputs utente (sicurezza)... function cleaninputs($input, $rmquotes = 0, $nopar = 0) { $input = cleaninputsbasic($input); #Removes ;... #Remove parenthesis... if (!$nopar) {//Used by commenting system to keep emjoys... $input = str_replace(";", "", $input); $input = str_replace("(", "", $input); $input = str_replace(")", "", $input); } #Removes quotes if requested... if ($rmquotes) { $input = preg_replace("/\"/i", "", $input); } #Remove strange quotes associations... $input = str_replace("\"'", "", $input); $input = str_replace("'\"", "", $input); #MySQL injection cleaning... /* $input = preg_replace("/ISNULL/i", "", $input); $input = preg_replace("/SUBSTRING/i", "", $input); $input = preg_replace("/CONCAT/i", "", $input); $input = preg_replace("/SELECT\ /i", "", $input); $input = preg_replace("/CHAR\(/i", "", $input); $input = preg_replace("/NSFTW/i", "", $input); $input = preg_replace("/DELETE\ /i", "", $input); $input = preg_replace("/union all/i", "", $input); $input = preg_replace("/javascript:/i", "", $input); */ // $input = str_ireplace("ISNULL", "", $input); // $input = str_ireplace("DECLARE", "", $input); // $input = str_ireplace("SUBSTRING", "", $input); // $input = str_ireplace("CONCAT", "", $input); // $input = str_ireplace("SELECT ", "", $input); // $input = str_ireplace(" CHAR ", "", $input); // $input = str_ireplace("NSFTW", "", $input); // $input = str_ireplace("DELETE ", "", $input); // $input = str_ireplace("union all", "", $input); // // // $input = str_ireplace(" elt ", "", $input); // $input = str_ireplace("pg_sleep", "", $input); // $input = str_ireplace("waitfor delay", "", $input); // $input = str_ireplace("from count ", "", $input); $input = cleanSQLonly($input); $input = str_ireplace("javascript:", "", $input); /* //This below removed 9-24-2014 because caused problems with ajax comments and //other stuff! Find a different way to tackle this, more focused on the problem! #For header attacks... $crhere = chr(13); $lnhere = chr(10); $patternhere = $crhere.$lnhere; $input = preg_replace("/".$patternhere."/i", "", $input); */ #This below removed because some users have the word "script" in their email!! //$input = preg_replace("/SCRIPT/i", "", $input); $input = preg_replace("/IFRAME/i", "", $input); $input = stripslashes($input); $input = trim($input); return $input; } function cleanSQLonly($input) { $input = str_ireplace("ISNULL", "", $input); $input = str_ireplace("DECLARE", "", $input); $input = str_ireplace("SUBSTRING", "", $input); $input = str_ireplace("CONCAT", "", $input); $input = str_ireplace("SELECT ", "", $input); $input = str_ireplace(" CHAR ", "", $input); $input = str_ireplace("NSFTW", "", $input); $input = str_ireplace("DELETE ", "", $input); $input = str_ireplace("union all", "", $input); $input = str_ireplace(" elt ", "", $input); $input = str_ireplace("pg_sleep", "", $input); $input = str_ireplace("waitfor delay", "", $input); $input = str_ireplace("from count ", "", $input); return $input; } #Function to prevent SQLinjection 3-25-2016... function nosqlinj($input, $rmallquotes = 0, $nospaces = 0) { if ($rmsquotes) { $input = str_replace("'", "", $input); $input = str_replace('"', "", $input); } if ($nospaces) { $input = str_replace(" ", "", $input); } $input = cleaninputs($input); return $input; } #Function to sanitize vars that should accept just numeric variables... function sanitizeNUMERIC($input) { if (is_numeric($input)) { return $input; } else { return ''; } } function HTMLcar($string) { $string = str_replace("\\","",$string); #Fa anche conversione HTML special characters... $string = htmlentities($string, ENT_QUOTES); return $string; } function pulisceaudiofile($audiofilehere) { $audiofilehere = str_replace("%25", "%", $audiofilehere); #Converte & (@) e % (@@)... $audiofilehere = str_replace("&", "@", $audiofilehere); $audiofilehere = str_replace("%", "@@", $audiofilehere); return $audiofilehere; } #Funzione per pulire audio file names... function cleanaudiofilename($name, $rmext = 0) { #$name e' il nome del file (es. 01Adagio_sostenuto.mid) #Toglie l' estensione ".mid" o altre... if ($rmext) { list ($name, $null) = explode (".", $name); } $name = fileconversions($name); #Toglie numero iniziale... $name = substr($name,2,strlen($name)-2); return $name; } function fileconversions($name) { $name = ereg_replaceFF ("_", " ", $name); # Converte "=" in ":" $name = ereg_replaceFF ("=", ":", $name); # Converte "!" in "." $name = ereg_replaceFF ("!", ".", $name); # Converte ">u" in "ù" $name = ereg_replaceFF ("ù", "ù", $name); $name = ereg_replaceFF (">u", "ù", $name); #Converte &23 in # $name = ereg_replaceFF ('&23', '#', $name); #Converte &27 in ' $name = ereg_replaceFF ('&27', '\'', $name); $name = str_replace('--27', "'",$name); $name = str_replace('--3F', "?",$name); #Converte &22 in " $name = ereg_replaceFF ('&22', '"', $name); #Converte &35 in # $name = ereg_replaceFF ('&35', '#', $name); #Converte ´ in a' $name = ereg_replaceFF ('´', '´', $name); #Converte é in � $name = ereg_replaceFF ('é', 'é', $name); #Converte &grave in � $name = ereg_replaceFF ('&grave', '`', $name); #Converte è in � $name = ereg_replaceFF ('è', 'è', $name); #Converte à in � $name = ereg_replaceFF ('à', 'à', $name); if (!(eregFF("à",$name)) and !(eregFF("´",$name))) { # Converte "&a" in "ä" (a con dieresi) $name = ereg_replaceFF ("&a", "ä", $name); } return $name; } #Funzione per tagliare frasi piu' lunghe di un certo numero (non tronca le parole!!) function cutText($string, $length) { if($length'.$text.''; } //Function for correct return panel for team members (such as customer service)... function writemenureturn() { global $teamlogged; if ($teamlogged) { $url = '/team/'; } else { $url = '/cgi-bin/topo.pl'; } print '**RETURN TO MAIN MENU**'; } function useragent() { global $_SERVER; $useragent = $_SERVER['HTTP_USER_AGENT']; //print $useragent; if(strchr($useragent,"Edge")) return 'Edge'; if(strchr($useragent,"MSIE 10.0")) return 'IE 10'; if(strchr($useragent,"MSIE 9.0")) return 'IE 9'; if(strchr($useragent,"MSIE 8.0")) return 'IE 8'; if(strchr($useragent,"MSIE 7.")) return 'IE 7'; if(strchr($useragent,"Firefox/3.0")) return 'FIREFOX 3'; if(strchr($useragent,"Firefox/2.0")) return 'FIREFOX 2'; if(strchr($useragent,"Firefox/1.0")) return 'FIREFOX 1'; if(strchr($useragent,"MSIE 6.")) return 'IE 6'; if(strchr($useragent,"MSIE 5")) return 'IE 5'; if(strchr($useragent,"MSIE 4")) return 'IE 4'; if(strchr($useragent,"MSIE 3")) return 'IE 3'; if(strchr($useragent,"Opera")) return 'Opera'; if(strchr($useragent,"iPad")) return 'iPad'; if(strchr($useragent,"iPhone")) return 'iPhone'; if(strchr($useragent,"iPod")) return 'iPhone'; if(strchr($useragent,"Android")) return 'Android'; if(strchr($useragent,"Chrome")) return 'Chrome'; if(strchr($useragent,"Safari")) return 'Safari'; if(strchr($useragent,"CometBird")) return 'CometBird'; if(strchr($useragent,"Firefox")) return 'Firefox'; if(strchr($useragent,"Trident")) return 'IE'; } function ismobile() { global $_SERVER; $useragent = $_SERVER['HTTP_USER_AGENT']; if(strchr($useragent,"iPad")) return '1'; if(strchr($useragent,"iPhone")) return '1'; if(strchr($useragent,"iPod")) return '1'; if(strchr($useragent,"Android")) return '1'; if(strchr($useragent,"mobile")) return '1'; return 0; } function ison_iOS() { if (useragent() == "iPhone" or useragent() == "iPad" or useragent() == "iPod") { return 1; } else { return 0; } } function useragentname() { global $_SERVER; $useragent = $_SERVER['HTTP_USER_AGENT']; //print $useragent; if(strchr($useragent,"MSIE")) return 'Internet Explorer'; if(strchr($useragent,"Opera")) return 'Opera'; if(strchr($useragent,"iPad")) return 'iPad'; if(strchr($useragent,"iPhone")) return 'iPhone'; if (preg_match("/Win/i", $useragent)) { if(strchr($useragent,"Chrome")) return 'this browser';//Now includes Opera also! } else { if(strchr($useragent,"Chrome")) return 'your browser';//Now includes Opera also! } if(strchr($useragent,"Safari")) return 'Safari'; if(strchr($useragent,"CometBird")) return 'CometBird'; if(strchr($useragent,"Firefox")) return 'Firefox'; return "this browser"; } function get_include_contents($filename) { if (is_file($filename)) { ob_start(); include $filename; $contents = ob_get_contents(); ob_end_clean(); return $contents; } return false; } #Function to clean a name for files (used by new product page system)... function cleanfilename($title) { $title = str_replace('"',"",$title); $title = str_replace(',',"",$title); $title = str_replace('"',"",$title); $title = ereg_replaceFF("\|","",$title); $title = ereg_replaceFF("\ ","_",$title); $title = ereg_replaceFF("\.","",$title); $title = ereg_replaceFF("\(","",$title); $title = ereg_replaceFF("\)","",$title); $title = ereg_replaceFF("\:","",$title); $title = ereg_replaceFF("\'","",$title); $title = ereg_replaceFF("\/","",$title); $title = ereg_replaceFF("\ ","",$title); $title = ereg_replaceFF(""","",$title); $title = ereg_replaceFF("ä","",$title); $title = ereg_replaceFF("è","",$title); $title = ereg_replaceFF("ò","",$title); $title = ereg_replaceFF("é","",$title); $title = ereg_replaceFF("ì","",$title); $title = ereg_replaceFF("ù","",$title); $title = ereg_replaceFF("à","",$title); $title = ereg_replaceFF("ê","",$title); $title = ereg_replaceFF("'","",$title); return $title; } #Function to grab Mp3accos files for a specific ID and composerID... function grabMp3accos($idMp3, $name_composer, $subdirs) { global $GLOBbasedir; //NOTE: variable $name_composer is no longer used here sinde we don't read //from file systme since 9-12-2018... //Defines vars... $Mp3Mp3acco = array(); $Mp3Mp3accoTMP = array(); $queryACCO = "SELECT subdir, acco FROM scores_accos WHERE itemid = '".$idMp3."'"; $resultACCO = mysql_queryFF($queryACCO); $nitemsACCO = mysql_num_rowsFF($resultACCO); $chksbdARR = array(); $lastsubdir = ''; if ($nitemsACCO) { //Emulates file system first 2 empty files... $Mp3Mp3acco[0]['sortname'] = ''; $Mp3Mp3acco[0]['file'] = ''; $Mp3Mp3acco[1]['sortname'] = ''; $Mp3Mp3acco[1]['file'] = ''; if ($subdirs == 1) { $ccac = 0; $ccacsd = 0;//Emulates file system first 2 empty files... } else { $ccac = 2;//Emulates file system first 2 empty files... $ccacsd = 2;//Emulates file system first 2 empty files... } while ($rowACCO = mysql_fetch_arrayFF($resultACCO)) { #Since PHP 'sort' has problems with strings of different length #We must use this awkward system... if ($rowACCO["subdir"]) {//If subdirs... if (!$chksbdARR[$rowACCO["subdir"]]) { $chksbdARR[$rowACCO["subdir"]] = 1; if ($ccacsd) { sort($Mp3Mp3accoTMP[$lastsubdir]); } $Mp3Mp3acco[$ccacsd+2]['sortname'] = strtolower(preg_replace("/_/", "", $rowACCO["subdir"])); $Mp3Mp3acco[$ccacsd+2]['file'] = $rowACCO["subdir"]; $ccacsd ++; } $Mp3Mp3accoTMP[$rowACCO["subdir"]][$ccac]['sortname'] = strtolower(preg_replace("/_/", "", $rowACCO["acco"])); $Mp3Mp3accoTMP[$rowACCO["subdir"]][$ccac]['file'] = $rowACCO["acco"]; $Mp3Mp3accoIDs[$ccac] = $idMp3; #Takes ID of this file... $lastsubdir = $rowACCO["subdir"]; } else { $Mp3Mp3acco[$ccac]['sortname'] = strtolower(preg_replace("/_/", "", $rowACCO["acco"])); $Mp3Mp3acco[$ccac]['file'] = $rowACCO["acco"]; } //print "ecco: ".$rowACCO["acco"]."\n"; $ccac ++; } } /* $dir_Mp3acco = "/home/webadmin/virtualsheetmusic.com/html/Mp3acco/".$name_composer."/".$idMp3."/"; $dh = opendir("$dir_Mp3acco"); #print "Eccoci!"; $ccac = 0; while ($file = readdir($dh)) { $file_array = explode(".",$file); #Since PHP 'sort' has problems with strings of different length #We must use this awkward system... $Mp3Mp3acco[$ccac]['sortname'] = strtolower(preg_replace("/_/", "", $file_array[0])); $Mp3Mp3acco[$ccac]['file'] = $file_array[0]; //print "ecco: ".$file_array[0]."\n"; $ccac ++; } closedir($dh); */ if (sizeof($Mp3Mp3acco)) { sort($Mp3Mp3acco); //print_r($Mp3Mp3acco); if ($subdirs == 1) { #Subdirs... sort($Mp3Mp3accoTMP[$lastsubdir]); /* $ccmp3accos = 0; foreach ($Mp3Mp3acco as $single) { $swt = 0; foreach ($single as $subdiracco) { if (strlen($subdiracco) > 2 and $swt) { #print "dentro: $subdiracco
"; $ccac = 0; #Process subdirs... $dir_Mp3ACCOsub = $GLOBbasedir."/Mp3acco/$name_composer/$idMp3/$subdiracco/"; #print "sooo2: $dir_Mp3ACCOsub"; $dh = opendir("$dir_Mp3ACCOsub"); while ($file = readdir($dh)) { if (strlen($file) > 2) { $file_array = explode(".",$file); #print "eccoci: $subdiracco - $file
"; $Mp3Mp3accoTMP[$subdiracco][$ccac]['sortname'] = strtolower(preg_replace("/_/", "", $file_array[0])); $Mp3Mp3accoTMP[$subdiracco][$ccac]['file'] = $file_array[0]; $Mp3Mp3accoIDs[$ccmp3accos] = $idMp3; #Takes ID of this file... $ccac ++; $ccmp3accos ++; } } closedir($dh); if (sizeof($Mp3Mp3accoTMP)) { sort($Mp3Mp3accoTMP[$subdiracco]); } } $swt ++; } } */ } elseif ($subdirs == 2) { #Regular offers... $ccmp3accos = 0; foreach ($Mp3Mp3acco as $single) { $swt = 0; $ccac = 0; foreach ($single as $file) { if (strlen($file) > 2 and $swt) { #print "dentro: $file
"; $Mp3Mp3accoTMP[$subdiracco][$ccac]['sortname'] = strtolower(preg_replace("/_/", "", $file)); $Mp3Mp3accoTMP[$subdiracco][$ccac]['file'] = $file; $Mp3Mp3accoIDs[$ccmp3accos] = $idMp3; #Takes ID of this file... $ccac ++; $ccmp3accos ++; } $swt ++; } if (sizeof($Mp3Mp3accoTMP)) { sort($Mp3Mp3accoTMP[$subdiracco]); } } } } return array($Mp3Mp3acco, $Mp3Mp3accoTMP, $Mp3Mp3accoIDs); } #Functions to convert URL in order to pass them inside URL vars... function encodeurl($url) { $url = str_replace("=", "@@@", $url); $url = str_replace("&", "___", $url); $url = str_replace("?", "---", $url); return $url; } function decodeurl($url) { $url = str_replace("@@@", "=", $url); $url = str_replace("___", "&", $url); $url = str_replace("---", "?", $url); return $url; } function makesitemurl($productidNEWPP) { if ($productidNEWPP) { $URLNEWPP = checkexs($productidNEWPP)."/".$productidNEWPP.".html"; $URLNEWPP = aggiustaurl($URLNEWPP); return $URLNEWPP; } else { return NULL; } } function fixspaces($text) { $text = str_replace(" ", "_", $text); return $text; } function settitlehereSEO($title, $faketitle) { global $newcat6; if ($title == "Sonata Op.27 No.2") { $titlehereSEO = "Moonlight ".$title; } else { //Here we make sure the $title doens't include the $faketitle already ! 9/7/21, 10:40 AM... $faketitleHere = str_replace(", ", "", $faketitle); if (stripos($title, $faketitleHere) !== false) { $titlehereSEO = $title; } else { $titlehereSEO = $title.$faketitle; } } return $titlehereSEO; } function cleanyoutubeid($youtubeid) { $youtubeid = eregi_replaceFF("(^.+\?v=)(.+)(&.+$)", "\\2", $youtubeid); $youtubeid = eregi_replaceFF("(^.+\?v=)(.+)", "\\2", $youtubeid); $youtubeid = str_replace("https://youtu.be/", "", $youtubeid); $youtubeid = str_replace("http://youtu.be/", "", $youtubeid); $youtubeid = preg_replace("/youtu.be\//", "", $youtubeid); $youtubeid = trim($youtubeid); return $youtubeid; } function parseyoutubeapi($youtubeURL, $programcalled = 0) { global $YTcurrent, $YTtitle, $YTdescription, $YTdonedescription, $YTauthor, $YTduration, $YTminuti, $YTsecondi, $basedir, $MEMBERid, $newcat6, $is_robot, $s_id; #Interpreta input, se singolo code o URL completo... /* if (eregiFF ("youtube.com", $youtubeURL)) { #Se URL completo... $youtubeURL = eregi_replaceFF("^.+\?v=", "", $youtubeURL); $youtubeURL = trim($youtubeURL); } */ $youtubeURL = cleanyoutubeid($youtubeURL); //Since 3/4/21, 8:41 AM we check $s_id and !$is_robot if not called by the backend... if ($programcalled or ($s_id and !$is_robot)) { /* ///This is old system dismissed on 5-14-2015 because we need to use new API... $filename = 'http://gdata.youtube.com/feeds/api/videos/'.$youtubeURL; if (! ($xmlparser = xml_parser_create()) ) { die ("Cannot create parser"); } xml_set_element_handler($xmlparser, "start_tag", "end_tag"); xml_set_character_data_handler($xmlparser, "tag_contents"); ///start parse... if (!($fp = fopen($filename, "r"))) { $error = 1; } while ($data = fread($fp, 4096)){ $data=eregi_replaceFF(">"."[[:space:]]+"."<","><",$data); $data = str_replace("\n", " - ", $data); if (!xml_parse($xmlparser, $data, feof($fp))) { $reason = xml_error_string(xml_get_error_code($xmlparser)); $reason .= xml_get_current_line_number($xmlparser); //die($reason); $error = 1; } } xml_parser_free($xmlparser); */ ///New API since 5-14-2015, it uses this key: AIzaSyCOUEvj2baGBZD2vg5VU5qqliFqlztZRBE ///Which is the one for the YouTube VSM API application created inside the Google ///Developer Console: https://console.developers.google.com //https://www.googleapis.com/youtube/v3/videos?id=dEK6s9i1_5g&key=AIzaSyCOUEvj2baGBZD2vg5VU5qqliFqlztZRBE&part=snippet,contentDetails,statistics,status $url = "https://www.googleapis.com/youtube/v3/videos?id=".$youtubeURL."&key=AIzaSyCOUEvj2baGBZD2vg5VU5qqliFqlztZRBE&part=snippet,contentDetails,statistics,status"; $output = file_get_contents($url); //If quota reached, tries with the other APIs 3/5/21, 8:47 AM... if (strpos($output, "quotaExceeded") !== false) { $url = "https://www.googleapis.com/youtube/v3/videos?id=".$youtubeURL."&key=AIzaSyBvhgX3ouMqzi9gTw86K_DuSiKIPOZCqAc&part=snippet,contentDetails,statistics,status"; $output = file_get_contents($url); if (strpos($output, "quotaExceeded") !== false) { $url = "https://www.googleapis.com/youtube/v3/videos?id=".$youtubeURL."&key=wF15VeDXXK3Ov9NvXK8h96EmeV02cKI&part=snippet,contentDetails,statistics,status"; $output = file_get_contents($url); } } if ($output and $output !== false) { $jsonobj = json_decode($output); if ($jsonobj->items[0]->snippet->title) { #Se ok, procede con il resto... //Stores data... $YTtitle = $jsonobj->items[0]->snippet->title; $YTdescription = $jsonobj->items[0]->snippet->description; $YTauthor = $jsonobj->items[0]->snippet->channelTitle; $YTduration = $jsonobj->items[0]->contentDetails->duration; //Work duration... $YTduration = str_replace("PT", "", $YTduration); //If includes H... if (strpos($YTduration, "H") !== false) { list ($YThour, $restchunck) = explode("H", $YTduration); list ($YTminuti, $YTsecondi) = explode("M", $restchunck); $YTsecondi = str_replace("S", "", $YTsecondi); } else {//Just minutes and seconds... list ($YTminuti, $YTsecondi) = explode("M", $YTduration); $YTsecondi = str_replace("S", "", $YTsecondi); } return TRUE; } else { //If it is called serverside (backend), we return true if the quota limit is exceeded... if ($programcalled) { if (strpos($output, "quotaExceeded") !== false) { return TRUE; } else { return FALSE; } } else { return FALSE; } } } else { return FALSE; } } else { return FALSE; } } #Funzione per calcolare tempo passato (usato da home page, forums. etc) function tempofrase($tempoTR) { #Controlla subito se il tempo passato continee una pipe per definizione alternativa #stampaggio tempo (rev. 4-17-09)... list ($tempoTR, $alternative, $ondate) = explode("|", $tempoTR); #Controlla se e' meno di 48 ore, in tal caso #da una indicazione tipo "3 ore fa", "yesterday at 3:40", etc... global $globaltempo; $tempodiff = $globaltempo-$tempoTR; ##Ora calcola se questa data e' oggi (1), ieri (2) o piu' di 48 ore (3)... #Prende giorno di oggi... $giornooggi = zonedate("j", $globaltempo); $meseoggi = zonedate("n", $globaltempo); $annooggi = zonedate("Y", $globaltempo); $giornoelement = zonedate("j", $tempoTR); $meseelement = zonedate("n", $tempoTR); $annoelement = zonedate("Y", $tempoTR); if ($giornooggi == $giornoelement and $meseoggi == $meseelement and $annooggi == $annoelement) { #Oggi... $posizione = 1; } elseif ($giornoelement == $giornooggi-1 and $meseoggi == $meseelement and $annooggi == $annoelement) { #Ieri... $posizione = 2; } else { #Ogni altra data... $posizione = 3; } if ($posizione < 3) { #Se meno di 48 ore... #Controlla se meno di 3 ore... if ($tempodiff < 5400) { #se meno di 90 minuti... $minutipassati = round($tempodiff/60); if ($minutipassati == 0) { $workdateTR = $tempodiff." seconds"; } else { $workdateTR = $minutipassati." minute"; } if ($minutipassati > 1) { $workdateTR .= "s"; } $workdateTR .= " ago"; } elseif ($tempodiff < 10800) { #se meno di 3 ore... $workhourTR = round($tempodiff/3600); $workdateTR = $workhourTR." hour"; if ($workhourTR > 1) { $workdateTR .= "s"; } $workdateTR .= " ago"; } elseif ($posizione == 1) { #se oggi... $workdateTR = "today @ ".zonedate("g:ia", $tempoTR); } else { #Se ieri... $workdateTR = "yesterday @ ".zonedate("g:ia", $tempoTR); } } else { #Se piu' di 48 ore... if ($alternative) { $workdateTR = zonedate($alternative, $tempoTR); if ($ondate) { $workdateTR = "on ".$workdateTR; } } else { $workdateTR = zonedate("M j, Y", $tempoTR); } } #Last check 'now'... if ($workdateTR == "0 seconds ago") { $workdateTR = "now"; } return $workdateTR; } #Funzione per il time zone... (3-14-08) function zonedate($layout, $time) { global $MEMBERtimezone, $MEMBERdaylight; $countryzone = $MEMBERtimezone; $daylightsaving = $MEMBERdaylight; if (!$countryzone) { $countryzone = 0; #Default, GMT } if (!$daylightsaving) { $daylightsaving = 'auto'; } if($daylightsaving == "auto") { $daylight_saving = date('I'); if ($daylight_saving) { $zone=3600*($countryzone+1); } else { $zone=3600*($countryzone); } } elseif($daylightsaving == "on") { $zone=3600*($countryzone+1); } elseif($daylightsaving == "off") { $zone=3600*($countryzone); } if(!$time) { $time = time(); } $date = gmdate($layout, $time + $zone); return $date; } #Function to clean title at the minimum removing (New Edition) and other standard stuff... #THis is used by YouTube video tab... function minimumtitle($text) { $text = ereg_replaceFF("\(.+\)", "", $text); $text = trim($text); return $text; } function prende_nomeSHARED($composer) { global $scores_dev, $composerarrayindexrev, $GLOBComposertable; $full_composeroring = $composer; $composerSQLH = escapeMySQL($composer); $queryHERE = "SELECT ID FROM $GLOBComposertable WHERE name = '$composerSQLH'"; #$queryHERErr = mysql_real_escape_stringFF($queryHERE); #$queryQW = "INSERT INTO testing2 (message, tempo) VALUES ('$queryHERErr', 1)"; #$resultQW = mysql_queryFF($queryQW); $resultHERE = mysql_queryFF($queryHERE); $nitemsHERE = mysql_num_rowsFF($resultHERE); if ($nitemsHERE) { $name_composer = mysql_resultFF($resultHERE, 0, 'ID'); } #Sicurezza: se il $full_composer e' vuoto, lo riempie con l' input originale... if (!$name_composer) { $name_composer = $full_composeroring; } return $name_composer; } #Funzione per cancellare directory e suo contenuto... function rmdir_r ( $dir, $DeleteMe = TRUE ) { if ( ! $dh = @opendir ( $dir ) ) return; while ( false !== ( $obj = readdir ( $dh ) ) ) { if ( $obj == '.' || $obj == '..') continue; if ( ! @unlink ( $dir . '/' . $obj ) ) rmdir_r ( $dir . '/' . $obj, true ); } closedir ( $dh ); if ( $DeleteMe ) { @rmdir ( $dir ); } } ###Crypt-Dcrypt functions.. function encrypt($text, $salt) { //This below doesn\'t work anymore on PHP 7! //return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)))); return EncryptDecrypt($text, true, $salt); } function decrypt($text, $salt) { //This below doesn\'t work anymore on PHP 7! //return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))); return EncryptDecrypt($text, false, $salt); } // function EncryptDecrypt($oldText, $encryptIt=true, $password="topo", $encryptType=""){ // $ciphers = openssl_get_cipher_methods(); // $foundEncType = false; // for($pointer=0; $pointer $tenminutesago $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { $goinsert = 0; } else { //Checks also if ticket is already there made by another user (!!!) //that may happen! (added 5-19-2017)... $query = "SELECT uid FROM member_logs WHERE action = 3 AND ticket = '$ticket' AND id != $VSMUSERid"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { $goinsert = 0; } else { $goinsert = 1; } } } else { //Since 3/21/22, 11:10 we also don't duplicate file downloads... if ($action == 2) { //Define today's time-frame so that we record the same item if it is downloaded on a different day... $startTempo = strtotime("today"); $endTempo = strtotime("tomorrow"); $query = "SELECT uid FROM member_logs WHERE id = $VSMUSERid AND action = 2 AND product_id = '$product_id' AND file = '$file' AND tempo >= $startTempo AND tempo < $endTempo"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { $goinsert = 0; } else { $goinsert = 1; } } else { $goinsert = 1; } } if ($goinsert) { $queryLOG = "INSERT INTO member_logs (id, action, cart_id, ticket, product_id, file, media, tempo) VALUES ($VSMUSERid, $action, '$cart_id', '$ticket', '$product_id', '$file', '$media', $globaltempo)"; $resultLOG = mysql_queryFF($queryLOG); } //Stores info into PROFILE_2 if it is a single item download (4-22-2014)... if ($s_id and $product_id) { work_realtime_profile($s_id, $product_id, 'downloads'); } } } #Function to make a string completely XML safe... function philsXMLClean($strin) { $strout = null; for ($i = 0; $i < strlen($strin); $i++) { $ord = ord($strin[$i]); if (($ord > 0 && $ord < 32) || ($ord >= 127)) { $strout .= "&#{$ord};"; } else { switch ($strin[$i]) { case '<': $strout .= '<'; break; case '>': $strout .= '>'; break; case '&': $strout .= '&'; break; case '"': $strout .= '"'; break; case "'": $strout .= '''; break; default: $strout .= $strin[$i]; } } } return $strout; } function displayrequest($type) { print '
'; offerrequest($type); print '
'; } function offerrequest($type, $forceid = '') { global $offerrequestflag, $id, $requestdone, $cleanURL, $GLOBcleanSCRIPT, $product_type_id, $interactiveicon; if ($type == "scorch" and $interactiveicon) { $type = "interactive"; } $origforceid = $forceid; if (!$forceid) { $forceid = $id; } if ($requestdone == $forceid) { print '
Thank you! We will consider to publish the '.ucfirst($type).' version of this item.
'; } else { if ($product_type_id == 1) {#If Physical item... print '
This physical item doesn\'t include '.ucfirst($type).' files to enjoy online.

Return to the Info Tab
'; } else { print '
We are sorry, but '.ucfirst($type).' files for '; if ($origforceid) { #print "eoo: $origforceid - $forceid"; print return_id_title($forceid); } else { print 'this item'; } print ' are not available yet.

'; if ($type == 'scorch' or $type == 'interactive') { print ucfirst($type)." files allow you to transpose and change instruments on a score directly inside your browser,
which you can then print copies of.

This feature also allows you to play a score's music by following it on the screen.

"; } elseif ($type == 'mp3') { print "Mp3 files allow you to play and listen to music related to this item.

"; } elseif ($type == 'MIDI') { print "MIDI files allow you to play and listen to music related to this item and also to create your own music with special dedicated programs.

"; } print 'Would you like request '.ucfirst($type).' files for '; if ($origforceid) { print return_id_title($forceid); } else { print 'this item'; } print '?
'; } } $offerrequestflag = 1; } function enablehtmlgzip() { if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); } function calcsaving($full, $reduced) { if (!$full) { return 0; } else { return round(100-((round($reduced, 1)*100)/round($full,1))); } } #Function to return new Membership offers (11-11-2010)... function returnmo($totaleCART) { global $MEMBERSHIP_PRICEorig, $discount24; $membershipdiff = $MEMBERSHIP_PRICEorig-$totaleCART; $membershipsaving = round(($totaleCART*100)/$MEMBERSHIP_PRICEorig); $membershipsaving24 = $membershipsaving+$discount24; $membershipdiff24 = $MEMBERSHIP_PRICEorig-(($membershipsaving24*$MEMBERSHIP_PRICEorig)/100); #If total cart is over 66% of the full price, just flat offer... if ($totaleCART > (($MEMBERSHIP_PRICEorig*66)/100)) { $membershipdiff24 = $membershipdiff; $no24offer = 1; $membershipsaving24 = $membershipsaving; } #If instead the total cart is too low, we give them a minimum discount of 15% elseif ($totaleCART < (($MEMBERSHIP_PRICEorig*15)/100)) { $membershipdiff = $MEMBERSHIP_PRICEorig-(($MEMBERSHIP_PRICEorig*15)/100); $membershipsaving = 15; $membershipsaving24 = $membershipsaving+$discount24; $membershipdiff24 = $MEMBERSHIP_PRICEorig-(($membershipsaving24*$MEMBERSHIP_PRICEorig)/100); } #Compose return... return array ($membershipdiff, $membershipsaving, $membershipdiff24, $membershipsaving24, $no24offer); } // function hyperlink($text) { // #$text = ereg_replaceFF("(\ |^)[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","\\0", $text); // // match protocol://address/path/file.extension?some=variable&another=asf% // //Since 6/16/23, 9:14 AM we remove mailto: if present... // $text = str_replace("mailto:", "", $text); // $text = preg_replace("/(\s|\>|^)([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\.|\,])([a-z]{2,6})([a-zA-Z0-9\/\-\?\&\@\.\%\=\_\#\+]*)(\s|$|\<[b-zB-Z]+)/i", "$1$2$3$4$5$6", $text); // // match www.something.domain/path/file.extension?some=variable&another=asf% // $text = preg_replace("/(\s|\>|^)(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])([a-z]{2,6})([a-zA-Z0-9\/\-\?\&\%\=]*)(\s|$|\<[b-zB-Z]+)/i", "$1$2$3$4$5$6", $text); // //Added 6-3-2016... // $text = preg_replace("/(\s|\>|^)([a-zA-Z]+:\/\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-z]{2,6}\/[a-zA-Z0-9]+\?[a-zA-Z0-9]+\=[a-zA-Z0-9]+)(\s|$|\<)/i", "$1$2$3", $text); // // match name@address // $text = preg_replace("/(\s|\>|^)([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,|$|\<])/i","$1$2$3", $text); // //Toglie target_blank se il link e' a vsm page (locale) (9-5-08)... // $text = preg_replace("/(\)/i", "$1$2$4$5", $text); // $text = preg_replace("/(\)/i", "$1$2$4$5", $text); // return $text; // } function hyperlink($text) { // Remove mailto: if present $text = str_replace("mailto:", "", $text); // 1. Link URLs with protocol (http, https, ftp, etc.) $text = preg_replace_callback( '/(?"\']+[^\s<>"\'\.,;:!?\)\]])/i', function ($matches) { $url = $matches[1]; return '' . $url . ''; }, $text ); // 2. Link www. URLs only if NOT preceded by :// $text = preg_replace_callback( '/(?])\b(www\.[^\s<>"\']+[^\s<>"\'\.,;:!?\)\]])/i', function ($matches) { $url = $matches[1]; return '' . $url . ''; }, $text ); // 3. Link email addresses ONLY outside ... tags // Split by ... $parts = preg_split('/(]*>.*?<\/a>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($parts as $i => $part) { // Only process parts that are NOT links if ($i % 2 == 0) { $parts[$i] = preg_replace( '/\b([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})\b/', '$1', $part ); } } $text = implode('', $parts); // 4. Remove target="_blank" for local VSM links (https and http) $text = preg_replace( '/("; #Checks if thisis already inside purchases_details for this purchase... $query = "SELECT ticket FROM purchases_details WHERE ticket = '$cbreceipt' AND session_id = '$s_id' AND product_id = '$single'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if (!$nitems) { #If not, inserts... $query = "INSERT INTO purchases_details (ticket, session_id, product_id, tempo, quantity) VALUES ('$cbreceipt', '$s_id', '$single', $tempo, $quantity)"; $result = mysql_queryFF($query); } } } } #Other function similar to hyperlink but tackle other versions... function hyperlink2($text, $nofollow = 0) { if ($nofollow) { $nofollowcode = ' rel="nofollow noopener"';//Noopener added 1-19-2018... } else { $nofollowcode = ' rel="noopener"';//Noopener added 1-19-2018... } $text = preg_replace('/(((f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/', '$1', $text); $text = preg_replace('/(((f|ht){1}tps:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/', '$1', $text); $text = preg_replace('/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/', '$1$2', $text); if (strpos($text, "http") === false) {//Just for emails, check added 9/18/23, 10:05 AM... $text = preg_replace('/([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})/', '$1', $text); } /* $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1', $text); $text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1\\2', $text); $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '\\1', $text); */ return $text; } #Function to return item price... function takeitemprice($id) { global $GLOBscorestable; $query = "SELECT price FROM $GLOBscorestable WHERE id = '$id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { #Is offer... $price = mysql_resultFF($result,0, 'price'); } return $price; } function printMBBANNER($memburl, $option = 0) { global $MEMBERSHIP_PRICEorig, $MemorialDay2023; $output = 'Start your Sheet Music Membership now!'; return $output; } #Function to get product_source_id of specific item... function get_product_source_id($id) { global $GLOBscorestable; $query = "SELECT product_source_id FROM $GLOBscorestable WHERE id = '$id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { #Is offer... $product_source_id = mysql_resultFF($result,0, 'product_source_id'); } return $product_source_id; } #Function to get product_type_id of specific item... function get_product_type_id($id) { global $GLOBscorestable; $query = "SELECT product_type_id FROM $GLOBscorestable WHERE id = '$id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { #Is offer... $product_type_id = mysql_resultFF($result,0, 'product_type_id'); } return $product_type_id; } #function to return item title only (2-23-2011)... function return_id_title($id) { global $GLOBscorestable; $query = "SELECT title FROM $GLOBscorestable WHERE id = '$id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { #Is offer... $title = mysql_resultFF($result,0, 'title'); $title = str_replace("|", "", $title); return $title; } else { return ''; } } #Function to return IE version... function ieversion() { eregFF('MSIE ([0-9]\.[0-9])',$_SERVER['HTTP_USER_AGENT'],$reg); if(!isset($reg[1])) { return -1; } else { return floatval($reg[1]); } } #Function to return data of a specific composer (from composer name - full name) function get_composer_info($fullname) { global $GLOBComposertable; $fullname = mysql_real_escape_stringFF($fullname); $query = "SELECT * FROM $GLOBComposertable WHERE name = '$fullname'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_fetch_assocFF($result); } else { return array(); } } #Function to return composer id of a specific composer (from composer name - full name) function get_composer_id($fullname, $mustbelive = 0) { global $GLOBComposertable; $fullname = mysql_real_escape_stringFF($fullname); $query = "SELECT id FROM virtualsheetmusic_optimizations.".$GLOBComposertable."_OPTIMIZED WHERE name = '$fullname'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0,'id'); } elseif (!$mustbelive) { //Tries to take it from Composer table (fixing 5-1-2014)... $query = "SELECT id FROM virtualsheetmusic.Composer WHERE name = '$fullname'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0,'id'); } else { //Tries to take it from Composer3 table (fixing 1-22-2019)... $query = "SELECT id FROM virtualsheetmusic.Composer3 WHERE name = '$fullname'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0,'id'); } else { return ''; } } } } #Function to return composer id of a specific composer (from composer name - abrv. name) function get_composer_id_abr($abrname) { global $GLOBComposertable; $abrname = mysql_real_escape_stringFF($abrname); $query = "SELECT id FROM $GLOBComposertable WHERE abbreviated_name = '$abrname'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0,'id'); } else { //Tries to take it from Composer table (fixing 5-1-2014)... $query = "SELECT id FROM Composer WHERE abbreviated_name = '$abrname'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0,'id'); } else { //Tries to take it from Composer3 table (fixing 1-22-2019)... $query = "SELECT id FROM Composer3 WHERE abbreviated_name = '$abrname'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0,'id'); } else { return ''; } } } } #Function to emulate $composerarray[$composer_id] old global composer system (rev. 4-18-2011) function em_composerarray($composer_id, $fromopttable = 0) { global $GLOBComposertable, $scores_dev3, $composerarray; if ($scores_dev3) { if ($fromopttable) {//If we want to get this from the optimized table (2-13-2017) $query = "SELECT name, ID FROM virtualsheetmusic_optimizations.".$GLOBComposertable."_OPTIMIZED WHERE ID = '$composer_id'"; } else {//Regular composers table... $query = "SELECT name, ID FROM $GLOBComposertable WHERE ID = '$composer_id'"; } $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { //If ID is different by $composer_id, returns "errorid:ID" so that we can make //301 redirect to correct composer URL (6-4-2013)... $idhere = mysql_resultFF($result,0, 'ID'); if ($idhere != $composer_id) { return "errorid:".$idhere; } else {//OK... return mysql_resultFF($result,0, 'name'); } } else { return NULL; } } else { return $composerarray[$composer_id]; } } #Function to emulate $composerarrayindexrev[$composer_name] old global composer system (rev. 4-18-2011) function em_composerarrayindexrev($composer_name) { global $GLOBComposertable, $scores_dev3, $composerarrayindexrev; if ($scores_dev3) { $query = "SELECT ID FROM $GLOBComposertable WHERE name = '$composer_name'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0, 'ID'); } else { return NULL; } } else { return $composerarrayindexrev[$composer_name]; } } #Function to put Genre table inside $genreset array (5-12-2011)... function setgenres() { $query = "SELECT genre_name FROM Genre WHERE is_used = 1"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { while ($row = mysql_fetch_arrayFF($result)) { $genre_name = $row["genre_name"]; $genreset[$genre_name] = 1; } } return $genreset; } #Function to return list of items bought for receitp page and other... function getboughtproducts($ticket) { global $GLOBpricecolumn, $GLOBscorestable, $offersetflag, $GLOBofferitems, $GLOBofferitemsflag, $plantedone, $mbcomboflag; #Lista gli items e loro prezzo... $querySSP = "SELECT distinct a.product_id, a.quantity, count(a.product_id) as quantitycalc, b.product_type_id FROM purchases_details a, $GLOBscorestable b WHERE a.ticket = '$ticket' AND a.product_id != 'shipping_fee' AND a.product_id != 'sale_tax' AND a.product_id NOT LIKE 'discount_%' AND b.id = a.product_id GROUP BY a.product_id ORDER by b.product_type_id, b.PDFdir = 'OFFER' DESC"; $resultSSP = mysql_queryFF($querySSP); $nitemsSSP = mysql_num_rowsFF($resultSSP); #print "querySSP: $querySSP"; #exit; $cc = 0; while ($rowSI = mysql_fetch_arrayFF($resultSSP)) { #Prende il prezzo di ogni singolo item... $queryPRSI = "SELECT $GLOBpricecolumn, title, Instruments, product_type_id, PDFdir, PDFs FROM $GLOBscorestable WHERE id = '".$rowSI["product_id"]."'"; $resultPRSI = mysql_queryFF($queryPRSI); #Now looks if this order includes an offer to remove price for included items (!!) #Fixing 10-22-2012)... $PDFdir = mysql_resultFF($resultPRSI,0,'PDFdir'); $PDFs = mysql_resultFF($resultPRSI,0,'PDFs'); if ($PDFdir == "OFFER") { $PDFsarr = explode(",", $PDFs); foreach ($PDFsarr as $single) { $offerset[$single] = 1; $offersetflag = 1; } } if (!$offerset[$rowSI['product_id']]) {#Skip included offers... $prezzoAR[$cc] = mysql_resultFF($resultPRSI,0, $GLOBpricecolumn); $titleitem = mysql_resultFF($resultPRSI,0,'title'); $titleitemAR[$cc] = cleanffstring($titleitem); $itemidAR[$cc] = $rowSI["product_id"]; $product_type_idAR[$cc] = mysql_resultFF($resultPRSI,0,'product_type_id'); $instrumentitem = mysql_resultFF($resultPRSI,0,'Instruments'); $instrumentitem = cleanffstring($instrumentitem); $instrumentitemAR[$cc] = $instrumentitem; if ($rowSI["quantity"] > 1) {//If new quantity value, thates that (3-12-2014)... $quantityAR[$cc] = $rowSI["quantity"]; } else { $quantityAR[$cc] = $rowSI["quantitycalc"]; } $cc ++; } #Checks if there is an item with Membership,Renewal or Extension offer (11-26-2012).. if ($GLOBofferitems[$rowSI["product_id"]]) { $GLOBofferitemsflag = 1; } } /* //Checks other extra items such as OneTreePlanted, etc... $querySSP = "SELECT distinct product_id, quantity, count(product_id) as quantitycalc FROM purchases_details WHERE ticket = '$ticket' AND product_id = 'OneTreePlanted'"; $resultSSP = mysql_queryFF($querySSP); $nitemsSSP = mysql_num_rowsFF($resultSSP); if ($nitemsSSP) { $titleitemAR[$cc] = 'OneTreePlanted.org Donation'; $product_type_idAR[$cc] = '0'; $instrumentitemAR[$cc] = 'planting a tree'; $prezzoAR[$cc] = 1; $quantity = mysql_resultFF($resultSSP,0,'quantity'); $quantitycalc = mysql_resultFF($resultSSP,0,'quantitycalc'); if ($quantitycalc > 1) {//If new quantity value, thates that (3-12-2014)... $quantityAR[$cc] = $quantity; } else { $quantityAR[$cc] = $quantitycalc; } $instrumentitem = mysql_resultFF($resultPRSI,0,'Instruments'); $itemidAR[$cc] = "OneTreePlanted"; } */ return array ($titleitemAR, $instrumentitemAR, $prezzoAR, $product_type_idAR, $quantityAR, $itemidAR); } #Function to check for shipping options and return shgipping rate to be added to #total shopping cart... function check_shippingrate($tmpcbreceipt, $ticket = '') { if ($ticket) { $query = "SELECT rate FROM shipping WHERE ticket = '$ticket'"; } else { $query = "SELECT rate FROM shipping WHERE tmp_ticket = '$tmpcbreceipt'"; } $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0, 'rate'); } else { return 0; } } #Function to check for possible sale tax to be added to #total shopping cart... function check_sale_tax($tmpcbreceipt, $ticket = '') { global $GLOBpricecolumn, $GLOBscorestable, $s_id; #First, checks if this user is from California... if ($ticket) { $query = "SELECT zip FROM shipping WHERE ticket = '$ticket' AND country = 'United States' AND state = 'California'"; } else { $query = "SELECT zip FROM shipping WHERE tmp_ticket = '$tmpcbreceipt' AND country = 'United States' AND state = 'California'"; } $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { $zip = mysql_resultFF($result,0, 'zip'); $query1 = "SELECT sum(a.".$GLOBpricecolumn.") as pricehere FROM $GLOBscorestable a, carts b WHERE b.session_id = '$s_id' AND a.ID = b.product_id AND a.product_type_id = 1"; #print "ecco: $query1
"; $result1 = mysql_queryFF($query1); $nitems1 = mysql_num_rowsFF($result1); #print "ecco: $nitems1 and $ticket"; if ($nitems1) { $pricehere = mysql_resultFF($result1,0, 'pricehere'); #Applies discount if set (8-29-2011)... list ($pricehereDD, $discounthereDD) = checkdiscount($pricehere); if (!$membership_only) { $pricehere = $pricehereDD; $discounthere = $discounthereDD; } if (!$pricehere and $ticket) { #Tries to get info from cartsDOWNLOAD... $query1 = "SELECT sum(a.".$GLOBpricecolumn.") as pricehere FROM $GLOBscorestable a, cartsDOWNLOAD b WHERE b.session_id = '$s_id' AND a.ID = b.product_id AND a.product_type_id = 1 AND b.ticket = '$ticket'"; #print "ecco2: $query1"; $result1 = mysql_queryFF($query1); $nitems1 = mysql_num_rowsFF($result1); if ($nitems1) { $pricehere = mysql_resultFF($result1,0, 'pricehere'); } } #print "roo2: $pricehere"; #Now returns 7.75% sales tax (as on 8/4/2011)... return number_format((($pricehere)*SaleTax($zip))/100, 2); } else { return 0; } } else { return 0; } } #Function to check if an item is physical or not... function is_physical($id) { global $GLOBscorestable; $queryFFCK = "SELECT product_type_id FROM $GLOBscorestable WHERE ID = '$id'"; $resultFFCK = mysql_queryFF($queryFFCK); $nitemsFFCK = mysql_num_rowsFF($resultFFCK); if ($nitemsFFCK) { $prodtype = mysql_resultFF($resultFFCK,0, 'product_type_id'); if ($prodtype == 1) { return 1; } else { return 0; } } } ##Function to return sale tax from ZIP code, based on https://www.taxdatasystems.net/ API ##Look at TDSBasic.php script in cgi-bin/cart/ -- 8/15/2011... function SaleTax($ZIP) { global $GLOBbasedir, $s_id, $newcat6; #First checks if this user has been already looked-up for the past day and #if ZIP correspond. This is to avoid to make too many lookups #to the API which costs (!!!) $tempodiff = time()-86400; $query1 = "SELECT tax FROM sale_tax WHERE zip = '$ZIP' AND tempo > ".$tempodiff; $result1 = mysql_queryFF($query1); $nitems1 = mysql_num_rowsFF($result1); if ($nitems1) { $sale_tax = mysql_resultFF($result1,0, 'tax'); //print "BUFFER"; return $sale_tax; } else {#Calls API... #First delets possible user entry... $query2 = "DELETE FROM sale_tax WHERE zip = '$ZIP'"; $result2 = mysql_queryFF($query2); #API process... require_once $GLOBbasedir.'/scripts/alfred/SOAP/nusoap/lib/nusoap.php'; $USER_ID = 'fabrizio@virtualsheetmusic.com'; $PASSWORD = 'topoloso1211'; $WSDL = 'http://service.taxdatasystems.net/TdsBasic.svc?WSDL'; $LOCATION = 'http://service.taxdatasystems.net/TdsBasic.svc/basic'; //This block below has been commented out on 11/12/19, 11:33 AM because doens't work anymore... //It was used for our own physical products (violin package), but the acount on that site was disabled a while ago. //If needed, call Tax Data Systems at 1-800-327-8829 Opt. 4-2 and ask about login info and restore our account. /* // create client $client = new SoapClient($WSDL, array('trace' => 1, 'exceptions' => 1, 'location'=>$LOCATION)); //set up parameter array $params = array("zipcode" => $ZIP, "username" => $USER_ID, "password" => $PASSWORD ); //call the web service operation $result = $client->__soapCall("GetTDSBasicUSPlainNetwork", array($params), null, null, $output_header); //show service results //Note that these are not all the fields contained in the service $sale_tax = 100*($result->GetTDSBasicUSPlainNetworkResult->ServiceResult->TotalUseTax); */ #If API returns 0 for any possible cause, set it to default OC sale tax 7.75... if (!$sale_tax) { $sale_tax = 7.75; } $county = $result->GetTDSBasicUSPlainNetworkResult->ServiceResult->County; #Then makes a new one... $query2 = "INSERT INTO sale_tax (zip, tax, county, tempo) VALUES ('$ZIP', $sale_tax, '$county', ".time().")"; $result2 = mysql_queryFF($query2); //print "API"; return $sale_tax; } } #Function to check and apply discount created 8-29-2011 for FB contest... #Modified 1-8-2012 to set to zero discounts if it is a logged Member... function checkdiscount($totaleCART, $fakediscount = 0, $forceused = 0) { global $s_id, $globaltempo, $discountuid, $discountpublic, $MEMBERlogged, $MEMBERexpired, $membership, $GLOBpricecolumn, $GLOBscorestable, $free_membership, $discount_single_use, $membership_only, $newcat6, $MEMBERrealid; #AND a.expiration >= $globaltempo #Checks if the discount has ben already activated... if ($forceused) { $query = "SELECT a.*, b.offer_id as offer_id, b.free_membership as free_membership, b.membership_only as membership_only FROM discounts a, discounts_table b WHERE a.session_id = '$s_id' AND a.id = b.id ORDER by a.tempo DESC LIMIT 1"; } else {//Default... $query = "SELECT a.*, b.offer_id as offer_id, b.free_membership as free_membership, b.membership_only as membership_only FROM discounts a, discounts_table b WHERE a.session_id = '$s_id' AND a.used = 0 AND a.id = b.id ORDER by a.tempo DESC LIMIT 1"; } $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); /* if ($newcat6) { print "
totaleCART: $totaleCART - query: $query - $nitems"; } */ if ($nitems) { $discountuid = mysql_resultFF($result,0, 'uid'); $idhere = mysql_resultFF($result,0, 'id'); $discount = mysql_resultFF($result,0, 'discount'); $offer_id = mysql_resultFF($result,0, 'offer_id'); $free_membership = mysql_resultFF($result,0, 'free_membership'); $membership_only = mysql_resultFF($result,0, 'membership_only'); #If item specific, checks if applicable... if ($offer_id) { if ($membership) { $discount = 0; } else { #Gets price of offer_id... $query1 = "SELECT $GLOBpricecolumn FROM $GLOBscorestable WHERE ID = '$offer_id'"; $result1 = mysql_queryFF($query1); $nitems1 = mysql_num_rowsFF($result1); if ($nitems1) { $priceck = mysql_resultFF($result1,0, $GLOBpricecolumn); if ($priceck != $totaleCART and !$fakediscount) { $discount = 0; } } } } if ($MEMBERrealid and !$MEMBERexpired and !$membership) { $discount = 0; } $tempohere = mysql_resultFF($result,0, 'tempo'); $expiration = mysql_resultFF($result,0, 'expiration'); $discountpublic = mysql_resultFF($result,0, 'public'); $discount_single_use = mysql_resultFF($result,0, 'single_use'); if ($expiration) { $expires = $expiration; } else { $expires = mktime(0, 0, 0, date("m", $tempohere)+1, date("d", $tempohere), date("Y", $tempohere)); } #print "ecco: $tempohere - $expires"; if ($globaltempo > $expires) {#Expired, returns null... $free_membership = 0; return array($totaleCART, 0); } else {#Ok, proceed... return array(round($totaleCART-(($totaleCART*$discount)/100), 2), $discount); } } else { $discountuid = 0; return array($totaleCART, 0); } } #Function to queue mailing commands inside mailing_lyris table #This function has been created for the old and new system (4-4-2012)... function mailing_queue($email, $name, $UserID, $origemail, $command, $fromscript) { global $globaltempo; $query = "INSERT INTO mailing_lyris (email, name, UserID, origemail, command, fromscript, tempo) VALUES ('$email', '$name', '$UserID', '$origemail', '$command', '$fromscript', $globaltempo)"; //print "query: $query
"; $result = mysql_queryFF($query); } #Function to count login attempts for Members to avoid vicous loop (4-25-2012)... #And in case there are more than 2 attempts, resets cookies... function check_vicious_loop($s_id) { global $globaltempo; if ($s_id) { $query = "SELECT session_id FROM antilooplogin WHERE session_id = '$s_id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) {#If present, we must reset cookies... $query1 = "DELETE FROM antilooplogin WHERE session_id = '$s_id'"; $result1 = mysql_queryFF($query1); setcookie("vsmpm","",time(),'/'); setcookie("vsmtm","",time(),'/'); setcookie("virtual","",time(),'/'); setcookie("PHPSESSID","",time(),'/'); session_regenerate_id(); } else { $query1 = "INSERT INTO antilooplogin (session_id, tempo) VALUES ('$s_id', $globaltempo)"; $result1 = mysql_queryFF($query1); } } } #Function to delete record inside antilooplogin once login is successful... function reset_vicious_loop($s_id) { if ($s_id) { $query1 = "DELETE FROM antilooplogin WHERE session_id = '$s_id'"; $result1 = mysql_queryFF($query1); } } #Function to replace accents with normal characters... function replace_accents($string) { //Very special stuff like special apostrophes, etc... $string = str_replace(chr(226).chr(128).chr(153), "'", $string); $string = str_replace(chr(226).chr(128).chr(152), "'", $string); $string = str_replace(chr(226).chr(128).chr(166), "...", $string); $string = str_replace(chr(226).chr(128).chr(147), "-", $string); //These accents are composed by 2 combined characters and must be processed before //the blocks below... $string = str_replace(chr(195).chr(188), "u", $string); $string = str_replace(chr(195).chr(169), "e", $string); $string = str_replace(chr(195).chr(164), "a", $string); $string = str_replace(chr(195).chr(159), "ss", $string); $string = str_replace(chr(195).chr(178), "o", $string); $string = str_replace(chr(197).chr(153), "r", $string); $string = str_replace(chr(195).chr(161), "a", $string); $string = str_replace(chr(195).chr(173), "i", $string); $string = str_replace(chr(195).chr(175), "i", $string); $string = str_replace(chr(195).chr(171), "e", $string); $string = str_replace(chr(195).chr(182), "o", $string); $string = str_replace(chr(195).chr(168), "e", $string); $string = str_replace(chr(195).chr(167), "c", $string); $string = str_replace(chr(197).chr(161), "s", $string); $string = str_replace(chr(196).chr(141), "c", $string); $string = str_replace(chr(195).chr(137), "E", $string); $string = str_replace(chr(195).chr(160), "a", $string); $string = str_replace(chr(195).chr(170), "e", $string); $string = str_replace(chr(195).chr(179), "o", $string); $string = str_replace(chr(195).chr(185), "u", $string); $string = str_replace(chr(195).chr(187), "u", $string); $string = str_replace(chr(195).chr(172), "i", $string); $string = str_replace(chr(195).chr(177), "n", $string); $string = str_replace(chr(195).chr(162), "a", $string); $string = str_replace(chr(195).chr(186), "u", $string); $string = str_replace(chr(195).chr(181), "o", $string); $string = str_replace(chr(195).chr(129), "A", $string); //$string = str_replace('â', "", $string);//Removed this because messes up! //$string = HTMLcar($string); //$string = sanitizeSHARED($string); $search = explode("," , chr(220).','.chr(241).','.chr(231).','.chr(251).','.chr(226).','.chr(238).','.chr(201).','.chr(255).','.chr(193).','.chr(202).','.chr(182).','.chr(183).','.chr(200).','.chr(204).','.chr(219).','.chr(153).','.chr(253).','.chr(203).','.chr(207).','.chr(218).','.chr(152).','.chr(148).','.chr(206).','.chr(212).','.chr(150).','.chr(184).','.chr(157).','.chr(146).','.chr(205).','.chr(211).','.chr(217).','.chr(154).','.chr(194).','.chr(175).','.','.chr(233).','.chr(232).','.chr(224).','.chr(225).','.chr(236).','.chr(237).','.chr(242).','.chr(243).','.chr(249).','.chr(250).','.chr(228).','.chr(235).','.chr(239).','.chr(246).','.chr(252).','.chr(174).','.chr(147).','.chr(148).','.chr(195)); $replace = explode(",",chr(85).','.chr(110).','.chr(99).','.chr(117).','.chr(97).','.chr(105).','.chr(69).','.chr(121).','.chr(99).','.chr(97).','.chr(111).','.chr(97).','.chr(69).','.chr(105).','.chr(85).','.chr(117).','.chr(97).','.chr(69).','.chr(73).','.chr(85).','.chr(117).','.chr(34).','.chr(101).','.chr(105).','.chr(79).','.chr(117).','.chr(121).','.chr(97).','.chr(101).','.chr(105).','.chr(79).','.chr(85).','.chr(65).','.chr(111).','.','.chr(101).','.chr(101).','.chr(97).','.chr(97).','.chr(105).','.chr(105).','.chr(111).','.chr(111).','.chr(117).','.chr(117).','.chr(97).','.chr(101).','.chr(105).','.chr(111).','.chr(117).','.chr(0).','.chr(34).','.chr(34).','.chr(65)); $stringhere = str_ireplace($search, $replace, $string); //Additional replacements not working inside the expression above (5-27-2015)... $stringhere = str_replace(chr(180), "'", $stringhere); $stringhere = str_replace(chr(158), "z", $stringhere); return $stringhere; } #Function to convert all carachters over 128 to respective HTML entities (numerical, unicode)... function htmlentitiesunicode($text) { $trans = array(); for($i=128;$i<=255;$i++) { #print "ecco: $i
"; $trans[chr($i)] = "&#".$i.";"; } return strtr($text, $trans); } /* ///This below not used... #Function to remove all special characters from string... function cleanstring($string) { return trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($string)))))); } */ ##Function to check legitimacy for free items for new mailing list system (6-10-2012)... function checkbonusaccess($id) { global $bonusaccess; if ($bonusaccess) { #Checks if this is legitimate... $bonusaccess = str_replace("-FREEBONUS", "", $bonusaccess); $queryBONUS = "SELECT uid FROM nl_bonus_id WHERE item_id = '$bonusaccess'"; $resultBONUS = mysql_queryFF($queryBONUS); $nitemsBONUS = mysql_num_rowsFF($resultBONUS); if ($nitemsBONUS and $id == $bonusaccess) { return 1; } else { return 0; } } else { return 0; } } #Function to calculate offer to new Members or Renewals with new $10 credit (6-12-2012)... function calc_memb_credit($totaleCART) { $totaleCARThloffer = $totaleCART - 10; if ($totaleCARThloffer < 0) { $totaleCARThloffer = 0; } return $totaleCARThloffer; } #Function to calculate percentage saving once HLoffer $10 Member credit is applied... function calc_memb_credit_perc($totaleCART, $MemberPriceTOTO) { $perc = 100-(round((100*$MemberPriceTOTO)/$totaleCART)); return $perc; } #Function to calculate offer to new Members or Renewals with new $10 credit (6-12-2012)... #for score page taking into account shopping cart content function calc_memb_credit_cart($totaleCART) { global $GLOBscorestable, $s_id, $MEMBERcredit, $MEMBERlogged, $MEMBERrealid; $query = "SELECT sum(a.memberprice) as price FROM $GLOBscorestable a, carts b WHERE b.session_id = '$s_id' AND a.ID = b.product_id"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { $carttotal = mysql_resultFF($result,0, 'price'); $totaleCART += $carttotal; } $MEMBERcredithere = $MEMBERcredit; if (!$MEMBERcredithere and !$MEMBERrealid) { $MEMBERcredithere = 10; } elseif (!$MEMBERcredithere and $MEMBERrealid) { $MEMBERcredithere = 0; } $totaleCARThloffer = $totaleCART - $MEMBERcredithere; if ($totaleCARThloffer < 0) { $totaleCARThloffer = 0; } return $totaleCARThloffer; } #Function to return Member credit (HL credit offer for Memberships 6-12-2012)... function get_memb_credit($MEMBERid) { #Checks if this member has some credit to apply (6-12-2012)... $query = "SELECT credit FROM datamembers WHERE id = $MEMBERid AND credit > 0"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { return mysql_resultFF($result,0, 'credit'); } else { return 0; } } #Function to subtract HLoffer Membership credit (6-13-2012)... function subtract_memb_credit($amount) { global $MEMBERid, $globaltempo; if ($MEMBERid) { $query1 = "UPDATE datamembers SET credit = credit - $amount, credit_tempo = $globaltempo WHERE id = $MEMBERid"; $result1 = mysql_queryFF($query1); } } #Function to check and store discount_member into purchases_details table (6-23-2012)... function checkstorediscountmember($cbreceipt, $s_id, $hlcreditapply, $tempo) { $query = "SELECT uid FROM purchases_details WHERE ticket = '$cbreceipt' AND product_id = 'discount_member'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if (!$nitems) { $queryPD = "INSERT INTO purchases_details (ticket, session_id, product_id, price, tempo) VALUES ('$cbreceipt','$s_id','discount_member',-".$hlcreditapply.",".$tempo.")"; $resultPD = mysql_queryFF($queryPD); } } // function displaymbg($noprintflag = 0, $mbpage = 0) { // return '';//Null return for redesign 2025... // } function displaymbg($noprintflag = 0, $mbpage = 0) { global $RDT_mbnorton3, $GLOBcdn2; ###Display Money Back Guaranteee, A/B split test winner 6-2-2011... $output = '
'; if ($mbpage) {//Norton guarantee for Membership page (8-27-2018)... $output .= '
'; $output .= 'Norton Shopping Guarantee'; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $output .= '
'; } if ($RDT_mbnorton3 == 2) {//Norton guarantee for Membership payment, bottom (9-17-2018)... $output .= '
'; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $output .= '
'; } $output .= '
'; if ($noprintflag) { return $output; } else { print $output; } } function escapeMySQL($string) { $string = preg_replace("/\'/", "\\'", $string); return $string; } //Function to clean instrument to be appended to title for indexes and headers SEO 5-26-2013 function cleaninstrapp($instrhere) { $instrhere = str_replace("|","",$instrhere); //$instrhere = str_replace(" solo", "", $instrhere); //$instrhere = str_replace(" & piano", "", $instrhere); $instrhere = str_replace ("&", "&", $instrhere); return $instrhere; } function escapeparenthesis($string) { $string = str_replace('(', '\(', $string); $string = str_replace(')', '\)', $string); return $string; } ////////////////////////////////////////////////////////////////// /////NEW RANDOM TESTER 10-10-2013 cookies based!!! ////////////////////////////////////////////////////////////////// function process_randomtester($ticket) { global $HTTP_USER_AGENT, $HTTP_COOKIE_VARS, $MEMBERrealid, $membership, $mbcomboflag; $tempo = time(); if (!$HTTP_USER_AGENT) { $agenthere = 'null'; } else { $agenthere = $HTTP_USER_AGENT; } #Loops through all cookies... foreach ($HTTP_COOKIE_VARS as $key => $nrt_value) { if (preg_match("/^RDT_/", $key)) { $nrt_id = str_replace("RDT_", "", $key); $skip = 0; //Check if this random tester has excluded Members from results (6-27-2018)... $query = "SELECT exclmb FROM new_random_testers WHERE id ='$nrt_id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { $exclmb = mysql_resultFF($result,0, 'exclmb'); if ($exclmb and $MEMBERrealid and !$membership and !$mbcomboflag) {//Must NOT be a just purchased Membership though! Added 5/18/23, 1:39 PM... $skip = 1; } } if (!$skip) { ###Inserisce risultati dentro purchases_randomtester #Controllo che non ci sia gia' il record... $query = "SELECT value FROM purchases_randomtester WHERE ticket = '$ticket' and id = '$nrt_id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if (!$nitems) { #Se non presente... $queryWR = "INSERT INTO purchases_randomtester (ticket, id, value, agent, tempo) VALUES ('$ticket', '$nrt_id', $nrt_value, '$agenthere', $tempo)"; $resultWR = mysql_queryFF($queryWR); } } } } } function randomtester($id, $no_values, $duration = "1 month", $pretrack = 0, $exclmb = 0) { global $s_id, $HTTP_COOKIE_VARS, $is_robot, $globaltempo, $REQUEST_URI; if (!$is_robot and $s_id) { $tempo = time(); $number = preg_replace("/^([0-9]{1,2})(\ .+$)/", "$1", $duration); if (strpos($duration, "week")) { $expiration = strtotime("+".$number." week"); } elseif (strpos($duration, "month")) { //$expiration = time()+$number*2592000; $expiration = strtotime("+".$number." month"); } else { /* if ($id == 'NewCCform') { $queryWR = "INSERT INTO testing6 (message, message2) VALUES ('1', '$duration')"; $resultWR = mysql_queryFF($queryWR); } */ return 0;//Error, returns 0... } //print "expiration: ".date("F j, Y", $expiration); $cookiename = "RDT_".$id; #STEP 1: check if this user has already cookie set... if ($HTTP_COOKIE_VARS[$cookiename] and $value = $HTTP_COOKIE_VARS[$cookiename]) { #$queryWR = "INSERT INTO testing6 (message, message2) VALUES ('rndtest', '$value')"; #$resultWR = mysql_queryFF($queryWR); return $value;//ok, read this from cookie, returns it... } //If it is here, means that this tester has not been assigned to this user... #Controlla se questo random tester e' gia' presente nella table... $query = "SELECT value, expiration FROM new_random_testers WHERE id ='$id'"; $result = mysql_queryFF($query); $nitems = mysql_num_rowsFF($result); if ($nitems) { #Se c'e' gia', update... $expirationMYSQL = mysql_resultFF($result,0, 'expiration'); //If this tester is expired, exists and don't do anything!!! (4-11-2014)... if ($expirationMYSQL < $globaltempo) { /* if ($id == 'NewCCform') { $queryWR = "INSERT INTO testing6 (message, message2) VALUES ('3', '$expirationMYSQL - $globaltempo')"; $resultWR = mysql_queryFF($queryWR); } */ return 0;//Null... } #preleva valore corrente... $value = $random_testerTEMPOSQL = mysql_resultFF($result,0, 'value'); #Definisce nuovo valore... if ($value == $no_values) { $value = 1; } else { $value ++; } if ($random_testerTEMPOSQL and $value > 0 and $value <= $no_values) { #ridondanze... #setta... $query = "UPDATE new_random_testers SET value = $value, count = count +1, exclmb = $exclmb, last_update = $tempo WHERE id = '$id'"; $result = mysql_queryFF($query); } else { /* if ($id == 'NewCCform') { $queryWR = "INSERT INTO testing6 (message, message2) VALUES ('4', '$random_testerTEMPOSQL - $value - $no_values')"; $resultWR = mysql_queryFF($queryWR); } */ return 0;//Error, returns 0... } } else { #Altrimenti lo crea ex novo... $query = "INSERT INTO new_random_testers (id, no_values, value, count, expiration, exclmb, tempo, last_update) VALUES ('$id', $no_values, 1, 1, $expiration, $exclmb, $tempo, $tempo)"; $result = mysql_queryFF($query); $value = 1; } //print "$cookiename - $value - $expiration"; setcookie($cookiename, $value, $expiration, '/'); /* //Stores this value in checking table (for accuracy testing)... $query = "INSERT INTO random_tester_checks (cookiename, value, session_id, tempo) VALUES ('$cookiename', $value, '$s_id', $tempo)"; $result = mysql_queryFF($query); */ //If $pretrack is set, we store this value inside new_testrandomsource 3-28-2015... if ($pretrack) { $queryRDMTSTb = "INSERT IGNORE INTO new_testrandomsource (id, value, script, session_id, tempo) VALUES ('$id', $value, '$REQUEST_URI', '$s_id', $globaltempo)"; $resultRDMTSTb = mysql_queryFF($queryRDMTSTb); /* if ($s_id == "gagtl2inc8c4pclht2b71uui94") { print "ecco: $queryRDMTSTb"; exit; } */ } /* if ($id == 'NewCCform') { $queryWR = "INSERT INTO testing6 (message, message2) VALUES ('5', '$value')"; $resultWR = mysql_queryFF($queryWR); } */ return $value; } else { return 0;//Error, returns 0... } } //Function to return Muso Special Offer text on 11-14-2013... function musoffer($kind, $fontsize = '', $receipt = 0) { $output = '
to Classical Music and International Piano digital magazines!'; if ($receipt) { $output .= '
Check your email to find your '.$kind.' confirmation which includes instructions to access the magazines. Enjoy!
'; } $output .= '
'; return $output; } #Function to return "restricted" flag of specific item (1-14-2013)... function checkrestricted($itemid) { global $GLOBscorestable; $query5 = "SELECT restricted FROM $GLOBscorestable WHERE ID = '$itemid'"; $result5 = mysql_queryFF($query5); $nitems5 = mysql_num_rowsFF($result5); if ($nitems5) { return mysql_resultFF($result5, 0, 'restricted'); } else { return 0; } } ///Stores this user profile info (behavioral system March/April 2014).... function store_user_prefs($s_id, $URL, $source) { global $GLOBuseragent, $GLOBremoteaddress, $MEMBERid, $MEMBERlogged, $globaltempo, $is_robot, $boxwork, $uniuser, $VSMUSERid; if (!$is_robot) { if (!$MEMBERid or !$MEMBERlogged) { $MEMBERid = 0; } $agenthere = escapeMySQL($GLOBuseragent); if ($uniuser) { $queryWR = "INSERT INTO PROFILE_1 (session_id, uni_user_id, URL, agent, ip_address, source, tempo) VALUES ('$s_id', $VSMUSERid, '$URL', '$agenthere', '$GLOBremoteaddress', '$source'