Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $handle = mysql_connect("127.0.0.1","[username]","[password]");
- if (!$handle) {
- die('Verbindung schlug fehl: ' . mysql_error());
- }
- mysql_select_db("2_server_9876",$handle) or die('Could not select database.');
- $columns = getColumns($_GET['table']);
- $projektbuchstarbe = substr(strtolower($_GET['projekt']), 0, 1);
- echo "#define MAX_".strtoupper($_GET['projekt'])." [Hier Maximale Anzahl eintragen]";
- echo "<br><br><br>";
- echo "enum ".$projektbuchstarbe."enum<br>";
- echo "{<ul>";
- echo "bool:".$projektbuchstarbe."active,<br>";
- foreach($columns as $column){
- if($column['name'] == "id") $column['name'] = "dbid";
- if($column['type'] == "real") echo "Float:";
- echo $projektbuchstarbe.htmlentities($column['name']);
- if($column['type'] == "string") echo "[".$column['len']."]";
- echo ",<br>";
- }
- echo "</ul>}<br>";
- echo "new ".$projektbuchstarbe."Info[MAX_".strtoupper($_GET['projekt'])."][".$projektbuchstarbe."enum];";
- echo "<br><br><br>";
- echo "stock Load".$_GET['projekt']."s()<br>";
- echo "{<ul>";
- echo "for(new i=0; i<MAX_".strtoupper($_GET['projekt'])."; i++)<br>";
- echo "{<ul>";
- echo "Load".$_GET['projekt']."(i);";
- echo "</ul>}<br>";
- echo "return 1;";
- echo "</ul>}";
- echo "<br><br><br>";
- echo "stock Load".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
- echo "{<ul>";
- echo "new query[128];<br>";
- echo 'format(query, 128, "SELECT * FROM '.$_GET['table'].' WHERE id = \'%d\'",'.strtolower($_GET['projekt']).'_id);<br>';
- echo 'mysql_tquery(Handle, query, "OnLoad'.$_GET['projekt'].'", "");<br>';
- echo 'return 1;';
- echo "</ul>}";
- echo "<br><br><br>";
- $return = "\"UPDATE `".$_GET['table']."` SET ";
- $return1 = "";
- $varcount = 0;
- foreach($columns as $column){
- if($column['name'] != "id")
- {
- if($column['type'] == "string") $abc = "%s";
- if($column['type'] == "int") $abc = "%d";
- if($column['type'] == "real") $abc = "%f";
- $varcount += $column['len'];
- if($createid == 0)
- {
- $return .= "`".$column['name']."` = '".$abc."'";
- $return1 .= $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe.htmlentities($column['name'])."]";
- }
- else
- {
- $return .= ", `".$column['name']."` = '".$abc."'";
- $return1 .= ", ".$projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe.htmlentities($column['name'])."]";
- }
- $createid = 1;
- }
- }
- $return .= " WHERE id='%d'\"";
- echo "stock Save".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
- echo "{<ul>";
- echo "new query[";
- echo strlen($return)+$varcount;
- echo "];<br>";
- echo "format(".$return.",".$return1.", ".$projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe."dbid]);<br>";
- echo "mysql_tquery(Handle, query, \"\", \"\");<br>";
- echo 'return 1;';
- echo "</ul>}";
- echo "<br><br><br>";
- echo "forward OnLoad".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id);<br>";
- echo "public OnLoad".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
- echo "{<ul>";
- echo $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe."dbid] = cache_get_field_content_int(0, \"id\", Handle);<br>";
- foreach($columns as $column){
- if($column['name'] != "id")
- {
- if($column['type'] == "string") echo "cache_get_field_content(0,\"".htmlentities($column['name'])."\",".$projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe.htmlentities($column['name'])."],Handle,".$column['len'].");<br>";
- if($column['type'] == "real") echo $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe.htmlentities($column['name'])."] = cache_get_field_content_float(0,\"".htmlentities($column['name'])."\",Handle);";
- if($column['type'] == "int") echo $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe.htmlentities($column['name'])."] = cache_get_field_content_int(0, \"".htmlentities($column['name'])."\", Handle);<br>";
- }
- }
- echo "<br>return 1;";
- echo "</ul>}<br>";
- echo "<br><br><br>";
- $createid = 0;
- echo "stock Create".$_GET['projekt']."()<br>";
- echo "{<ul>";
- echo "new query[128];<br>";
- echo "new ".strtolower($_GET['projekt'])."_id = GetFree".$_GET['projekt']."ID();<br>";
- echo 'format(query, 128, "INSERT INTO `'.$_GET['table'].'`(';
- foreach($columns as $column){
- if($column['name'] != "id")
- {
- if($createid == 0) echo "`".$column['name']."`";
- else echo ", `".$column['name']."`";
- $createid = 1;
- }
- }
- echo ') VALUES (';
- $createid = 0;
- foreach($columns as $column){
- if($column['name'] != "id")
- {
- if($column['type'] == "int")
- {
- if($createid == 0) echo "'%d'";
- else echo ", '%d'";
- }
- elseif($column['type'] == "string")
- {
- if($createid == 0) echo "'%s'";
- else echo ", '%s'";
- }
- elseif($column['type'] == "real")
- {
- if($createid == 0) echo "'%f'";
- else echo ", '%f'";
- }
- $createid = 1;
- }
- }
- echo ')",value);<br>';
- echo 'mysql_tquery(Handle, query, "OnCreate'.$_GET['projekt'].'", "d", '.strtolower($_GET['projekt']).'_id);<br>';
- echo "return 1;";
- echo "</ul>}<br>";
- echo "<br><br><br>";
- echo "stock GetFree".$_GET['projekt']."ID()<br>";
- echo "{<ul>";
- echo "for(new i=0; i<MAX_".strtoupper($_GET['projekt'])."; i++)<br>";
- echo "{<ul>";
- echo "if(".$projektbuchstarbe."Info[i][".$projektbuchstarbe."active] == true) continue;<br>";
- echo "return i;";
- echo "</ul>}<br>";
- echo "return -1;";
- echo "</ul>}";
- echo "<br><br><br>";
- echo "forward OnCreate".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id);<br>";
- echo "public OnCreate".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
- echo "{<ul>";
- echo $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe."dbid] = cache_insert_id();<br>";
- echo "Load".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id);<br>";
- echo "return 1;<br>";
- echo "</ul>}<br>";
- function getColumns($table)
- {
- $res = array();
- $result = mysql_query("SELECT * FROM ".$table);
- $fields = mysql_num_fields($result);
- for ($i=0; $i < $fields; $i++) {
- $type = mysql_field_type($result, $i);
- $name = mysql_field_name($result, $i);
- $len = mysql_field_len($result, $i);
- $flags = mysql_field_flags($result, $i);
- $res[$i]["type"] = $type;
- $res[$i]["name"] = $name;
- $res[$i]["len"] = $len;
- }
- mysql_free_result($result);
- return $res;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement