Hello, first.. sorrry my bad english..
But, i made a good mod... Whit that mod you can add in your game admin panel, tutorial to every page...
create file staff_tutorial.php
<?php
include "sglobals.php";
if($ir['user_level'] > 2)
{
die("403");
}
//This contains city stuffs
switch($_GET['action'])
{
case "addtutorial": addtutorial(); break;
case "edittutorial": edittutorial(); break;
case "deltutorial": deltutorial(); break;
default: print "scripti vale kasutamine."; break;
}
function addtutorial()
{
global $db, $ir, $c, $h, $userid;
$name=$_POST['leht'];
$sisu=$_POST['sisu'];
if($name)
{
$q=$db->query("SELECT * FROM tutorial WHERE leht='{$name}'");
if($db->num_rows($q))
{
print "2 same name cnt.";
$h->endpage();
exit;
}
$db->query("INSERT INTO tutorial VALUES(NULL, '$name', '$sisu')");
print "Tutorial to page {$name} is created.";
stafflog_add("New tutorial $name added");
}
else
{
print "<h3>Lisa õpetus</h3><hr />
<form action='staff_tutorial.php?action=addtutorial' method='post'>
Page:(example: /home.php) /is important <input type='text' name='leht' /><br />
content: <textarea style='width: 100%; height:200px;' name='sisu'></textarea><br />
<input type='submit' value='Add new' /></form>";
}
}
function edittutorial()
{
global $db, $ir, $c, $h, $userid;
switch($_POST['step'])
{
case "2":
if($_POST['uus']) {
$name=$_POST['leht'];
$sisu=$_POST['sisu'];
$q=$db->query("SELECT * FROM tutorial WHERE leht='{$name}'");
if($db->num_rows($q))
{
print "2 same name cnt .";
$h->endpage();
exit;
}
}
break;
default:
if($_POST['muuda']){
$name=$_POST['leht'];
$sisu=$_POST['sisu'];
$q=$db->query("SELECT * FROM tutorial WHERE id='".$_GET['id']."'");
$old=$db->fetch_row($q);
$db->query("UPDATE tutorial SET leht='{$name}', sisu='{$sisu}' WHERE id='".$_GET['id']."'");
print "Tutorial {$name} is edidet.";
stafflog_add("Edidet page {$name} tutorial");
}
if($_GET['id']){
$q=$db->query("SELECT * FROM tutorial WHERE id='".$_GET['id']."'");
$old=$db->fetch_row($q);
print "<h3>Tutorial edit</h3><hr />
<form action='staff_tutorial.php?action=edittutorial&id={$_GET['id']}' method='post'>
<input type='hidden' name='id' value='{$_POST['tutorial']}' />
Page: <input type='text' name='leht' value='{$old['leht']}' /><br />
Content:<textarea style='width: 100%; height:200px;' name='sisu'>{$old['sisu']}</textarea> <br />
<input type='submit' name='muuda' value='Edit tutorial' /></form>";
}
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM tutorial")
or die(mysql_error());
print "<h3>Tutorial edit</h3><hr />
<table class=table>
<tr>
<td>Page</td><td>link</td>
</tr>";
while($row = mysql_fetch_array( $result )) {
print"<tr>
<td>".$row['leht']."</td><td><a href='staff_tutorial.php?action=edittutorial&id=".$row['id']."'>Edit</a></td>
</tr>";
}
print"</table>
";
break;
}
}
function deltutorial()
{
global $db,$ir,$c,$h,$userid;
if($_GET['id_del'])
{
$q=$db->query("SELECT * FROM tutorial WHERE id={$_GET['id_del']}");
$old=$db->fetch_row($q);
$db->query("DELETE FROM tutorial WHERE id={$_GET['id_del']}");
print "Tutorial for page {$old['leht']} is deleted.";
stafflog_add("Deleted tutorial {$old['leht']}");
}
else
{
print "<h3>Delete tutorial</h3><hr />
are you sure? ";
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM tutorial")
or die(mysql_error());
print "
<table class=table>
<tr>
<td>Page</td><td>link</td>
</tr>";
while($row = mysql_fetch_array( $result )) {
print"<tr>
<td>".$row['leht']."</td><td><a href='staff_tutorial.php?action=deltutorial&id_del=".$row['id']."'>Delete</a></td>
</tr>";
}
print"</table>";
}
}
function report_clear()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 3)
{
die("403");
}
$_GET['ID'] = abs((int) $_GET['ID']);
stafflog_add("Cleared player report ID {$_GET['ID']}");
$db->query("DELETE FROM preports WHERE prID={$_GET['ID']}");
print "Report cleared and deleted!<br />
<a href='staff_users.php?action=reportsview'>> Back</a>";
}
$h->endpage();
?>
then add this into your globals.php , bottom
$result = mysql_query("SELECT * FROM tutorial WHERE leht='".$_SERVER['SCRIPT_NAME']."'");
$row = mysql_fetch_array($result);
if($row['leht']==''){
}else
if($ir['pagetutorials'] == ON)
{
print"
<table class='table'>
<tr>
<td>Tutorial to this page</td>
</tr>
<tr>
<td><div id='sisu'>".$row['sisu']."</div><div id='aeg'>[<a href=preferences.php>Turn off tutorial</a>]</div></td>
</tr>
</table>";
}
and then, add this to you smenu.php wher you want..
<li><a href='staff_tutorial.php?action=addtutorial'>Add tutorial</a></li>
<li><a href='staff_tutorial.php?action=edittutorial'>Edit tutorial</a></li>
<li><a href='staff_tutorial.php?action=deltutorial'>Delete tutorial</a></li>
and then add this in your preferences.php
function pagetutorials_change()
{
global $ir,$c,$userid,$h;
print "<h3>Page Tutorials</h3><br>
<form action='preferences.php?action=pagetutorialschange2' method='post'>
<select name='pagetutorials' type='dropdown'>
<option value='ON'>ON
<option value='OFF'>OFF</select>
<input type='submit' value='Change Info' /></form>";
}
function do_pagetutorials_change()
{
global $db,$ir,$c,$userid,$h;
if($ir['pagetutorials'] == "ON") { $g="OFF"; } else { $g="ON"; }
$_POST['pagetutorials']=str_replace(array("<", ">", "\\\'"), array("<", ">", "'"), $_POST['pagetutorials']);
$db->query("UPDATE users SET pagetutorials='{$_POST['pagetutorials']}' WHERE userid=$userid");
print "Page Tutorials Has Been Turned $g<br />";
}
that to sql
CREATE TABLE IF NOT EXISTS `tutorial` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`leht` varchar(200) NOT NULL,
`sisu` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
and last you need add this whenever you want to add, to user can turn off tutorial
<a href='preferences.php?action=pagetutorialschange'>Turn off tutorial</a>
againe, sorry for my english.. im form estonia, and i translated this mod now in english only to but it here, to share that whit you guys .. :)