"SELECT", "PNA" => 'ACTION', "PEA" => 'ACTION', "PES" => "SELECT", "PBS" => "SELECT", "PBA" => 'ACTION'); $testable_types = array("PNS" => true, "PNA" => false, "PEA" => false, "PES" => true, "PBS" => true, "PBA" => false); $type_titles = array("PNS" => "remote_procedures_catalog_caddienotice_select", "PNA" => "remote_procedures_catalog_caddienotice_action", "PEA" => "remote_procedures_catalog_caddieexpl_action", "PES" => "remote_procedures_catalog_caddieexpl_select", "PBS" => "remote_procedures_catalog_caddiebull_select", "PBA" => "remote_procedures_catalog_caddiebull_action"); function show_remote_procs($type) { global $pmb_procedure_server_credentials, $pmb_procedure_server_address; global $msg; global $charset; $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])); $procedures = $aremote_procedure_client->get_procs($type); if ($procedures) { global $testable_types, $type_titles; if ($procedures->error_information->error_code) { $buf_contenu=$msg["remote_procedures_error_server"].":
".$procedures->error_information->error_string.""; print $buf_contenu; } else if (isset($procedures->elements)){ $current_set=""; foreach ($procedures->elements as $aprocedure) { if ($aprocedure->current_attached_set != $current_set) { $parity=0; $current_set = $aprocedure->current_attached_set; $buf_contenu .= ''.htmlentities($current_set, ENT_QUOTES, $charset).''; } if ($parity % 2) {$pair_impair = "even"; } else {$pair_impair = "odd";} $parity += 1; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./catalog.php?categ=caddie&sub=gestion&quoi=remote_procs&action=view_remote&id=$aprocedure->id&remote_type=$type';\" "; $buf_contenu.="\n ".($testable_types[$type] ? "id&remote_type=$type'\" />" : "")." ".($aprocedure->untested ? "[".$msg["remote_procedures_procedure_non_validated"]."]  " : '')."$aprocedure->name
$aprocedure->comment  "; $buf_contenu.="id&remote_type=$type'\" /> "; } $title = $msg[$type_titles[$type]]; $buf_contenu="

".$title."

"."".$buf_contenu."

"; print $buf_contenu; } else { $title = $msg[$type_titles[$type]]; $buf_contenu="

".$title."

".$msg[remote_procedures_no_procs]."

"; print $buf_contenu; } } } } function show_procs() { show_remote_procs("PNS"); show_remote_procs("PNA"); show_remote_procs("PES"); show_remote_procs("PEA"); show_remote_procs("PBS"); show_remote_procs("PBA"); } function display_remote_proc($id) { global $pmb_procedure_server_credentials, $pmb_procedure_server_address; global $cart_proc_view_remote; global $type_list; global $msg; global $remote_type; $pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials); $the_procedure = 0; 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($id,$remote_type); if ($procedure["error_message"]) { $buf_contenu=htmlentities($msg["remote_procedures_error_server"], ENT_QUOTES, $charset).":
".$procedure["error_message"].""; print $buf_contenu; return; } $the_procedure = $procedure["procedure"]; } if (!$the_procedure) { echo htmlentities($msg["remote_procedures_error_client"],ENT_QUOTES, $charset); return; } global $msg; global $admin_proc_form; global $charset; global $allowed_proc_types; if (!in_array($the_procedure->type, $allowed_proc_types)) { echo htmlentities($msg["remote_procedures_circ_nocatalogproc"],ENT_QUOTES, $charset); return; } $cart_proc_view_remote = str_replace('!!id!!', $id, $cart_proc_view_remote); $cart_proc_view_remote = str_replace('!!form_title!!', htmlentities($msg["remote_procedures_details"],ENT_QUOTES, $charset), $cart_proc_view_remote); $additional_information = $the_procedure->untested ? $msg["remote_procedures_procedure_non_validated_additional_information"] : ""; $cart_proc_view_remote = str_replace('!!additional_information!!', htmlentities($additional_information,ENT_QUOTES, $charset), $cart_proc_view_remote); $cart_proc_view_remote = str_replace('!!name!!', htmlentities($the_procedure->name,ENT_QUOTES, $charset), $cart_proc_view_remote); $cart_proc_view_remote = str_replace('!!name_suppr!!', htmlentities(addslashes($the_procedure->name),ENT_QUOTES, $charset), $cart_proc_view_remote); $cart_proc_view_remote = str_replace('!!ptype!!', htmlentities(($the_procedure->type == "PEMPS" ? $msg["caddie_procs_type_SELECT"] : $msg["caddie_procs_type_ACTION"]),ENT_QUOTES, $charset), $cart_proc_view_remote); $cart_proc_view_remote = str_replace('!!code!!', htmlentities($the_procedure->sql,ENT_QUOTES, $charset), $cart_proc_view_remote); $cart_proc_view_remote = str_replace('!!comment!!', htmlentities($the_procedure->comment,ENT_QUOTES, $charset), $cart_proc_view_remote); $parameters = $the_procedure->params; $parameters = $aremote_procedure_client->parse_parameters($parameters); // highlight_string(print_r($parameters, true)); if ($parameters) { $cart_proc_view_remote = str_replace('!!parameters_title!!', "", $cart_proc_view_remote); $parameters_display = ''; $parity = 0; foreach($parameters as $parametername => $parameter) { $pair_impair = $parity++ % 2 ? "even" : "odd"; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" "; $parameters_display .= ''; $parameters_display .= ''; $parameters_display .= ''; $parameters_display .= ''; switch ($parameter["type"]["value"]) { case "query_list": $parameters_display .= ''; break; case "text": $parameters_display .= ''; break; case "list": $parameters_display .= ''; break; case "date_box": $parameters_display .= ''; break; case "selector": $parameters_display .= ''; break; case "file_box": $parameters_display .= ''; break; default: break; } $parameters_display .= ''; } $parameters_display .= '
'.htmlentities($msg["remote_procedures_procedure_parameters_name"],ENT_QUOTES, $charset).''.htmlentities($msg["remote_procedures_procedure_parameters_title"],ENT_QUOTES, $charset).''.htmlentities($msg["remote_procedures_procedure_parameters_type"],ENT_QUOTES, $charset).''.htmlentities($msg["remote_procedures_procedure_parameters"],ENT_QUOTES, $charset).'
'.htmlentities($parametername,ENT_QUOTES, $charset).''.htmlentities($parameter["title"]['value'],ENT_QUOTES, $charset).''.htmlentities($type_list[$parameter["type"]["value"]],ENT_QUOTES, $charset).'
  • '.htmlentities($msg["procs_options_requete"], ENT_QUOTES, $charset).': '.htmlentities($parameter["options"]["QUERY"][0]["value"],ENT_QUOTES, $charset).'
  • '.htmlentities($msg["procs_options_liste_multi"], ENT_QUOTES, $charset).': '.($parameter["options"]["MULTIPLE"][0]["value"] == "yes" ? htmlentities($msg["40"], ENT_QUOTES, $charset) : htmlentities($msg["39"], ENT_QUOTES, $charset)).'
  • '.htmlentities($msg["procs_options_text_taille"], ENT_QUOTES, $charset).': '.htmlentities($parameter["options"]["SIZE"][0]["value"],ENT_QUOTES, $charset).'
  • '.htmlentities($msg["procs_options_text_max"], ENT_QUOTES, $charset).': '.($parameter["options"]["MAXSIZE"][0]["value"]).'
    '; $parameters_display .= '
  • '.htmlentities($msg["procs_options_liste_multi"], ENT_QUOTES, $charset).': '.($parameter["options"]["MULTIPLE"][0]["value"] == "yes" ? htmlentities($msg["40"], ENT_QUOTES, $charset) : htmlentities($msg["39"], ENT_QUOTES, $charset)).'
  • '; $parameters_display .= '
  • '.htmlentities($msg["procs_options_choix_vide"], ENT_QUOTES, $charset).': '.(htmlentities($parameter["options"]["UNSELECT_ITEM"][0]["value"],ENT_QUOTES, $charset)).' ('.htmlentities($parameter["options"]["UNSELECT_ITEM"][0]["VALUE"],ENT_QUOTES, $charset).')
  • '; $choix=array(); foreach($parameter["options"]["ITEMS"][0]["ITEM"] as $achoix) { $choix[] = $achoix["value"]." (".$achoix["VALUE"].")"; } $parameters_display .= '
  • '.htmlentities($msg["procs_options_liste_options"], ENT_QUOTES, $charset).': '.(htmlentities(implode("; ", $choix),ENT_QUOTES, $charset)).'
  • '; $parameters_display .= '


    '; $parameters_display .= '
  • '.htmlentities($msg["include_option_methode"], ENT_QUOTES, $charset).': '.($parameter["options"]["METHOD"][0]["value"] == "1" ? $msg['parperso_include_option_selectors_id'] : $msg['parperso_include_option_selectors_label']).'
  • '; $id_captions=array($msg['133'], $msg['134'], $msg['135'], $msg['136'], $msg['137'], $msg['333'], $msg['indexint_menu']); $parameters_display .= '
  • '.htmlentities($msg["include_option_type_donnees"], ENT_QUOTES, $charset).': '.(htmlentities($id_captions[$parameter["options"]["DATA_TYPE"][0]["value"]], ENT_QUOTES, $charset)).'
  • '; $parameters_display .= '
    '; $parameters_display .= '
  • '.htmlentities($msg["include_option_methode"], ENT_QUOTES, $charset).': '.($parameter["options"]["METHOD"][0]["value"] == "1" ? htmlentities($msg["57"], ENT_QUOTES, $charset) : htmlentities($msg["include_option_table"], ENT_QUOTES, $charset)).'
  • '; $parameters_display .= '
  • '.htmlentities($msg["include_option_nom_table"], ENT_QUOTES, $charset).': '.(htmlentities($parameter["options"]["TEMP_TABLE_NAME"][0]["value"],ENT_QUOTES, $charset)).'
  • '; $parameters_display .= '
  • '.htmlentities($msg["include_option_type_donnees"], ENT_QUOTES, $charset).': '.($parameter["options"]["DATA_TYPE"][0]["value"] == "1" ? "Chaine" : "Entier").'
  • '; $parameters_display .= '
'; $cart_proc_view_remote = str_replace('!!parameters_content!!', $parameters_display, $cart_proc_view_remote); } $cart_proc_view_remote = str_replace('!!parameters_title!!', "", $cart_proc_view_remote); $cart_proc_view_remote = str_replace('!!parameters_content!!', "", $cart_proc_view_remote); print $cart_proc_view_remote; } switch($action) { case 'view_remote': if ($id) { display_remote_proc($id); } break; case 'import_remote': if ($id) { if($do_import) { $pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials); $the_procedure = 0; 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($id,$remote_type); if ($procedure["error_message"]) { $buf_contenu=htmlentities($msg["remote_procedures_error_server"], ENT_QUOTES, $charset).":
".$procedure["error_message"].""; print $buf_contenu; return; } $the_procedure = $procedure["procedure"]; } if (!$the_procedure) { echo htmlentities($msg["remote_procedures_error_client"],ENT_QUOTES, $charset); break; } global $allowed_proc_types; if (!in_array($the_procedure->type, $allowed_proc_types)) { echo htmlentities($msg["remote_procedures_circ_nocatalogproc"],ENT_QUOTES, $charset); return; } if (is_array($userautorisation)) $autorisations=implode(" ",$userautorisation); else $autorisations=''; if ($imported_name) $the_procedure->name = $imported_name; else $the_procedure->name = mysql_escape_string($the_procedure->name); if ($imported_comment) $the_procedure->comment = $imported_comment; else $the_procedure->comment = mysql_escape_string($the_procedure->comment); $parameters=$the_procedure->params; //mise à jour de l'encodage de l'entête if($charset == 'utf-8') { $parameters = str_replace('', '', $parameters) ; } global $types_selectaction; $type = $types_selectaction[$the_procedure->type]; $sql = "INSERT INTO caddie_procs (type, name, requete, comment, autorisations, parameters) VALUES ('".$type."', '".($the_procedure->name)."', '".mysql_escape_string($the_procedure->sql)."', '".$the_procedure->comment."', '".mysql_escape_string($autorisations)."', '".mysql_escape_string($parameters)."')"; $res = mysql_query($sql, $dbh); show_procs($dbh); } else { $pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials); $the_procedure = 0; 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($id,$remote_type); if ($procedure["error_message"]) { $buf_contenu=htmlentities($msg["remote_procedures_error_server"], ENT_QUOTES, $charset).":
".$procedure["error_message"].""; print $buf_contenu; return; } $the_procedure = $procedure["procedure"]; } if (!$the_procedure) { echo htmlentities($msg["remote_procedures_error_client"],ENT_QUOTES, $charset); break; } global $allowed_proc_types; if (!in_array($the_procedure->type, $allowed_proc_types)) { echo htmlentities($msg["remote_procedures_circ_nocatalogproc"],ENT_QUOTES, $charset); return; } //Regardons si on a déjà une procédure avec ce nom là dans la base de donnée $type = $types_selectaction[$the_procedure->type]; $sql_test = "SELECT COUNT(*) FROM caddie_procs WHERE type ='".$type."' AND name='".addslashes($the_procedure->name)."'"; $count = mysql_result(mysql_query($sql_test), 0, 0); if ($count) { print "
$msg[remote_procedures_import_remote_already_exists_caution]
".$msg["remote_procedures_import_remote_already_exists"]."


"; } $form = "
"; $form .= "

>".$msg["remote_procedures_import_remote"]."

"; $form .= "
"; $form .= ''.$msg["remote_procedures_procedure_name"].':


'; $form .= ''.$msg["caddie_procs_type"].':
'.htmlentities((in_array($the_procedure->type, array('PNS', 'PES', 'PEMPS', 'PBS')) ? $msg["caddie_procs_type_SELECT"] : $msg["caddie_procs_type_ACTION"]), ENT_QUOTES, $charset)."

"; $form .= ''.$msg["remote_procedures_procedure_comment"].':


'; $requete_users = "SELECT userid, username FROM users order by username "; $res_users = mysql_query($requete_users, $dbh); $all_users=array(); while (list($all_userid,$all_username)=mysql_fetch_row($res_users)) { $all_users[]=array($all_userid,$all_username); } foreach($all_users as $a_user) { $id_check="auto_".$a_user[0]; if($id_check_list)$id_check_list.='|'; $id_check_list.=$id_check; $autorisations_users.="  "; } $autorisations_users.=""; $form .= "
"; $form .= $autorisations_users; $form .= '
'; $form .= " "; $form .= " "; $form .= '
'; print $form; } } break; case 'execute_remote': if (!$id) break; $pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials); $the_procedure = 0; 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($id,$remote_type); if ($procedure["error_message"]) { $buf_contenu=htmlentities($msg["remote_procedures_error_server"], ENT_QUOTES, $charset).":
".$procedure["error_message"].""; print $buf_contenu; return; } $the_procedure = $procedure["procedure"]; } if (!$the_procedure) { echo htmlentities($msg["remote_procedures_error_client"],ENT_QUOTES, $charset); break; } global $allowed_proc_types; if (!in_array($the_procedure->type, $allowed_proc_types)) { echo htmlentities($msg["remote_procedures_circ_nocatalogproc"],ENT_QUOTES, $charset); return; } global $testable_types; if (!in_array($the_procedure->type, $testable_types)) { echo htmlentities($msg["remote_procedures_catalog_noSELECT"],ENT_QUOTES, $charset); break; } if ($the_procedure->params && ($the_procedure->params != "NULL")) { // $sql = "DROP TABLE IF EXISTS remote_proc"; // mysql_query($sql, $dbh) or die(mysql_error()); $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"); if (preg_match_all("|!!(.*)!!|U",$hp->proc->requete,$query_parameters)) $hp->gen_form("catalog.php?categ=caddie&sub=gestion&quoi=remote_procs&action=final_remote&id=$id"); else echo ""; } else echo ""; break; case 'final_remote': if (!$id) break; $pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials); $the_procedure = 0; 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($id); if ($procedure["error_message"]) { $buf_contenu=htmlentities($msg["remote_procedures_error_server"], ENT_QUOTES, $charset).":
".$procedure["error_message"].""; print $buf_contenu; return; } $the_procedure = $procedure["procedure"]; } if (!$the_procedure) { echo htmlentities($msg["remote_procedures_error_client"],ENT_QUOTES, $charset); break; } global $allowed_proc_types; if (!in_array($the_procedure->type, $allowed_proc_types)) { echo htmlentities($msg["remote_procedures_circ_nocatalogproc"],ENT_QUOTES, $charset); return; } global $testable_types; if (!in_array($the_procedure->type, $testable_types)) { echo htmlentities($msg["remote_procedures_catalog_noSELECT"],ENT_QUOTES, $charset); break; } $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"); if (preg_match_all("|!!(.*)!!|U",$hp->proc->requete,$query_parameters)) { $hp->get_final_query(); $the_procedure->sql = $hp->final_query; } $execute_external = true; $execute_external_procedure = $the_procedure; include("./catalog/caddie/gestion/execute.inc.php"); break; default: if (!$pmb_procedure_server_address) { echo $msg["remote_procedures_error_noaddress"]; break; } show_procs(); break; } ?>