Advertisement
Guest User

EasySystem V2

a guest
May 12th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.40 KB | None | 0 0
  1. <?php
  2.  
  3. $handle = mysql_connect("127.0.0.1","[username]","[password]");
  4. if (!$handle) {
  5.     die('Verbindung schlug fehl: ' . mysql_error());
  6. }
  7. mysql_select_db("2_server_9876",$handle) or die('Could not select database.');
  8.  
  9.  
  10. $columns = getColumns($_GET['table']);
  11.  
  12.  
  13. $projektbuchstarbe = substr(strtolower($_GET['projekt']), 0, 1);
  14.  
  15.  
  16.  
  17. echo "#define MAX_".strtoupper($_GET['projekt'])." [Hier Maximale Anzahl eintragen]";
  18. echo "<br><br><br>";
  19. echo "enum ".$projektbuchstarbe."enum<br>";
  20. echo "{<ul>";
  21. echo "bool:".$projektbuchstarbe."active,<br>";
  22. foreach($columns as $column){
  23.     if($column['name'] == "id") $column['name'] = "dbid";
  24.     if($column['type'] == "real") echo "Float:";
  25.     echo $projektbuchstarbe.htmlentities($column['name']);
  26.    
  27.     if($column['type'] == "string") echo "[".$column['len']."]";
  28.    
  29.     echo ",<br>";
  30. }
  31. echo "</ul>}<br>";
  32. echo "new ".$projektbuchstarbe."Info[MAX_".strtoupper($_GET['projekt'])."][".$projektbuchstarbe."enum];";
  33. echo "<br><br><br>";
  34.  
  35.  
  36. echo "stock Load".$_GET['projekt']."s()<br>";
  37. echo "{<ul>";
  38. echo "for(new i=0; i&lt;MAX_".strtoupper($_GET['projekt'])."; i++)<br>";
  39. echo "{<ul>";
  40. echo "Load".$_GET['projekt']."(i);";
  41. echo "</ul>}<br>";
  42. echo "return 1;";
  43. echo "</ul>}";
  44. echo "<br><br><br>";
  45.  
  46.  
  47.  
  48. echo "stock Load".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
  49. echo "{<ul>";
  50. echo "new query[128];<br>";
  51.  
  52.     echo 'format(query, 128, "SELECT * FROM '.$_GET['table'].' WHERE id = \'%d\'",'.strtolower($_GET['projekt']).'_id);<br>';
  53.     echo 'mysql_tquery(Handle, query, "OnLoad'.$_GET['projekt'].'", "");<br>';
  54.     echo 'return 1;';
  55. echo "</ul>}";
  56. echo "<br><br><br>";
  57.  
  58.  
  59. $return = "\"UPDATE `".$_GET['table']."` SET ";
  60. $return1 = "";
  61. $varcount = 0;
  62. foreach($columns as $column){
  63.     if($column['name'] != "id")
  64.     {
  65.         if($column['type'] == "string") $abc = "%s";
  66.         if($column['type'] == "int") $abc = "%d";
  67.         if($column['type'] == "real") $abc = "%f";
  68.         $varcount += $column['len'];
  69.         if($createid == 0)
  70.         {
  71.             $return .= "`".$column['name']."` = '".$abc."'";
  72.             $return1 .= $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe.htmlentities($column['name'])."]";
  73.         }
  74.         else
  75.         {
  76.             $return .= ", `".$column['name']."` = '".$abc."'";
  77.             $return1 .= ", ".$projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe.htmlentities($column['name'])."]";
  78.         }  
  79.         $createid = 1;
  80.     }
  81. }
  82. $return .= " WHERE id='%d'\"";
  83.  
  84.  
  85. echo "stock Save".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
  86. echo "{<ul>";
  87.     echo "new query[";
  88.     echo strlen($return)+$varcount;
  89.     echo "];<br>";
  90.     echo "format(".$return.",".$return1.", ".$projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe."dbid]);<br>";
  91.     echo "mysql_tquery(Handle, query, \"\", \"\");<br>";
  92.     echo 'return 1;';
  93. echo "</ul>}";
  94.  
  95.  
  96. echo "<br><br><br>";
  97. echo "forward OnLoad".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id);<br>";
  98. echo "public OnLoad".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
  99. echo "{<ul>";
  100.    
  101.    
  102.     echo $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe."dbid] = cache_get_field_content_int(0, \"id\", Handle);<br>";
  103.     foreach($columns as $column){
  104.         if($column['name'] != "id")
  105.         {
  106.             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>";
  107.             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);";
  108.             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>";
  109.         }
  110.     }  
  111.     echo "<br>return 1;";
  112. echo "</ul>}<br>";
  113.  
  114. echo "<br><br><br>";
  115.  
  116. $createid = 0;
  117. echo "stock Create".$_GET['projekt']."()<br>";
  118. echo "{<ul>";
  119.     echo "new query[128];<br>";
  120.     echo "new ".strtolower($_GET['projekt'])."_id = GetFree".$_GET['projekt']."ID();<br>";
  121.     echo 'format(query, 128, "INSERT INTO `'.$_GET['table'].'`(';
  122.    
  123.     foreach($columns as $column){
  124.         if($column['name'] != "id")
  125.         {
  126.             if($createid == 0) echo "`".$column['name']."`";
  127.             else echo ", `".$column['name']."`";
  128.             $createid = 1;
  129.         }
  130.     }  
  131.     echo ') VALUES (';
  132.     $createid = 0;
  133.     foreach($columns as $column){
  134.         if($column['name'] != "id")
  135.         {
  136.             if($column['type'] == "int")
  137.             {
  138.                 if($createid == 0) echo "'%d'";
  139.                 else echo ", '%d'";
  140.             }
  141.             elseif($column['type'] == "string")
  142.             {
  143.                 if($createid == 0) echo "'%s'";
  144.                 else echo ", '%s'";
  145.             }
  146.             elseif($column['type'] == "real")
  147.             {
  148.                 if($createid == 0) echo "'%f'";
  149.                 else echo ", '%f'";
  150.             }
  151.            
  152.             $createid = 1;
  153.         }
  154.     }
  155.    
  156.     echo ')",value);<br>';
  157.     echo 'mysql_tquery(Handle, query, "OnCreate'.$_GET['projekt'].'", "d", '.strtolower($_GET['projekt']).'_id);<br>';
  158.     echo "return 1;";
  159. echo "</ul>}<br>";
  160.  
  161.  
  162.  
  163.  
  164. echo "<br><br><br>";
  165. echo "stock GetFree".$_GET['projekt']."ID()<br>";
  166. echo "{<ul>";
  167.     echo "for(new i=0; i&lt;MAX_".strtoupper($_GET['projekt'])."; i++)<br>";
  168.     echo "{<ul>";
  169.         echo "if(".$projektbuchstarbe."Info[i][".$projektbuchstarbe."active] == true) continue;<br>";
  170.         echo "return i;";
  171.     echo "</ul>}<br>";
  172.     echo "return -1;";
  173. echo "</ul>}";
  174.  
  175. echo "<br><br><br>";
  176.  
  177. echo "forward OnCreate".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id);<br>";
  178. echo "public OnCreate".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id)<br>";
  179. echo "{<ul>";
  180.     echo $projektbuchstarbe."Info[".strtolower($_GET['projekt'])."_id][".$projektbuchstarbe."dbid] = cache_insert_id();<br>";
  181.     echo "Load".$_GET['projekt']."(".strtolower($_GET['projekt'])."_id);<br>";
  182.     echo "return 1;<br>";
  183. echo "</ul>}<br>";
  184.  
  185.  
  186. function getColumns($table)
  187. {
  188.     $res = array();
  189.     $result = mysql_query("SELECT * FROM ".$table);
  190.     $fields = mysql_num_fields($result);
  191.     for ($i=0; $i < $fields; $i++) {
  192.         $type  = mysql_field_type($result, $i);
  193.         $name  = mysql_field_name($result, $i);
  194.         $len   = mysql_field_len($result, $i);
  195.         $flags = mysql_field_flags($result, $i);
  196.         $res[$i]["type"] = $type;
  197.         $res[$i]["name"] = $name;
  198.         $res[$i]["len"] = $len;
  199.     }
  200.     mysql_free_result($result);
  201.     return $res;
  202. }
  203. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement