UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd') * -> WHERE Host = 'some_host' AND User = 'some_user'; * mysql> FLUSH PRIVILEGES; */ $alg_password="OLD_PASSWORD"; $dirsito = ""; $dirfoto = "foto"; $currentPage = $_SERVER["PHP_SELF"]; $editFormAction = $currentPage; $queryString = ""; $Allowdelete=1; $Allowmodify=1; if (!empty($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { array_push($newParams, $param); } if (count($newParams) != 0) { // $queryString = "&" . htmlentities(implode("&", $newParams)); $queryString = "&" . (implode("&", $newParams)); } } function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } function url($page) { //solo con dati testo global $currentPage; $queryString = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { array_push($newParams, $param); } if (count($newParams) != 0) { $queryString = "" . htmlentities(implode("&", $newParams)); } } return ($page."?".$queryString); } function urlnew($page,$nome,$nuovo) { //solo con dati testo global $currentPage; $queryString = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "$nome") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { If ($nuovo != "") { // $queryString = "&" . htmlentities(implode("&", $newParams)); $queryString = "&" . (implode("&", $newParams)); } Else { // $queryString = "" . htmlentities(implode("&", $newParams)); $queryString = "" . (implode("&", $newParams)); } } } If ($nuovo != "") { $queryString = sprintf("$nome=%s%s", $nuovo, $queryString); } If ($page != "") { return sprintf("%s?%s", $page , $queryString); } else { return sprintf("%s?%s", $currentPage , $queryString); } } function urlok($inputqueryString,$nome,$nuovo) { //solo con dati testo global $currentPage; $queryString = ""; If ($inputqueryString == "0") { if (!empty($_SERVER['QUERY_STRING'])) { $inputqueryString=$_SERVER['QUERY_STRING']; } else { $inputqueryString = ""; } } If ($inputqueryString !== "") { $params = explode("&", $inputqueryString); $newParams = array(); foreach ($params as $param) { if (stristr($param, "$nome") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { If ($nuovo != "") { $queryString = "&" . (implode("&", $newParams)); } Else { $queryString = "" . (implode("&", $newParams)); } } } If ($nuovo != "") { $queryString = sprintf("$nome=%s%s", $nuovo, $queryString); } return $queryString; } // redirect *************************************************************** // Purpose: Redirects to relative URL on the current site // Author: http://www.edoceo.com/ function redirect($to) { $schema = $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http'; $host = strlen($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:$_SERVER['SERVER_NAME']; if (headers_sent()) { return false; } else { header("HTTP/1.1 301 Moved Permanently"); // header("HTTP/1.1 302 Found"); // header("HTTP/1.1 303 See Other"); header("Location: $schema://$host/$to"); exit(); } } // redirect *************************************************************** function jredirect($to) { if (headers_sent()) { return false; } else { echo ''; exit(); } } function Squeryvuota($codinv) { // messagi per ricerca vuota in scheda echo "
 "; echo "Nessun Risultato per la Richiesta selezionata (".$codinv.")"; } function picker($nome,$tipo,$sqlvalore) { // date picker from mysql:date da 1990 a 2010 switch ($tipo) { case 1: //giorno $value_chosen = substr($sqlvalore,8,2); if ($value_chosen == "00") { $value_chosen = ""; } $fill_array = array(""); for ($i = 1;$i <= 31;$i++) { array_push($fill_array, $i); } break; case 2: //mese $value_chosen = substr($sqlvalore,5,2); if ($value_chosen == "00") { $value_chosen = ""; } $fill_array = array(""); for ($i = 1;$i <= 12;$i++) { array_push($fill_array, $i); } break; default: //anno $value_chosen = substr($sqlvalore,0,4); if ($value_chosen == "0000") { $value_chosen = ""; } $fill_array = array(""); for ($i = 1990;$i <= 2010;$i++) { array_push($fill_array, $i); } } // inizio ritorna picker echo ""; } function formatcodfor($codfor) { $codfor = sprintf("%d", $codfor); $lung = strlen($codfor); switch ($lung) { case 1: $codfor = "F000".$codfor; break; case 2: $codfor = "F00".$codfor; break; case 3: $codfor = "F0".$codfor; break; default: $codfor = $codfor; } return $codfor; } function htmlnoformat($data) { $search = "&"; $replace = "&"; return ereg_replace("&", "&", $data); } function texteuro($data) { $data = sprintf("%01.2f", $data); $data = "€"." ".$data; return $data; } function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual) { /* Get the dimensions of the source picture */ $picsize=getimagesize("$sourcefile"); $source_x = $picsize[0]; $source_y = $picsize[1]; $source_id = imageCreateFromJPEG("$sourcefile"); /* Create a new image object (not neccessarily true colour) */ $target_id=imagecreatetruecolor($dest_x, $dest_y); /* resize the original picture and copy it into the just created image object. Because of the lack of space I had to wrap the parameters to several lines. I recommend putting them in one line in order keep your code clean and readable */ $target_pic=imagecopyresampled($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y); /* Create a jpeg with the quality of "$jpegqual" out of the image object "$target_pic". This will be saved as $targetfile */ imagejpeg ($target_id,"$targetfile",$jpegqual); return true; } function inv_foto ($codinv, $tipo) { global $dirfoto; $jpegqual=70; switch ($tipo) { case 0: //thumbnail pagina foto $folder = "thumb"; $dest_x=80; $dest_y=60; $nd="prodndt.gif"; break; case 1: //slide pagine e etich $folder = "slide"; $dest_x=320; $dest_y=240; $nd="prodnds.gif"; break; case 2: //full pagina slideshow $folder = "full"; $dest_x=800; $dest_y=600; $nd="prodndf.gif"; break; case 10: //thumbnail pagina pocket pc $folder = "thumb"; $dest_x=80; $dest_y=60; $nd="spacer.gif"; break; } if (file_exists($dirfoto."/".$folder."/".$codinv.".jpg")) { return ($dirfoto."/".$folder."/".$codinv.".jpg"); } else { // ora commentata perche immagini sono create da un cron thumbinv //if (file_exists($dirfoto."/hr/".$codinv.".jpg")) //{ // resizeToFile ($dirfoto."/hr/".$codinv.".jpg", $dest_x, $dest_y, $dirfoto."/".$folder."/".$codinv.".jpg", $jpegqual); // return ($dirfoto."/".$folder."/".$codinv.".jpg"); //} //else //{ return ($dirfoto."/".$nd); //} } } function admin_table($database, $ordina="", $database2="", $link2="") // verifica database per modifica // se trovato ok return true // altrimenti return false { global $database_gestione; global $gestione; global $result; if ( $ordina !="" ) { $ordina=" ORDER BY ".$ordina; } // Ricerca nel DB If ( ($database2 == "") && ($link2 == "") ) { $updateSQL = sprintf("SELECT * FROM %s $ordina", $database); } else { $updateSQL = sprintf("SELECT * FROM %s, %s WHERE $database.$link2 = $database2.$link2 $ordina", $database, $database2); } mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$gestione) { return false; } else { if (!$result) return false; if (mysql_num_rows($result)>0) { return true; } else return false; } } function admin_modifica($database,$fai,$tableid,$tablevalue,$id,$new,$tablevalue2=0,$new2=0) // verifica database per modifica // se trovato ok return true // altrimenti return false { global $database_gestione; global $gestione; global $result; // Update DB $updateSQL=""; switch ($fai) { case 0: // Aggiungi Nuovo If ($tablevalue2==0 && $new2==0) { $updateSQL = sprintf("INSERT INTO $database ($tablevalue) VALUES (%s)", GetSQLValueString($new, "text")); } else { $updateSQL = sprintf("INSERT INTO $database ($tablevalue,$tablevalue2) VALUES (%s,%s)", GetSQLValueString($new, "text"), GetSQLValueString($new2, "text")); } break; case 1: // Modifica If ($tablevalue2==0 && $new2==0) { $updateSQL = sprintf("UPDATE $database SET $tablevalue=%s WHERE $tableid=%s LIMIT 1", GetSQLValueString($new, "text"), GetSQLValueString($id, "int")); } else { $updateSQL = sprintf("UPDATE $database SET $tablevalue=%s, $tablevalue2=%s WHERE $tableid=%s LIMIT 1", GetSQLValueString($new, "text"), GetSQLValueString($new2, "text"), GetSQLValueString($id, "int")); } break; case 9: // Cancella $updateSQL = sprintf("DELETE FROM $database WHERE $tableid=%s LIMIT 1", GetSQLValueString($id, "int")); break; } mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$gestione) { return false; } else { if (!$result) return false; } } function login($username, $password) // check username and password with db // if yes, return true // else return false { global $gestione; global $database_gestione; global $_SESSION; global $alg_password; // connect to db mysql_select_db($database_gestione, $gestione); if (!$gestione) return false; $result = mysql_query("select * from admin where username='$username' and password = ".$alg_password."('$password')"); if (!$result) return false; if (mysql_num_rows($result)>0) { $datiutente = mysql_fetch_assoc($result); $_SESSION['utente']['userid'] = $datiutente['userid']; $_SESSION['utente']['username'] = $datiutente['username']; $_SESSION['utente']['tipo'] = $datiutente['tipo']; $_SESSION['utente']['nome'] = $datiutente['nome']; $_SESSION['utente']['cognome'] = $datiutente['cognome']; $_SESSION['utente']['m_agenda'] = $datiutente['m_agenda']; $_SESSION['utente']['m_email'] = $datiutente['m_email']; $_SESSION['utente']['m_rubrica'] = $datiutente['m_rubrica']; $_SESSION['utente']['m_inv'] = $datiutente['m_inv']; $_SESSION['utente']['m_inv_ditta'] = $datiutente['m_inv_ditta']; $_SESSION['utente']['m_inv_def'] = $datiutente['m_inv_def']; $_SESSION['utente']['m_cespiti'] = $datiutente['m_cespiti']; $_SESSION['utente']['m_gestione'] = $datiutente['m_gestione']; $_SESSION['utente']['m_contab'] = $datiutente['m_contab']; $_SESSION['utente']['m_info'] = $datiutente['m_info']; $_SESSION['utente']['email'] = $datiutente['email']; $_SESSION['utente']['remoteserver'] = $datiutente['remoteserver']; $_SESSION['utente']['remoteport'] = $datiutente['remoteport']; $_SESSION['utente']['remotetype'] = $datiutente['remotetype']; $_SESSION['utente']['remoteuser'] = $datiutente['remoteuser']; $_SESSION['utente']['remotepassword'] = $datiutente['remotepassword']; mysql_free_result($result); return true; } else return false; } function check_auth_user() // see if somebody is logged in and notify them if not { global $_SESSION; if (isset($_SESSION['utente']['username'])) return true; else return false; } function check_module($requiremod='', $valore=1) // verifica se il modulo rientra tra quelli autorizzati o meno // da completare { global $_SESSION; if (($requiremod=='') || (isset($_SESSION['utente']["$requiremod"]) && $_SESSION['utente']["$requiremod"]>=$valore)) return true; else return false; } function email($fromname, $fromaddress, $toname, $toaddress, $subject, $message) { // Copyright ? 2005 ECRIA LLC, http://www.ECRIA.com // Please use or modify for any purpose but leave this notice unchanged. $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php\n"; $headers .= "From: \"".$fromname."\" <".$fromaddress.">\n"; return mail($toaddress, $subject, $message, $headers); } function checkemail($email) { // checks proper syntax if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email)) { return false; } else { return true; } } ?>0) { $row_select = mysql_fetch_assoc($result); $risultato=$row_select['marcaid']; mysql_free_result($result); return $risultato; } else { return false; } } } function info_aggiungi_marca($produttore) // verifica produttore // se trovato return nome { global $database_gestione; global $gestione; // Ricerca nel DB // Insert new marca $updateSQL = sprintf("INSERT INTO pcitalia_marca (marca) VALUES (%s)", GetSQLValueString(ucwords(strtolower($produttore)), "text")); mysql_select_db($database_gestione, $gestione); $Result1 = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$gestione) { return false; } else { return true; } } function pcitalia_categoria_automatico($categoriafornitore) // verifica categoria se tutto ok ritorna array catid defcatid // altrimenti return array false 1,1 (Varie) { global $database_gestione; global $gestione; $categoriaid=info_verifica_categoria($categoriafornitore); if ($categoriaid[1]) { // Trovato perciņ selezionalo return $categoriaid; } else { // Aggiungi Nuova categoria // if (info_aggiungi_marca($produttore)) // { // $marcaid=info_verifica_marca($produttore); // return $marcaid; // } // else // { return array(1,1); // } } } function info_verifica_categoria($categoriafornitore) // verifica categoria // se trovato return array catid { global $database_gestione; global $gestione; // Ricerca nel DB if ( $categoriafornitore != "" ) { $updateSQL = sprintf("SELECT catid,repiddef FROM pcitalia_cat WHERE cat LIKE '%%%s%%' OR catcontforn LIKE '%%%s%%' ",$categoriafornitore,$categoriafornitore); mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); } else { return false; } if (!$gestione) { return false; } else { if (!$result) { return false; } if (mysql_num_rows($result)>0) { $row_select = mysql_fetch_assoc($result); $risultato=array($row_select['catid'],$row_select['repiddef']); mysql_free_result($result); return $risultato; } else { return false; } } } function pcitalia_scat_automatico($sottocategoria,$catid) // verifica sottocategoria se tutto ok ritorna id // altrimenti return false 1 (Varie) { global $database_gestione; global $gestione; $scatid=info_verifica_scat($sottocategoria,$catid); if ($scatid) { // Trovato perciņ selezionalo return $scatid; } else { // Aggiungi Nuova scat if (info_aggiungi_scat($sottocategoria,$catid)) { $scatid=info_verifica_scat($sottocategoria,$catid); return $scatid; } else { return 1; } } } function info_verifica_scat($sottocategoria,$catid) // verifica sottocategoria // se trovato return scatid { global $database_gestione; global $gestione; // Ricerca nel DB if ( $sottocategoria != "" ) { $updateSQL = sprintf("SELECT scatid FROM pcitalia_scat WHERE scat LIKE '%%%s%%' AND catid = %s ",$sottocategoria,$catid); mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); } else { return false; } if (!$gestione) { return false; } else { if (!$result) { return false; } if (mysql_num_rows($result)>0) { $row_select = mysql_fetch_assoc($result); $risultato=$row_select['scatid']; mysql_free_result($result); return $risultato; } else { return false; } } } function info_aggiungi_scat($sottocategoria,$catid) // verifica produttore // se trovato return nome { global $database_gestione; global $gestione; // Ricerca nel DB // Insert new marca $updateSQL = sprintf("INSERT INTO pcitalia_scat (scat, catid) VALUES (%s, %s)", GetSQLValueString(ucwords(strtolower($sottocategoria)), "text"), GetSQLValueString($catid, "int")); mysql_select_db($database_gestione, $gestione); $Result1 = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$gestione) { return false; } else { return true; } } function pcitalia_automatico($fornid,$repiddef,$catid,$scatid,$marcaid,$catforn,$scatforn,$codiceforn,$codiceprod,$codiceean,$descrizioneforn,$quantitaforn,$quantitafornsede,$prezzoforn,$prezzolist,$vetrina,$lastupdate) // verifica variabili inventario // se tutto ok return true // altrimenti return false { global $database_gestione; global $gestione; global $elementi_nuovi; global $elementi_modificati; global $elementi_cancellati; $id=info_verifica($fornid,$codiceforn); if ($id) { // Trovato perciņ modifica return info_modifica($fornid,$repiddef,$catid,$scatid,$marcaid,$catforn,$scatforn,$codiceforn,$codiceprod,$codiceean,$descrizioneforn,$quantitaforn,$quantitafornsede,$prezzoforn,$prezzolist,$vetrina,$lastupdate,$id); } else { // Aggiungi Nuovo return info_aggiungi($fornid,$repiddef,$catid,$scatid,$marcaid,$catforn,$scatforn,$codiceforn,$codiceprod,$codiceean,$descrizioneforn,$quantitaforn,$quantitafornsede,$prezzoforn,$prezzolist,$vetrina,$lastupdate); } } function info_verifica($fornid,$codiceforn) // verifica codiceforn in forid // se trovato ok return true // altrimenti return false { global $database_gestione; global $gestione; // Ricerca nel DB $updateSQL = sprintf("SELECT id FROM pcitalia WHERE fornid = %s AND codiceforn = %s", GetSQLValueString($fornid, "int"), GetSQLValueString($codiceforn, "text")); mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$gestione) { return false; } else { if (!$result) return false; if (mysql_num_rows($result)>0) { $row_select = mysql_fetch_assoc($result); $risultato=$row_select['id']; mysql_free_result($result); return $risultato; } else return false; } } function info_aggiungi($fornid,$repiddef,$catid,$scatid,$marcaid,$catforn,$scatforn,$codiceforn,$codiceprod,$codiceean,$descrizioneforn,$quantitaforn,$quantitafornsede,$prezzoforn,$prezzolist,$vetrina,$lastupdate) // verifica variabili inventario // se tutto ok return true // altrimenti return false { global $database_gestione; global $gestione; global $elementi_nuovi; //Calcola promo vetrina if ( (strlen(stristr($descrizioneforn,'promo'))>0) or (strlen(stristr($descrizioneforn,'fino:'))>0) ) { $vetrina=1; } else { $vetrina=0; } // Aggiungi Nuovo $updateSQL = sprintf("INSERT INTO pcitalia (fornid, repid, catid, scatid, marcaid, catforn, scatforn, codiceforn, codiceprod, codiceean, descrizioneforn, quantitaforn, quantitafornsede, prezzoforn, prezzolist, lastupdate, vetrina ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($fornid, "int"), GetSQLValueString($repiddef, "int"), GetSQLValueString($catid, "int"), GetSQLValueString($scatid, "int"), GetSQLValueString($marcaid, "int"), GetSQLValueString($catforn, "text"), GetSQLValueString($scatforn, "text"), GetSQLValueString($codiceforn, "text"), GetSQLValueString($codiceprod, "text"), GetSQLValueString($codiceean, "text"), GetSQLValueString($descrizioneforn, "text"), GetSQLValueString($quantitaforn, "int"), GetSQLValueString($quantitafornsede, "int"), GetSQLValueString($prezzoforn, "double"), GetSQLValueString($prezzolist, "double"), GetSQLValueString($lastupdate, "text"), GetSQLValueString($vetrina, "int")); mysql_select_db($database_gestione, $gestione); $Result1 = mysql_query($updateSQL, $gestione) or die(mysql_error()); $elementi_nuovi++; if (!$gestione) { return false; } else { return true; } } function info_modifica($fornid,$repiddef,$catid,$scatid,$marcaid,$catforn,$scatforn,$codiceforn,$codiceprod,$codiceean,$descrizioneforn,$quantitaforn,$quantitafornsede,$prezzoforn,$prezzolist,$vetrina,$lastupdate,$id) // verifica variabili inventario // se tutto ok return true // altrimenti return false { global $database_gestione; global $gestione; global $elementi_modificati; // Modifica $updateSQL = sprintf("UPDATE pcitalia SET fornid=%s, repid=%s, catid=%s, scatid=%s, marcaid=%s, catforn=%s, scatforn=%s, codiceforn=%s, codiceprod=%s, codiceean=%s, descrizioneforn=%s, quantitaforn=%s, quantitafornsede=%s, prezzoforn=%s, prezzolist=%s, lastupdate=%s, vetrina=%s WHERE id=%s LIMIT 1", GetSQLValueString($fornid, "int"), GetSQLValueString($repiddef, "int"), GetSQLValueString($catid, "int"), GetSQLValueString($scatid, "int"), GetSQLValueString($marcaid, "int"), GetSQLValueString($catforn, "text"), GetSQLValueString($scatforn, "text"), GetSQLValueString($codiceforn, "text"), GetSQLValueString($codiceprod, "text"), GetSQLValueString($codiceean, "text"), GetSQLValueString($descrizioneforn, "text"), GetSQLValueString($quantitaforn, "int"), GetSQLValueString($quantitafornsede, "int"), GetSQLValueString($prezzoforn, "double"), GetSQLValueString($prezzolist, "double"), GetSQLValueString($lastupdate, "text"), GetSQLValueString($vetrina, "int"), GetSQLValueString($id, "int")); mysql_select_db($database_gestione, $gestione); $Result1 = mysql_query($updateSQL, $gestione) or die(mysql_error()); $elementi_modificati++; if (!$gestione) { return false; } else { return true; } } function info_delete($fornid,$lastupdate) // cancella tutti i record del fornid diversi da lastupdate // se tutto ok return true // altrimenti return false { global $database_gestione; global $gestione; global $elementi_cancellati; // Cancella $updateSQL = sprintf("SELECT id FROM pcitalia WHERE fornid = %s AND lastupdate != %s", GetSQLValueString($fornid, "int"), GetSQLValueString($lastupdate, "text")); mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$gestione) return false; //if (!$result) // return false; $elementi_cancellati=mysql_num_rows($result); mysql_free_result($result); $updateSQL = sprintf("DELETE FROM pcitalia WHERE fornid = %s AND lastupdate != %s", GetSQLValueString($fornid, "int"), GetSQLValueString($lastupdate, "text")); mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$result) return false; else return true; } function select($id) // richiesta row select su pcitlia // per visualizza singole se tutto ok return true // altrimenti return false { global $database_gestione; global $gestione; global $inv_select; global $row_select; global $select; mysql_select_db($database_gestione, $gestione); $query_select = sprintf("SELECT * FROM pcitalia WHERE id = %s", $id); $select = mysql_query($query_select, $gestione) or die(mysql_error()); $inv_select = mysql_fetch_assoc($select); $totalinv_select = mysql_num_rows($select); // se il codice invetario preso non appare in tabella risultati if (!$gestione) return false; if ($totalinv_select >= 1) { return true; } else { return false; } } function modifica($id,$tablevalue,$new) // richiesta modifica su pcitalia // per visualizza singole se tutto ok return true // altrimenti return false { global $database_gestione; global $gestione; global $result; $updateSQL = sprintf("UPDATE pcitalia SET $tablevalue=%s WHERE id=%s LIMIT 1", GetSQLValueString($new, "int"), GetSQLValueString($id, "int")); mysql_select_db($database_gestione, $gestione); $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$gestione) { return false; } else { if (!$result) return false; } } function setupinfo() // verifica variabili informatica // se tutto ok return true // altrimenti return false { global $_GET; global $_POST; global $id; global $database_gestione; global $gestione; global $row_select; global $pzcosto; global $select; global $selec2; global $invrisultati; global $invprec; global $invsucc; global $ordina; global $categoria; global $marca; global $disp; global $reparto; global $ricerca; global $row_forn; global $totalRows_forn; global $row_dcat; global $totalRows_dcat; global $row_Gcat; global $totalRows_Gcat; global $row_Gscat; global $totalRows_Gscat; global $row_marcaG; global $totalRows_marcaG; global $marcaG; global $row_marcaC; global $totalRows_marcaC; global $marcaC; global $row_rep; global $totalRows_rep; global $rep; global $rep2; global $forn; global $dcat; global $dcat2; global $Gcat; global $Gscat; global $print; global $scatid; global $pagina; global $pagine; global $rigepagina; global $totalPages_inv; // prende valore del codinv altrimenti assegna 0 $colname_select = "0"; if (isset($_GET['id'])) { $colname_select = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } $id=$colname_select; // prende valore altre variabili $invrisultati = 0; $pzcosto=0; $pagina_select = 1; if (isset($_GET['pagina'])) { $pagina_select = (get_magic_quotes_gpc()) ? $_GET['pagina'] : addslashes($_GET['pagina']); } if (!(strcmp("Tutte", $pagina_select))) { $pagina = 1; $pagine = 0; } else { $pagina = $pagina_select; } $print_select = 0; if (isset($_GET['print'])) { $print_select = (get_magic_quotes_gpc()) ? $_GET['print'] : addslashes($_GET['print']); } $print = $print_select; $marca_select = "T"; if (isset($_GET['marca'])) { $marca_select = (get_magic_quotes_gpc()) ? $_GET['marca'] : addslashes($_GET['marca']); } $marca = $marca_select; $disp_select = "T"; if (isset($_GET['disp'])) { $disp_select = (get_magic_quotes_gpc()) ? $_GET['disp'] : addslashes($_GET['disp']); } $disp = $disp_select; $reparto_select = "T"; if (isset($_GET['reparto'])) { $reparto_select = (get_magic_quotes_gpc()) ? $_GET['reparto'] : addslashes($_GET['reparto']); } $reparto = $reparto_select; $categoria_select = "T"; $scatid="T"; if (isset($_GET['categoria'])) { $categoria_select = (get_magic_quotes_gpc()) ? $_GET['categoria'] : addslashes($_GET['categoria']); $temps = explode("-", $categoria_select); $newTemp = array(); foreach ($temps as $temp) { array_push($newTemp, $temp); } if (count($newTemp) > 1) { $categoria_select = $newTemp[0]; $scatid = $newTemp[1]; } } $categoria = $categoria_select; $ricerca_select = ""; if ( isset($_POST['ricerca']) && isset($_POST['invia']) ) { $ricerca_select = (get_magic_quotes_gpc()) ? $_POST['ricerca'] : addslashes($_POST['ricerca']); } $ricerca = $ricerca_select; // carica categorie mysql_select_db($database_gestione, $gestione); // query distint categoria $query_rep = " SELECT DISTINCT pcitalia_rep.repid,pcitalia_rep.rep FROM pcitalia_rep"; $query_rep .= " ORDER BY repid"; $rep = mysql_query($query_rep, $gestione) or die(mysql_error()); $rep2 = mysql_query($query_rep, $gestione) or die(mysql_error()); // $row_rep = mysql_fetch_assoc($rep); $totalRows_rep = mysql_num_rows($rep); $query_marcaG = " SELECT DISTINCT pcitalia_marca.marcaid,pcitalia_marca.marca FROM pcitalia_marca"; $query_marcaG .= " ORDER BY marca"; $marcaG = mysql_query($query_marcaG, $gestione) or die(mysql_error()); // $row_marcaG = mysql_fetch_assoc($marcaG); $totalRows_marcaG = mysql_num_rows($marcaG); $query_forn = " SELECT DISTINCT pcitalia_forn.fornid,pcitalia_forn.forn FROM pcitalia_forn"; $query_forn .= " ORDER BY forn"; $forn = mysql_query($query_forn, $gestione) or die(mysql_error()); // $row_forn = mysql_fetch_assoc($forn); $totalRows_forn = mysql_num_rows($forn); $query_dcat = " SELECT DISTINCT pcitalia_cat.catid,pcitalia_cat.cat FROM pcitalia,pcitalia_cat"; $query_dcat .= " WHERE pcitalia.catid = pcitalia_cat.catid"; if ($reparto !== "T") { $query_dcat .= sprintf(" AND ").sprintf(" pcitalia.repid = %s ", $reparto); } $query_dcat .= " ORDER BY cat"; $dcat = mysql_query($query_dcat, $gestione) or die(mysql_error()); $dcat2 = mysql_query($query_dcat, $gestione) or die(mysql_error()); // $row_dcat = mysql_fetch_assoc($dcat); $totalRows_dcat = mysql_num_rows($dcat); $query_Gcat = " SELECT pcitalia_cat.catid,pcitalia_cat.cat FROM pcitalia_cat"; $query_Gcat .= " ORDER BY pcitalia_cat.cat"; $Gcat = mysql_query($query_Gcat, $gestione) or die(mysql_error()); // $row_Gcat = mysql_fetch_assoc($Gcat); $totalRows_Gcat = mysql_num_rows($Gcat); $query_Gscat = " SELECT pcitalia_scat.scatid,pcitalia_scat.scat,pcitalia_cat.catid,pcitalia_cat.cat FROM pcitalia_cat,pcitalia_scat"; $query_Gscat .= " WHERE pcitalia_cat.catid = pcitalia_scat.catid"; $query_Gscat .= " ORDER BY pcitalia_cat.cat, pcitalia_scat.scat"; $Gscat = mysql_query($query_Gscat, $gestione) or die(mysql_error()); // $row_Gscat = mysql_fetch_assoc($Gscat); $totalRows_Gscat = mysql_num_rows($Gscat); // query list // Ema disabilita scat // $query_select = sprintf("SELECT * FROM pcitalia,pcitalia_cat,pcitalia_rep "); // $query_selec2 = sprintf("SELECT id FROM pcitalia,pcitalia_cat,pcitalia_rep "); // $query_marcaC = " SELECT DISTINCT pcitalia.marcaid,pcitalia_marca.marca FROM pcitalia,pcitalia_marca "; // $query_select .= sprintf("WHERE pcitalia.catid = pcitalia_cat.catid AND pcitalia.repid=pcitalia_rep.repid "); // $query_selec2 .= sprintf("WHERE pcitalia.catid = pcitalia_cat.catid AND pcitalia.repid=pcitalia_rep.repid "); // $query_marcaC .= "WHERE pcitalia.marcaid = pcitalia_marca.marcaid "; // Non funziona la disabilitazione da vedere $query_select = sprintf("SELECT * FROM pcitalia,pcitalia_cat,pcitalia_scat,pcitalia_rep,pcitalia_marca "); $query_selec2 = sprintf("SELECT id FROM pcitalia,pcitalia_cat,pcitalia_scat,pcitalia_rep "); $query_marcaC = " SELECT DISTINCT pcitalia.marcaid,pcitalia_marca.marca FROM pcitalia,pcitalia_marca "; $query_select .= sprintf("WHERE pcitalia.catid = pcitalia_cat.catid AND pcitalia.scatid = pcitalia_scat.scatid AND pcitalia.repid=pcitalia_rep.repid AND pcitalia.marcaid=pcitalia_marca.marcaid "); $query_selec2 .= sprintf("WHERE pcitalia.catid = pcitalia_cat.catid AND pcitalia.scatid = pcitalia_scat.scatid AND pcitalia.repid=pcitalia_rep.repid "); $query_marcaC .= "WHERE pcitalia.marcaid = pcitalia_marca.marcaid "; if (!(check_moduleinfo(9))) { $query_select .= sprintf(" AND ").sprintf(" pcitalia.pub = %s ", 1); $query_selec2 .= sprintf(" AND ").sprintf(" pcitalia.pub = %s ", 1); $query_marcaC .= sprintf(" AND ").sprintf(" pcitalia.pub = %s ", 1); } if ($reparto !== "T") { $query_select .= sprintf(" AND ").sprintf(" pcitalia.repid = %s ", $reparto); $query_selec2 .= sprintf(" AND ").sprintf(" pcitalia.repid = %s ", $reparto); } if (!(check_moduleinfo(9))) { $query_select .= sprintf(" AND ").sprintf(" pcitalia.repid != %s ", 1); $query_selec2 .= sprintf(" AND ").sprintf(" pcitalia.repid != %s ", 1); $query_marcaC .= sprintf(" AND ").sprintf(" pcitalia.repid != %s ", 1); } if ($disp == "T") { $query_select .= sprintf(" AND ( pcitalia.quantitaforn > %s OR pcitalia.quantitafornsede > %s ) ", 0, 0); $query_selec2 .= sprintf(" AND ( pcitalia.quantitaforn > %s OR pcitalia.quantitafornsede > %s ) ", 0, 0); $query_marcaC .= sprintf(" AND ( pcitalia.quantitaforn > %s OR pcitalia.quantitafornsede > %s ) ", 0, 0); // $query_marcaC .= sprintf(" AND (").sprintf(" pcitalia.quantitaforn > %s ", 0).; } $query_select .= sprintf(" AND ").sprintf(" pcitalia.prezzoforn > %s ", 0); $query_selec2 .= sprintf(" AND ").sprintf(" pcitalia.prezzoforn > %s ", 0); $query_marcaC .= sprintf(" AND ").sprintf(" pcitalia.prezzoforn > %s ", 0); if ($categoria !== "T") { $query_select .= sprintf(" AND ").sprintf(" pcitalia.catid = %s ", $categoria); $query_selec2 .= sprintf(" AND ").sprintf(" pcitalia.catid = %s ", $categoria); } if ($scatid !== "T") { $query_select .= sprintf(" AND ").sprintf(" pcitalia.scatid = %s ", $scatid); $query_selec2 .= sprintf(" AND ").sprintf(" pcitalia.scatid = %s ", $scatid); } if ($marca !== "T") { $query_select .= sprintf(" AND ").sprintf(" pcitalia.marcaid = %s ", $marca); $query_selec2 .= sprintf(" AND ").sprintf(" pcitalia.marcaid = %s ", $marca); } if ($ricerca !== "") { $query_select .= sprintf(" AND (").sprintf(" descrizione LIKE '%%%s%%' ", $ricerca); $query_select .= sprintf(" OR ").sprintf(" descrizioneforn LIKE '%%%s%%' ", $ricerca); $query_select .= sprintf(" ) "); $query_selec2 .= sprintf(" AND (").sprintf(" descrizione LIKE '%%%s%%' ", $ricerca); $query_selec2 .= sprintf(" OR ").sprintf(" descrizioneforn LIKE '%%%s%%' ", $ricerca); $query_selec2 .= sprintf(" ) "); } $query_select .= sprintf(" ORDER BY cat ASC, scat ASC, prezzoforn ASC"); $query_selec2 .= sprintf(" ORDER BY cat ASC, scat ASC, prezzoforn ASC"); $query_marcaC .= " ORDER BY marca"; // calcola pagina if ($pagine == "1") { $startRow_inv = ($pagina-1) * $rigepagina; $query_select .= sprintf(" LIMIT %d, %d", $startRow_inv, $rigepagina); } // echo "query1=".$query_select; $select = mysql_query($query_select, $gestione) or die(mysql_error()); $selec2 = mysql_query($query_selec2, $gestione) or die(mysql_error()); $marcaC = mysql_query($query_marcaC, $gestione) or die(mysql_error()); // $row_select = mysql_fetch_assoc($select); // $row_selec2 = mysql_fetch_assoc($selec2); // $row_marcaC = mysql_fetch_assoc($marcaC); $totalRows_select = mysql_num_rows($select); $totalRows_selec2 = mysql_num_rows($selec2); $totalRows_marcaC = mysql_num_rows($marcaC); if ($pagine == "1") { $totalPages_inv = ceil($totalRows_selec2/$rigepagina); } else { $totalPages_inv = 1; } $invmatch = 0; $invtrovato = 0; $invprec = 0; $invsucc = 0; $invlast = 0; $row_selec2 =0; if ($totalRows_selec2 >= 1) { do { if ($id == 0) { $id = $row_selec2['id']; } if ($invmatch == 1) { $invsucc = $row_selec2['id']; $invmatch = 0; } if (!(strcmp($row_selec2['id'], $id))) { $invprec = $invlast; $invmatch = 1; $invtrovato = 1; } $invlast = $row_selec2['id']; } while ($row_selec2 = mysql_fetch_assoc($selec2)); } // se il codice invetario preso non appare in tabella risultati if ($totalRows_select >= 1) { If ($invtrovato == 0) { $invrisultati=1; return false; } else { return true; } } else { return false; } } function check_auth_userinfo() // see if somebody is logged in and notify them if not { global $_SESSION; if (isset($_SESSION['pcitalia_utente']['username'])) return true; else return false; } function user_modify($userid, $username, $password, $tipo, $cognome, $nome, $referente, $via, $cap, $citta, $prov, $piva, $tel, $news) { global $gestione; global $database_gestione; // connect to db mysql_select_db($database_gestione, $gestione); if (!$gestione) return false; if ($userid=="new") { $updateSQL = sprintf("INSERT INTO pcitalia_user (username, pass, tipo, cognome, nome, riferimento, via, cap, citta, prov, piva, tel1, news ) VALUES (%s, aes_encrypt('%s','pcitalia'), %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($username, "text"), $password, GetSQLValueString($tipo, "int"), GetSQLValueString($cognome, "text"), GetSQLValueString($nome, "text"), GetSQLValueString($referente, "text"), GetSQLValueString($via, "text"), GetSQLValueString($cap, "text"), GetSQLValueString($citta, "text"), GetSQLValueString($prov, "text"), GetSQLValueString($piva, "text"), GetSQLValueString($tel, "text"), GetSQLValueString($news, "int") ); } else { $updateSQL = sprintf("UPDATE pcitalia_user SET username=%s, pass=aes_encrypt('%s','pcitalia'), tipo=%s, cognome=%s, nome=%s, riferimento=%s, via=%s, cap=%s, citta=%s, prov=%s, piva=%s, tel1=%s, news=%s WHERE userid=%s LIMIT 1", GetSQLValueString($username, "text"), $password, GetSQLValueString($tipo, "int"), GetSQLValueString($cognome, "text"), GetSQLValueString($nome, "text"), GetSQLValueString($referente, "text"), GetSQLValueString($via, "text"), GetSQLValueString($cap, "text"), GetSQLValueString($citta, "text"), GetSQLValueString($prov, "text"), GetSQLValueString($piva, "text"), GetSQLValueString($tel, "text"), GetSQLValueString($news, "int"), GetSQLValueString($userid, "int") ); } $result = mysql_query($updateSQL, $gestione) or die(mysql_error()); if (!$result) { return false; } else { return true; } } function logininfo($username, $password='') // check username and password with db // if yes, return true // else return false // Insert: // mysql_db_query("table","insert into userdata (user,password,other) values ('$user',aes_encrypt('$password','text_key'),'$other')"); // // Read: // select * from pcitalia_user where username='$username' and pass = AES_ENCRYPT('$password','pcitalia') // // select *,aes_decrypt(pass,'pcitalia') as password from pcitalia_user WHERE username='info@pcitalia.it' LIMIT 1 // // Modify: // UPDATE pcitalia_user SET password=aes_encrypt('federica','pcitalia') WHERE userid='1000' // mysql_db_query("table","Update userdata Set password=aes_encrypt('$password','text_key')") { global $gestione; global $database_gestione; global $_SESSION; global $utente_trovato; // connect to db mysql_select_db($database_gestione, $gestione); if (!$gestione) return false; $result = mysql_query("SELECT *,aes_decrypt(pass,'pcitalia') as password from pcitalia_user WHERE username='$username' LIMIT 1"); if (!$result) { $utente_trovato=false; return false; } if (mysql_num_rows($result)>0) { $utente_trovato=true; $datiutente = mysql_fetch_assoc($result); if ($datiutente['password']==$password) { $_SESSION['pcitalia_utente']['userid'] = $datiutente['userid']; $_SESSION['pcitalia_utente']['username'] = $datiutente['username']; $_SESSION['pcitalia_utente']['password'] = $datiutente['password']; $_SESSION['pcitalia_utente']['tipo'] = $datiutente['tipo']; $_SESSION['pcitalia_utente']['cognome'] = $datiutente['cognome']; $_SESSION['pcitalia_utente']['nome'] = $datiutente['nome']; $_SESSION['pcitalia_utente']['riferimento'] = $datiutente['riferimento']; $_SESSION['pcitalia_utente']['via'] = $datiutente['via']; $_SESSION['pcitalia_utente']['cap'] = $datiutente['cap']; $_SESSION['pcitalia_utente']['citta'] = $datiutente['citta']; $_SESSION['pcitalia_utente']['prov'] = $datiutente['prov']; $_SESSION['pcitalia_utente']['piva'] = $datiutente['piva']; $_SESSION['pcitalia_utente']['t1'] = $datiutente['t1']; $_SESSION['pcitalia_utente']['tel1'] = $datiutente['tel1']; $_SESSION['pcitalia_utente']['t2'] = $datiutente['t2']; $_SESSION['pcitalia_utente']['tel2'] = $datiutente['tel2']; $_SESSION['pcitalia_utente']['t3'] = $datiutente['tel3']; $_SESSION['pcitalia_utente']['tel3'] = $datiutente['tel3']; $_SESSION['pcitalia_utente']['news'] = $datiutente['news']; mysql_free_result($result); return true; } else { mysql_free_result($result); return false; } } else return false; } function check_moduleinfo($valore=1) // verifica se il modulo rientra tra quelli autorizzati o meno // per informatica { global $_SESSION; if (($valore==0) || (isset($_SESSION['pcitalia_utente']['tipo']) && $_SESSION['pcitalia_utente']['tipo']>=$valore)) return true; else return false; } ?>
  
  Database in Manutenzione


Si è veificato un errore durante l'accesso al database. Scusandoci per l'inconveniente, Vi invitiamo a riprovare fra qualche minuto.

Se il problema dovesse persistere siete pregati di contattare il webmaster[at]pcitalia.it