// EvalRemoteSnippet - Version 1.0 // Snippet by Henning Mersch // See http://www.henning-mersch.de/snippets.html // Open Source in terms of the GPLv2; see http://www.gnu.org/licenses/gpl.html // Retrieves and executes a remote (File / URL / SQL) snippet // // IF YOU DECIDE TO USE THIS: // You have to ultimately trust the remote provider of your snippets! // Please think about why and what could happen...DONT USE IF YOU ARE NOT SURE ! // // Please notice: the parameter separator is '_AND_' for the remote evaluated skript, but will be passed to that as usual. // example usage with a file/URL location: [ [EvalRemoteSnippet?snippetURL=http://my.host/test.snippet¶ms=a=b_AND_b=c] ] // example usage with a EtomiteDB: [ [EvalRemoteSnippet?dbUser=root&dbPWD=XXX&snippetname=LocLister&remoteParameters=locURL=foundCaches.loc]] // example usage with a SQLQuery: [ [EvalRemoteSnippet?db=MyDB&dbUser=root&dbPWD=XXX&selectCMD=SELECT content FROM XXX¶ms=locURL=foundCaches.loc]] //read parameters for remote snippet. // Seperator has to be '_AND_' ! $paramstring= isset($remoteParameters)?$remoteParameters:''; //DEBUG: $return .= "Given params:".$paramstring."n"; //snippet location per URL / file $snippetLocation = isset($snippetURL)?$snippetURL:''; //For DB Query: one of these has to be given - either etomiteDB query of free DB query $snipname = isset($snippetname)?$snippetname:'snippet'; $selectCMD = isset($select)? $select:''; //If DB Query, these habe to be given: $db = isset($db)?$db:'etomite_db'; $table = isset($table)?$table:'etomite_site_snippets'; $dbUser = isset($dbUser)?$dbUser:'myuser'; $dbPWD = isset($dbPWD)?$dbPWD:'mypasswd'; $host = isset($host)?$host:'localhost'; /////// processing code if($snippetLocation != '') { //load snippet from URL/file //DEBUG: $return .="Reading from URL: $snippetLocationn"; $snippet = base64_encode(file_get_contents($snippetLocation)); } else if ($snipname != '') { // load snippet from etomiteDB //DEBUG: $return .="Reading from EtomiteDB: $snipnamen"; $snippets = $etomite->dbExtQuery($host, $dbUser, $dbPWD, $db, "SELECT snippet FROM etomite_site_snippets WHERE name LIKE '$snipname'"); $snippetsElement = $etomite->fetchRow($snippets); $snippet = base64_encode($snippetsElement['snippet']); } else { //load snippet from other remote DB //DEBUG: $return .="Reading from DB: $selectCMDn"; $snippets = $etomite->dbExtQuery($host, $dbUser, $dbPWD, $db, $selectCMD); $snippetsElement = $etomite->fetchRow($snippets); $snippet = base64_encode($snippetsElement['snippet']); } //parse $paramstring same way like etomite's index.php $parameter = array(); $tempSnippetParams = str_replace("?", "", $paramstring); $tempSnippetParams = split("_AND_", $tempSnippetParams); for($x=0; $xevalSnippet($snippet,$parameter); //DEBUG: $return .= base64_decode($snippet); return $return;