$row->idproc,
"name" => $row->name,
"requete" => $row->requete,
"comment" => $row->comment,
);
}
return $result;
} else {
return array();
}
}
/*
*
*/
function executeProc($procedure, $idProc,$tparams) {
global $msg,$dbh, $PMBuserid;
global $pmb_procedure_server_credentials,$pmb_procedure_server_address;
if (SESSrights & ADMINISTRATION_AUTH) {
$name = "";
$report = "";
if ($tparams) {
foreach ($tparams as $aparam=>$vparam) {
global $$aparam;
$$aparam = $vparam;
}
}
switch ($procedure) {
case INTERNAL:
$hp=new parameters($idProc,"procs");
$hp->get_final_query();
$code_sql=$hp->final_query;
$autorisations = $hp->proc->autorisations;
break;
case EXTERNAL:
$pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials);
if ($pmb_procedure_server_address && (count($pmb_procedure_server_credentials_exploded) == 2)) {
$aremote_procedure_client = new remote_procedure_client($pmb_procedure_server_address, trim($pmb_procedure_server_credentials_exploded[0]), trim($pmb_procedure_server_credentials_exploded[1]));
$procedure = $aremote_procedure_client->get_proc($idProc,"AP");
$the_procedure = $procedure["procedure"];
if ($procedure["error_message"]) {
$report = htmlentities($msg["remote_procedures_error_server"], ENT_QUOTES, $charset).":
".$procedure["error_message"]."";
$result = array(
"name" => $the_procedure->name,
"report" => $report
);
return $result;
} else if ($the_procedure->params && ($the_procedure->params != "NULL")) {
$sql = "CREATE TEMPORARY TABLE remote_proc LIKE procs";
mysql_query($sql, $dbh) or die(mysql_error());
$sql = "INSERT INTO remote_proc (idproc, name, requete, comment, autorisations, parameters, num_classement) VALUES (0, '".mysql_escape_string($the_procedure->name)."', '".mysql_escape_string($the_procedure->sql)."', '".mysql_escape_string($the_procedure->comment)."', '', '".mysql_escape_string($the_procedure->params)."', 0)";
mysql_query($sql, $dbh) or die(mysql_error());
$idproc = mysql_insert_id($dbh);
$hp=new parameters($idproc,"remote_proc");
$hp->get_final_query();
$the_procedure->sql = $hp->final_query;
$name = $the_procedure->name;
$code_sql = $the_procedure->sql;
$commentaire = $the_procedure->comment;
}
}
break;
}
$linetemp = explode(";", $code_sql);
if($autorisations)
$temp_autorisation = explode(" ", $autorisations);
$allow=false;
if ($temp_autorisation) {
foreach ($temp_autorisation as $userid) {
if ($userid == $PMBuserid)
$allow = true;
}
if (!$allow) {
$report = $msg["11"];
// throw new Exception($message, $code);
$result = array(
"name" => $name,
"report" => $report
);
return $result;
}
}
for ($i=0;$i: $valeur
";
if (explain_requete($valeur)) {
$res = @mysql_query($valeur, $dbh);
$report .= mysql_error();
$nbr_lignes = @mysql_num_rows($res);
$nbr_champs = @mysql_num_fields($res);
if($nbr_lignes) {
$report .= "";
for($i=0; $i < $nbr_champs; $i++) {
$fieldname = mysql_field_name($res, $i);
$report .= "${fieldname} | ";
}
for($i=0; $i < $nbr_lignes; $i++) {
$row = mysql_fetch_row($res);
$report .= "";
foreach($row as $dummykey=>$col) {
if(trim($col)=='') $col = ' ';
$report .= ''.$col.' | ';
}
$report .= "
";
}
$report .= "
";
$report .= "".$msg['admin_misc_lignes']." ".mysql_affected_rows($dbh)."";
} else {
$report .= "
".$msg['admin_misc_lignes']." ".mysql_affected_rows($dbh);
$err = mysql_error($dbh);
if ($err) $report .= "
$err";
$report .= "
";
}
} else {
// erreur explain_requete
$report .= $valeur."
".$msg["proc_param_explain_failed"]."
".$erreur_explain_rqt;
}
}
} // fin while
$result = array(
"name" => $name,
"report" => $report
);
return $result;
}
return array();
}
}
?>