Source for file rpc.php
Documentation is available at rpc.php
* File RPC per le chiamate AJAX della scheda.
* Questo file viene chiamato da funzioni javascript per eseguire le normali operazioni
* sulla tabella, come inserimento, modifica, cancellazione e selezione dei record.
* Se esiste una chimata post viene incluso il file {@link func.rpc_query.php}
* con le funzioni di interazione con il database
* @author Mario Marcello Verona <marcelloverona@gmail.com>
* @copyright 2007 Mario Marcello Verona
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
require ("./inc/conn.php");
require ("./inc/func.comuni.php");
require ("./inc/func.frontend.php");
require ("./inc/func.browser_detection.php");
$info_browser= implode(" ",browser_detection());
// $fp=fopen("test.txt","w");
require_once("./inc/func.rpc_query.php");
// UPDATE--------------------------------
if($_GET['post']== 'update'){
// INSERISCO IL LOG E PRENDO L'ID
$last_id_log= rpc_log('update',$_GET['action'],$_SESSION['user']['uid'],$_SESSION['gid'],$_POST['pk'],true,'',$sql_update,$info_browser);
// se KO cancella la riga di log
vmsql_query("DELETE FROM {$db1['frontend']}.log WHERE id_log=". intval($last_id_log),$link);
// INSERT--------------------------------
else if($_GET['post']== 'new'){
// manda l'id appena inserito
rpc_log('insert',$_GET['action'],$_SESSION['user']['uid'],$_SESSION['gid'],$last_id,true,'',$sql_insert,$info_browser);
// DELETE--------------------------------
else if($_GET['post']== 'delete'){
rpc_log('delete',$_GET['action'],$_SESSION['user']['uid'],$_SESSION['gid'],$_POST['pk'],true,'','',$info_browser);
$result= vmsql_try($sql_delete,$link,false,true);
// eliminazione link e allegati se ci sono
// SEARCH--------------------------------
else if($_GET['post']== 'cerca'){
echo (is_array($risultati_ricerca)) ? implode("|",$risultati_ricerca) : "";
// DUPLICA --------------------------------
else if($_GET['post']== 'duplica'){
list ($campo_id,$valore_id)= each($_POST['pk']);
rpc_log('duplicazione',$_GET['action'],$_SESSION['user']['uid'],$_SESSION['gid'],$last_id,true,'','DUPLICAZIONE '. $_GET['action']. ":". $valore_id,$info_browser);
echo $risultati_duplicazione;
require ("./inc/func.xmlize.php");
$tabella = $_GET['action'];
//aggiungi l'ID all'order by
$orderby_doppio= $orderby. ", $PK ASC ";
$campo_orderby = str_replace(array(" ASC"," DESC"),"",$orderby);
$operatore_orderby = ereg(' DESC',$orderby) ? " > " : " < ";
// CASO RISULTATO DI RICERCA-------------------------------------------------------
// SE c'è l'id in GET prendi calcola a che punto dell'elenco si è arrivati
if(isset ($_GET['id']) && intval($_GET['id'])> 0){
// Prendi il moe del campo orderby ed il vaolre relativo all'id
$sql_calcola_sub = "SELECT s.$campo_orderby
FROM $tabella s WHERE s.". $PK. "='". $_GET['id']. "'";
$sql_calcola = "SELECT count(*) FROM ". $_GET['action']. " t
WHERE t.$campo_orderby $operatore_orderby ($sql_calcola_sub) OR t.$campo_orderby IS NULL";
$offset= (int) $_GET['c'];
$XML = xmlize("SELECT * FROM $tabella ORDER BY $orderby_doppio ". limit_sintax(1,$offset),null,true,$offset,$tot_records);
elseif($_GET['c']== 'all'){
$XML = xmlize("SELECT * FROM $tabella ORDER BY $orderby_doppio ",null,true,false,$tot_records);
header("Content-Type: text/xml");
|