2-1 PHP Script Pack PHP 

Status
Not open for further replies.
Newbie Spellweaver
Joined
Apr 22, 2008
Messages
34
Reaction score
0
Whos Logged In?
PHP:
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("odinms", $con);

echo 'The following users are online:';
$result = mysql_query("SELECT name 
                         FROM accounts
                        WHERE loggedin=1");

while($row = mysql_fetch_array($result))
  {
  echo $row['name'] . " " . $row['online'];
  echo ", ";
  }

mysql_close($con);

?>

News System For Website

Display The News, Include This Somewhere (post.php)
PHP:
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("odinms", $con);

$result = mysql_query("SELECT * FROM news ORDER BY id DESC limit 15");



while($row = mysql_fetch_array($result))
  {
  echo "<br><b><font size='5' face='sans-serif'><span id='jiggle0' class='jc'>" . $row['title'] . "</span></b><hr></font>";
    echo "<font size='3' face='sans-serif'>" . $row['message'] . "</font><br>";
  }

  mysql_close($con);

?>
Post The News (put this somewhere)
PHP:
<form action="post.php" method="POST">
Title:<input type=text name=title maxlength="30" style=" font-size:.99em;border:2px inset pink;"><br>
Message:<textarea scrollbar=no name=message maxlength="300" rows="10" cols="50"style=" font-size:.99em;border:2px inset pink;"></textarea><br>
<input type="submit" value='Post Main' style=" font-size:.99em;border:2px inset pink;"></td></tr>
</form>

Post The News(post.php)
PHP:
<?php

$title = $_POST['title'];
$message = $_POST['message'];

$host['naam'] = 'localhost';
$host['gebruikersnaam'] = 'root';
$host['wachtwoord'] = 'root'; 
$host['databasenaam'] = 'odinms';

$db = mysql_connect($host['naam'], $host['gebruikersnaam'], $host['wachtwoord']) OR die ('Cant connect to the database');
mysql_select_db($host['databasenaam'], $db);

if($message == ""){
echo 'Enter a message mr.dum';
exit();
}elseif($title == ""){
echo 'You have to enter a title you stupid idiot!!';
exit();
}else{
	
$d = 'INSERT INTO news (title, message) VALUES ("'.$title.'", "'.$message.'")';
mysql_query($d) OR die (mysql_error());
echo 'Message Posted (normal)<a href="http://yoursite.com">Back</a>';
}
?>
News Database
Code:
DROP TABLE IF EXISTS `odinms`.`news`;
CREATE TABLE  `odinms`.`news` (
  `title` text character set latin1 NOT NULL,
  `message` text character set latin1 NOT NULL,
  `id` int(10) unsigned NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
 
Make the title : [RELEASE] 2-1 PHP Script Pack
please :)

But nice release :D
 
It shows the Game ID of whoever is online, this of course could pose a security threat.
How on earth can that pose as a security threat?

$result = mysql_query("SELECT * FROM news ORDER BY id DESC limit 15");

Should be,

$result = mysql_query("SELECT title, news FROM news ORDER BY id DESC limit 15");
 
Re: [RELEASE]2-1 PHP Script Pack

is anyone else using a database driven news system here?
I just made a new character name script, but I can't get it to work it uses a modified buy nx script I can't figure out what's rock, help please from someone who knows php, then ill release it

PHP:
          <?php
if (array_key_exists('reset', $_POST)) {
  include('config.php');
  $username = trim($_POST['username']);
  $password = trim($_POST['password']);
  $username = mysql_real_escape_string($username);
  $char = trim($_POST['char']);
  $nchar = trim($_POST['nchar']);
  $mesocheck = mysql_query('SELECT * FROM meso FROM characters');
  $result = mysql_query("SELECT meso, accountid FROM characters WHERE name = '$char' LIMIT 1");
  list($meso, $accountid) = mysql_fetch_row($result);

  $result = mysql_query("SELECT id, password, salt FROM accounts WHERE name = '$username' LIMIT 1");
  list($id, $realpass, $salt) = mysql_fetch_row($result);
  
  $sql = "SELECT * FROM accounts WHERE name = '$username'";
  $result = mysql_query($sql);
  $row = mysql_fetch_assoc($result);
  
if($realpass == hash('sha512',$password.$salt) && $accountid == $id && $meso >= 9999999) {
     mysql_query("UPDATE characters SET name = '$nchar' WHERE name = '$char' LIMIT 1");
     mysql_query("UPDATE characters SET meso = meso - 9999999 WHERE name = '$char' LIMIT 1");
     echo "yay you changed your name";
} else
     echo "You didn't put he right info -_-";    }
  else {
    $message[] = '';
    }
?>
            

              <?php
if (isset($message)) {
  echo '';
  foreach ($message as $item) {
    echo "$item";
    }
  echo '';
  }
?>
            
              <form id="form1" name="form1" method="post" action="">
 
   
     
   <h2>Username:</h>
                   <input id="username" type="text" name="username" maxlength="12" / style=" font-size:.80em;border:2px inset pink;">
   <h2>Password :</h>
           <input id="password" style=" font-size:.80em;border:2px inset pink;" type="password" name="password" maxlength="20" />
<h2>Character Name:</h>
<input id="char" type="text" name="char" style=" font-size:.80em;border:2px inset pink;" maxlength="12" />
<h2>New Character Name</h><input id="nchar" type="text" name="char" style=" font-size:.80em;border:2px inset pink;" maxlength="12" />
<input id="reset" name="reset" type="submit" style=" font-size:.80em;border:2px inset pink;" value="Buy 30k NX!" />
                 
              </form>
</div> </center>
 
Re: [RELEASE]2-1 PHP Script Pack

Maybe instead of showing the user's Id of who's on have it show the character name instead.
 
Status
Not open for further replies.
Back