Good day, I have a problem with the script, that I can not create more than 99 rooms here are printed cu. php code, I hope that someone can help
they give me this eroos : the tabele 'chat0' alredy exzist ... so where are problem ? ...help.. and thanks
PHP Code:
<?php
error_reporting(0);
require_once"./includes/functions/gzip.php";
include('start.php');
include("config.php");
include("./includes/".$ver."/banned");
list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;
$nocache = rand(1000, 9999);
switch($ver)
{
case 'wml':
///////////////////////////////////////////////////////
//WML VERSION
///////////////////////////////////////////////////////
header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
//AUTH
$id = intval($_SESSION['id']);
$password = mysql_escape_string($_SESSION['password']);
$q = mysql_query("SELECT nickname FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
if(mysql_num_rows($q) == 0)
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
echo "<card title=\"ERROR\" ontimer=\"index.php?ver=wml\"><timer value=\"15\"/><p align=\"left\">\n";
echo "<small>Authorization Failed!<br/>\n";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
echo "</small>";
require_once "includes/functions/gzip_foot.php";
echo "</p></card></wml>";
ob_end_flush();
exit();
}
//END AUTH
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\">\n<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"index\" title=\"opcije\"><p align=\"left\">\n";
echo "<!-- Developed by martin suvalj -->\n";
$chat = file("chat.dat");
$logo = trim($chat[0]);
$message = trim($chat[1]);
if(!empty($logo)) echo "<img src=\"http://$logo\" alt=\"\" /><br/>\n";
if(!empty($message)) echo "$message<br/>\n";
///razglas
//razglas
$q = mysql_query("SELECT id,nickname,level,shoutbox,status,posts,time,ip,ua,security,fsize FROM `chat_users` WHERE `nickname` = '".$nickname."' AND `password` = '".md5($password)."' LIMIT 1;");
$user = mysql_fetch_array($q);
$uid = $user['id'];
$nickname = $user['nickname'];
$pass = $user['password'];
$ip = $user['ip'];
$ua = $user['ua'];
$kick = $user['kick'];
$moder = $user['moder'];
$reason = $user['reason'];
$name = $user['name'];
$site = $user['site'];
$sex = $user['sex'];
$from = $user['from'];
$mobile = $user['mobile'];
$email = $user['email'];
$birthday = $user['birthday'];
$about = $user['about'];
$posts = $user['posts'];
$lev = $user['level'];
$answers = $user['answers'];
$gbalans = $user['gbalans'];
$status = $user['status'];
$regdate = $user['regdate'];
$place = $user['place'];
$photo_type = $user['photo'];
$time = $user['time'];
$mood = $user['mood'];
$shoutbox= $user['message'];
echo "Room:<br/>\n";
echo "Obrati paznju na ime sobe, da soba sa takvim nazivom vec ne postoji i da ne krsi uslove koristenja chata<br/>\n";
echo "<br/>";
if(!isset($_POST['action']))
{
echo "ime sobe:<br/>\n";
echo "<input name=\"name$nocache\" maxlength=\"15\" title=\"name\"/><br/>\n";
echo "Position:<br/>\n";
echo "<input name=\"position$nocache\" format=\"*N\" size=\"2\" maxlength=\"2\" title=\"position\"/><br/>\n";
$type = '3';
echo "<anchor>[Kreiraj]<go href=\"create_my_room.php?nocache=$nocache&ver=wml&".SID."&mod=addroom\" method=\"post\">\n";
echo "<postfield name=\"name\" value=\"$(name$nocache)\"/>\n";
echo "<postfield name=\"position\" value=\"$(position$nocache)\"/>\n";
echo "<postfield name=\"action\" value=\"$(add$nocache)\"/>\n";
echo "</go></anchor><br/>\n";
}
else
{
$type = '3';
$mid = $id;
$name = trim(mysql_escape_string(htmlspecialchars($_POST['name'])));
$name = str_replace('$', '$$', $name);
if(empty($name))
{
echo "Niste unijeli ime sobe!<br/>\n";
break;
}
$position = intval($_POST['position']);
if($postion < 0) $postion = 0;
if($postion > 100) $postion = 100;
$type = intval($_POST['type']);
if($type < 0) $type = 0;
if($type > 2) $type = 0;
$q = mysql_query("SELECT `name` FROM `chat_rooms` WHERE `name` = '".$name."';");
if(mysql_affected_rows() != 0)
{
echo "Soba sa takvim imenom vec postoji.<br/>\n";
break;
}
$q = mysql_query("SELECT COUNT(*) FROM `chat_rooms`;");
$result = mysql_result($q, 0);
if($result > 25)
{
echo "Too many established rooms!<br/>\n";
break;
}
$sql = mysql_query("INSERT INTO `chat_rooms` VALUES(0, '".$name."', '".$position."', '".$name."', '".$type."', '".$mid."');");
$room = mysql_insert_id();
$sql = mysql_query("CREATE TABLE `chat".$room."`
(
`id` int(10) unsigned NOT NULL auto_increment,
`aid` int(11) NOT NULL default '0',
`nickname` tinytext NOT NULL,
`msg` text NOT NULL,
`to` int(11) NOT NULL default '0',
`time` tinytext NOT NULL,
`seconds` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;");
if($sql)
{
echo "Room successfully created!<br/>\n";
if($type == 3) echo "<a href=\"mroom.php?".SID."&ver=wml&rid=$room\">The room</a><br/>\n";
}
else
{
echo "Error.<br/>\n";
echo mysql_error();
}
}echo "<br />\n";
echo "<a href=\"rooms.php?".SID."&ver=wml\">Chat Sobe:</a><br/>\n";
echo "<a href=\"menu.php?".SID."&ver=wml&nocache=$nocache\">Livechat meni</a><br/>\n";
list($msec, $sec) = explode(chr(32), microtime());
echo "<small>[".round(($sec + $msec) - $headtime, 5)."]</small><br/>\n";
require_once "includes/functions/gzip_foot.php";
echo "</p></card></wml>";
ob_end_flush();
break;
case 'html':
///////////////////////////////////////////////////////
//HTML VERSION
///////////////////////////////////////////////////////
$my_title = "rom admin";
if(!isset($_COOKIE['theme'])) $_COOKIE['theme'] = 1;
include_once "themes/".intval($_COOKIE['theme'])."/index.php";
//AUTH
$id = intval($_SESSION['id']);
$password = mysql_escape_string($_SESSION['password']);
$q = mysql_query("SELECT nickname FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
if(mysql_num_rows($q) == 0)
{
echo "Authorization Failed!<br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
exit();
}
//END AUTH
$nik = mysql_result($q, 0);
$user = mysql_fetch_array($q);
$mid = $user['id'];
$nickname = $user['nickname'];
$pass = $user['password'];
$ip = $user['ip'];
$ua = $user['ua'];
$kick = $user['kick'];
$moder = $user['moder'];
$reason = $user['reason'];
$name = $user['name'];
$site = $user['site'];
$sex = $user['sex'];
$from = $user['from'];
$mobile = $user['mobile'];
$email = $user['email'];
$birthday = $user['birthday'];
$about = $user['about'];
$posts = $user['posts'];
$lev = $user['level'];
$answers = $user['answers'];
$gbalans = $user['gbalans'];
$status = $user['status'];
$regdate = $user['regdate'];
$place = $user['place'];
$photo_type = $user['photo'];
$time = $user['time'];
$mood = $user['mood'];
$shoutbox= $user['message'];
echo "<!-- Developed by martin suvalj -->\n";
$chat = file("chat.dat");
$logo = trim($chat[0]);
$message = trim($chat[1]);
if(!empty($logo)) echo "<img src=\"http://$logo\" alt=\"\" /><br/>\n";
if(!empty($message)) echo "$message<br/>\n";
if(!isset($_POST['action']))
{
echo "<div class=\"form\">\n";
echo "<form method=\"post\" action=\"create_my_room.php?nocache=$nocache&ver=html&".SID."&mod=addroom\">\n";
echo "napravi svoju sobu , budi siguran da ime sobe vec ne postoji!<br/>\n";
echo "Title:<br/>\n";
echo "<input name=\"name\" maxlength=\"15\" title=\"name\"/><br/>\n";
echo "pozicija:<br/>\n";
echo "<input name=\"position\" size=\"2\" maxlength=\"2\" title=\"position\"/><br/>\n";
$type = '3';
$mid = $id;
echo "</select><br/>\n";
echo "<input type=\"hidden\" name=\"action\" value=\"add\"/>\n";
echo "<input type=\"submit\" value=\"Create\"/></form></div><br/>\n";
}
else
{
$name = trim(mysql_escape_string(htmlspecialchars($_POST['name'])));
$name = str_replace('$', '$$', $name);
if(empty($name))
{
echo "Prazan naziv sobe!<br/>\n";
break;
}
$type = '3';
$mid = $id;
$position = intval($_POST['position']);
if($postion < 0) $postion = 0;
if($postion > 100) $postion = 100;
$type = intval($_POST['type']);
if($type < 0) $type = 0;
if($type > 12) $type = 0;
$q = mysql_query("SELECT `name` FROM `chat_rooms` WHERE `name` = '".$name."';");
if(mysql_affected_rows() != 0)
{
echo "Zao nam je naziv sobe sa takvim imenom vec postoji!<br/>\n";
break;
}
$q = mysql_query("SELECT COUNT(*) FROM `chat_rooms`;");
$result = mysql_result($q, 0);
if($result > 1000)
{
echo "Zao nam je trenutno ima Previse privatnih soba!<br/>\n";
break;
}
$sql = mysql_query("INSERT INTO `chat_rooms` VALUES('()', '".$name."', '".$position."', '".$name."', '".$type."', '".$mid."');");
$room = mysql_insert_id();
$sql = mysql_query("CREATE TABLE `chat".$room."`
(
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`aid` int(11) NOT NULL default '0',
`nickname` tinytext NOT NULL,
`msg` text NOT NULL,
`to` int(11) NOT NULL default '0',
`time` tinytext NOT NULL,
`seconds` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM ;");
if($sql)
{
echo "Soba uspijesno kreirana!<br/>\n";
if($type = 3) echo "<a href=\"room.php?".SID."&ver=html&rid=$room\">udji u sobu</a><br/>\n";
}
else
{
echo "Error. greska s bazama podataka (izvjestaj je dolje)<br/>\n";
echo mysql_error();
}
}
echo "<br />\n";
echo "<img src='ikone/line.jpg' alt='--'> <br/>\n";
echo " <img src='ikone/chat.gif' alt='chat'> <a href=\"rooms.php?".SID."&ver=html\">Chat Sobe:</a><br/>\n";
echo "<img src='ikone/calen.gif' alt='my'><a href=\"menu.php?".SID."&ver=html&nocache=$nocache\">LiveChat meni</a><br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
break;
}
?>
Comment