Advertisement
Syntafin

Untitled

Feb 27th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.18 KB | None | 0 0
  1. <?php
  2. if( (isset($_GET['m'])) AND ($_GET['m'] == 'write') ) { ?>
  3. <form action="?a=news&amp;m=write&amp;do=send" method="post">
  4. <label for="title">News-Titel: </label>
  5. <input name="title" type="text"><br />
  6. <label for="text">News-Text:<br /></label>
  7. <textarea name="text" cols="60" rows="20"></textarea><br />
  8. <label for="cat">Kategorie: </label>
  9. <select name="cat">
  10.   <option value="News">News</option>
  11.   <option value="Wartung">Wartung</option>
  12.   <option value="Server">Server</option>
  13. </select><br />
  14. <label for="autor">Autor: </label>
  15. <select name="autor">
  16.   <option value="Choast">Choast</option>
  17.   <option value="ChaosChaot">ChaosChaot</option>
  18.   <option value="Nonomiya">Nonomiya</option>
  19.   <option value="LillyFee87">LillyFee87</option>
  20. </select><br />
  21. <input name="send" type="submit" class="button" value="News Eintragen">
  22. </form>
  23. <p><a href="?a=news">Zur &Uuml;bersicht</a></p>
  24. <?php
  25.     }else if(isset($_GET['m']) == 'edit') {
  26.     $id = $_GET['id'];
  27.     $sql = "SELECT * FROM news WHERE id='".mysql_real_escape_string($id)."'";
  28.     mysql_set_charset('utf8');
  29.     $entry = mysql_query($sql,$datenbank) or die(mysql_error());
  30.     $news = mysql_fetch_object($entry);
  31.     {
  32. ?>
  33. <form action="?a=news&amp;m=edit&amp;id=<?php echo $id ?>&amp;do=update" method="post">
  34. <label for="title">News-Titel: </label>
  35. <input name="title" type="text" value="<?php echo $news->title ?>"><br />
  36. <label for="text">News-Text:<br /></label>
  37. <textarea name="text" cols="60" rows="20"><?php echo $news->text ?></textarea><br />
  38. <label for="cat">Kategorie: </label>
  39. <input name="cat" type="text" value="<?php echo $news->cat ?>" readonly="true" /><br />
  40. <label for="autor">Autor: </label>
  41. <input name="autor" type="text" value="<?php echo $news->autor ?>" readonly="true" /><br />
  42. <input name="send" type="submit" class="button" value="News Updaten">
  43. </form>
  44. <p><a href="?a=news">Zur &Uuml;bersicht</a></p>
  45. <?php
  46. }
  47. }else{
  48. ?>
  49. <h4><a href="?a=news&amp;m=write">Neuen News Eintrag erstellen</a></h4>
  50. <table border="1">
  51.   <tr>
  52.     <th>Titel</th>
  53.     <th>Datum</th>
  54.     <th>Kategorie</th>
  55.     <th>Optionen</th>
  56.   </tr>
  57.   <?php
  58.     $sql = "SELECT * FROM news ORDER BY id DESC";
  59.     mysql_set_charset('utf8');
  60.     $entry = mysql_query($sql,$datenbank) or die(mysql_error());
  61.     while($news = mysql_fetch_object($entry))
  62.     { ?>
  63.         <tr>
  64.         <td><?php echo $news->title ?></td>
  65.         <td><?php echo $news->datum ?></td>
  66.         <td><?php echo $news->cat ?></td>
  67.         <td><a href="?a=news&amp;m=edit&amp;id=<?php echo $news->id ?>">Bearbeiten</a><br />
  68.           <a href="?a=news&amp;m=delete&amp;id=<?php echo $news->id ?>">L&ouml;schen</a></td>
  69.         </tr>
  70.     <?php } ?>
  71. </table>
  72. <p>&nbsp;</p>
  73. <p><a href="?a=overview">Zur&uuml;ck zur &Uuml;bersicht</a></p>
  74. <?php } ?>
  75. <?php
  76. if(isset($_GET['do']) AND 'send' == $_GET['do']) {
  77. $sqlk = "INSERT INTO news
  78.                    (
  79.                        title,
  80.                        text,
  81.                         cat,
  82.                        autor,
  83.                        datum
  84.                    )
  85.        VALUES
  86.                    (
  87.                        '".mysql_real_escape_string($_POST['title'])."',
  88.                        '".mysql_real_escape_string($_POST['text'])."',
  89.                         '".mysql_real_escape_string($_POST['cat'])."',
  90.                        '".mysql_real_escape_string($_POST['autor'])."',
  91.                        NOW()
  92.                    )";
  93. $qry = mysql_query($sqlk,$datenbank) or die(mysql_error());
  94.  
  95. $titel = $_POST['title'];
  96.  
  97. $HOST = "127.0.0.1"; //the ip of the bukkit server
  98. $password = "superdupergeheimespasswort";
  99. //Can't touch this:
  100. $sock = socket_create(AF_INET, SOCK_STREAM, 0)
  101. or die("error: could not create socket\n");
  102. $succ = socket_connect($sock, $HOST, 4445)
  103. or die("error: could not connect to host\n");
  104. //Authentification
  105. socket_write($sock, $command = md5($password)."<Password>", strlen($command) + 1)
  106. or die("error: failed to write to socket\n");
  107. //Begin custom code here.
  108. socket_write($sock, $command = "/Command/ExecuteConsoleCommand:broadcast Neuer News Eintrag: ".$titel.";", strlen($command) + 1) //Writing text/command we want to send to the server
  109. or die("error: failed to write to socket\n");
  110. }
  111. ?>
  112. <?php
  113. if(isset($_GET['do']) AND 'update' == $_GET['do']) {
  114. $id = $_GET['id'];
  115. $sql = "update news set title = '".mysql_real_escape_string($_POST['title'])."' , text = '".mysql_real_escape_string($_POST['text'])."' WHERE id='".mysql_real_escape_string($id)."'";
  116.  
  117. $qry = mysql_query($sql,$datenbank) or die(mysql_error());
  118.  
  119. $titel = $_POST['title'];
  120.  
  121. $HOST = "127.0.0.1"; //the ip of the bukkit server
  122. $password = "superdupergeheimespasswort";
  123. //Can't touch this:
  124. $sock = socket_create(AF_INET, SOCK_STREAM, 0)
  125. or die("error: could not create socket\n");
  126. $succ = socket_connect($sock, $HOST, 4445)
  127. or die("error: could not connect to host\n");
  128. //Authentification
  129. socket_write($sock, $command = md5($password)."<Password>", strlen($command) + 1)
  130. or die("error: failed to write to socket\n");
  131. //Begin custom code here.
  132. socket_write($sock, $command = "/Command/ExecuteConsoleCommand:broadcast News Beitrag wurde bearbeitet: ".$titel.";", strlen($command) + 1) //Writing text/command we want to send to the server
  133. or die("error: failed to write to socket\n");
  134. }
  135. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement