mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Add the SourceMod API doc generator.
This commit is contained in:
parent
c255191a2a
commit
fc560a79d9
566
tools/docgen/generate/updater.php
Executable file
566
tools/docgen/generate/updater.php
Executable file
@ -0,0 +1,566 @@
|
||||
<pre><?php
|
||||
|
||||
set_time_limit(300);
|
||||
$downloadnew = FALSE;
|
||||
$dir = ''; // Put DIR here
|
||||
|
||||
// Database credentials.
|
||||
$host = '';
|
||||
$user = '';
|
||||
$password = '';
|
||||
$database = '';
|
||||
|
||||
// Output filename.
|
||||
$filename = '../www/SMfuncs.js';
|
||||
|
||||
// Start defines
|
||||
$funcs = Array();
|
||||
$filefunclist = Array();
|
||||
$tableinfo = Array();
|
||||
$consts = Array();
|
||||
$version = "";
|
||||
$thebasedir = dirname(__FILE__);
|
||||
$defines = Array();
|
||||
$javascript = "var SMfunctions=new Array()\nvar SMconstant=new Array()\nvar SMfiles=new Array()\nvar SMfiledata=new Array()\n";
|
||||
|
||||
function GetFunctionType($str){
|
||||
switch (strtolower($str)) {
|
||||
case "native": return 1; break;
|
||||
case "stock": return 2; break;
|
||||
case "forward": return 3; break;
|
||||
case "functag": return 4; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function PrepareJava($string){
|
||||
return addslashes(str_replace("\n","",nl2br($string)));
|
||||
}
|
||||
|
||||
function DecodeTheFile($file){
|
||||
global $funcs, $conts;
|
||||
$thelines = file($file);
|
||||
$thelines[] = "/**";
|
||||
|
||||
$basename = basename($file);
|
||||
$linescount = count($thelines) - 1;
|
||||
|
||||
$lines = Array();
|
||||
$isanotherone = false;
|
||||
|
||||
foreach ($thelines as $line_num => $lin) {
|
||||
$line = trim($lin);
|
||||
|
||||
if($line == "") continue;
|
||||
|
||||
if(substr($line,0,7) == "#define")
|
||||
AddDefine(substr($line,8));
|
||||
|
||||
if(($line == "/**" && !$isanotherone) || $linescount == $line_num){
|
||||
if(isset($lines[1])){
|
||||
$temp = explode(" ",$lines[1][0]);
|
||||
$type = GetFunctionType($temp[0]);
|
||||
if($type > 0){
|
||||
MakeFunction($lines, implode("", $lines[1]) ,$type,$basename);
|
||||
}else
|
||||
MakeConstant($lines,$basename);
|
||||
}
|
||||
|
||||
$lines = Array();
|
||||
$isanotherone = false;
|
||||
$commented = true;
|
||||
}
|
||||
|
||||
if($line == "{")
|
||||
$isanotherone = true;
|
||||
elseif($line{0} == "}")
|
||||
$isanotherone = false;
|
||||
|
||||
if($commented){
|
||||
$lines[0][] = $line;
|
||||
} else {
|
||||
$lines[1][] = $lin;
|
||||
}
|
||||
|
||||
if($line == "*/" && !$isanotherone)
|
||||
$commented = false;
|
||||
}
|
||||
return implode("",$thelines);
|
||||
}
|
||||
|
||||
function AddDefine($str){
|
||||
if($str{0} == "_")
|
||||
return;
|
||||
global $defines;
|
||||
|
||||
//Sryl, Preg match is just not working out, too much iregularitires
|
||||
//The * will bug the preg_match
|
||||
/*$str = str_replace("*","",$str);
|
||||
$pattern = '/([$A-Z|8|_^]+)\b([^.*]+)([ | | ]\/)/';
|
||||
|
||||
if(!preg_match($pattern, $str, $matches,PREG_OFFSET_CAPTURE)){
|
||||
echo $str . "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$new = substr($str , $matches[2][1] + strlen($matches[2][0]) );
|
||||
if(strlen($new) > 0){
|
||||
$new = str_replace(
|
||||
Array ("/**", "<" , "","/"),
|
||||
Array ("", "" , "",""),
|
||||
$new
|
||||
);
|
||||
}
|
||||
*/
|
||||
$stage = 0;
|
||||
$stageinfo = Array('','','');
|
||||
|
||||
$strlen = strlen($str);
|
||||
for($i=0; $i < $strlen; $i++){
|
||||
if(trim($str{$i}) == "" && $stage == 0){
|
||||
$stage++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if($str{$i} == "/"){
|
||||
if(substr($str,$i,3) == "/**"){
|
||||
$stage++;
|
||||
$i += 3;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if($str{$i} == "*"){
|
||||
if(substr($str,$i,2) == '*/'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
$stageinfo[$stage] .= $str{$i};
|
||||
}
|
||||
|
||||
foreach($stageinfo as $i => $a)
|
||||
$stageinfo[$i] = trim($a);
|
||||
|
||||
if($stageinfo[1] != ""){
|
||||
$defines[] = Array (
|
||||
'variable' => $stageinfo[0],
|
||||
'value' => wordwrap(trim($stageinfo[1]) , 35, " " , true ),
|
||||
'comment' => isset($stageinfo[2]) ? trim($stageinfo[2]) : "",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if($stageinfo[0] == "SOURCEMOD_VERSION"){
|
||||
global $version;
|
||||
$version = str_replace('"',"",$stageinfo[1]);
|
||||
}
|
||||
}
|
||||
|
||||
function MakeConstant($lines,$file){
|
||||
global $consts;
|
||||
|
||||
$info = Array();
|
||||
$content = Array();
|
||||
|
||||
foreach($lines[0] as $line){
|
||||
if(substr($line,0,1) != "*") continue;
|
||||
$thesub = trim(substr($line,2));
|
||||
if($thesub == "") continue;
|
||||
|
||||
$info[] = $thesub;
|
||||
}
|
||||
|
||||
$theinfo = str_replace("@section","", implode("\n",$info));
|
||||
|
||||
if(strpos($theinfo,"All rights reserved.")){
|
||||
$theinfo = "<i>Unclassified</i>";
|
||||
$newline = Array();
|
||||
|
||||
foreach($lines[1] as $lin){
|
||||
$line = trim($lin);
|
||||
if(substr($line,0,7) == "#define" && $line{8} != "_")
|
||||
$newline[] = $line . "\n";
|
||||
}
|
||||
if(count($newline) == 0)
|
||||
return;
|
||||
|
||||
$lines[1] = $newline;
|
||||
}
|
||||
|
||||
$consts[] = Array(
|
||||
'info' => $theinfo,
|
||||
'content' => trim(implode('',$lines[1])),
|
||||
'file' => $file,
|
||||
);
|
||||
}
|
||||
|
||||
function MakeFunction($lines,$function,$type,$file){
|
||||
global $funcs;
|
||||
|
||||
$description = Array();
|
||||
$funcinput = Array();
|
||||
$return = Array();
|
||||
$onerror = Array();
|
||||
$notes = Array();
|
||||
$depreached = 0;
|
||||
|
||||
$infostarted = false;
|
||||
$lastone = 0;
|
||||
|
||||
|
||||
foreach($lines[0] as $line){
|
||||
if(substr($line,0,1) != "*") continue;
|
||||
$thesub = trim(substr($line,2));
|
||||
if($thesub == "") continue;
|
||||
|
||||
|
||||
if ($thesub{0} == "@")
|
||||
$infostarted = true;
|
||||
|
||||
if(!$infostarted){
|
||||
$description[] = $thesub;
|
||||
}
|
||||
|
||||
if ($infostarted && $thesub{0} != "@"){
|
||||
switch ($lastone) {
|
||||
case 0:
|
||||
// if(!isset($funcinput[ count($funcinput) - 1 ]))
|
||||
// echo $file . "\n" . $function . "\n\n";
|
||||
$funcinput[ count($funcinput) - 1 ] .= " " . $thesub;
|
||||
break;
|
||||
case 1: $return[ count($return) - 1 ] .= " " . $thesub; break;
|
||||
case 2: $onerror[ count($onerror) - 1 ] .= " " . $thesub; break;
|
||||
case 3: $notes[ count($notes) - 1 ] .= " " . $thesub; break;
|
||||
case 4: $description[ count($description) - 1 ] .= " " . $thesub; break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$infostarted)
|
||||
$continue;
|
||||
|
||||
if(substr($thesub, 0, 7) == "@return"){
|
||||
$return[] = trim(substr($thesub, 7));
|
||||
$lastone = 1;
|
||||
} elseif(substr($thesub, 0, 11) == "@deprecated"){
|
||||
$depreached = 1;
|
||||
} elseif(substr($thesub, 0, 6) == "@error"){
|
||||
$onerror[] = trim(substr($thesub, 6));
|
||||
$lastone = 2;
|
||||
} elseif(substr($thesub, 0, 9) == "@noreturn"){
|
||||
$return[] = 0;
|
||||
} elseif(substr($thesub, 0, 5) == "@note"){
|
||||
$notes[] = substr($thesub, 5);
|
||||
$lastone = 3;
|
||||
} elseif(substr($thesub, 0, 6) == "@param") {
|
||||
$funcinput[] = substr($thesub, 6);
|
||||
$lastone = 0;
|
||||
} elseif(substr($thesub, 0, 6) == "@brief") {
|
||||
$description[] = substr($thesub, 6);
|
||||
$lastone = 4;
|
||||
}
|
||||
}
|
||||
|
||||
/*$fullcommand = str_replace(
|
||||
Array("Float:","Handle:","Action:","bool:","any:","GroupId:","Function:","ReplySource:","QueryCookie:"),
|
||||
Array("","","","","","","","",""),
|
||||
$function);*/
|
||||
|
||||
$temp = explode("(",$function);
|
||||
$func = $temp[0];
|
||||
if(strpos($func, " ") !== false){
|
||||
$func = trim(substr( $func , strpos($func , " ") ));
|
||||
}
|
||||
|
||||
if(strpos($function, "{") !== false){
|
||||
$function = trim(substr( $function, 0, strpos($function, "{") ));
|
||||
}
|
||||
|
||||
$thestrpos = strpos($func,":");
|
||||
if($thestrpos !== false){
|
||||
$func = substr($func ,$thestrpos + 1);
|
||||
}
|
||||
|
||||
$funcs[] = Array(
|
||||
'description' => implode("\n",$description),
|
||||
'input' => implode("\n",$funcinput),
|
||||
'function' => $func,
|
||||
'fullfunc' => trim($function),
|
||||
'return' => implode("\n",$return),
|
||||
'onerror' => implode("\n",$onerror),
|
||||
'notes' => implode("\n",$notes),
|
||||
'file' => $file,
|
||||
'typeof' => $type,
|
||||
'depreached' => $depreached
|
||||
);
|
||||
}
|
||||
|
||||
function db_query($query){
|
||||
$q = mysql_query($query);
|
||||
if(!$q){
|
||||
echo "\n" . mysql_error() . "\n" . $query . "<hr>";
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
function GetFileAddr(){
|
||||
$lines = file("http://www.sourcemod.net/builds.php");
|
||||
|
||||
foreach ($lines as $line_num => $lin) {
|
||||
if(substr($lin, 0, 13) == "<li><a href='"){
|
||||
$explode = explode("<a href='", $lin);
|
||||
foreach($explode as $a){
|
||||
if(strpos($a, ".zip")){
|
||||
$b = explode("'>", $a);
|
||||
return $b[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DownloadNew(){
|
||||
global $thebasedir;
|
||||
copy( GetFileAddr() ,'build.zip');
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open('build.zip') === TRUE) {
|
||||
$zip->extractTo($thebasedir . "/build/" );
|
||||
$zip->close();
|
||||
} else {
|
||||
exit( 'Failed to zip' );
|
||||
}
|
||||
}
|
||||
|
||||
function full_rmdir( $dir ){
|
||||
if ( !is_writable( $dir ) ){
|
||||
if ( !@chmod( $dir, 0777 ) ){
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
$d = dir( $dir );
|
||||
while ( FALSE !== ( $entry = $d->read() ) ){
|
||||
if ( $entry == '.' || $entry == '..' ){
|
||||
continue;
|
||||
}
|
||||
$entry = $dir . '/' . $entry;
|
||||
if ( is_dir( $entry ) ){
|
||||
if ( !$this->full_rmdir( $entry ) ){
|
||||
return FALSE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ( !@unlink( $entry ) ){
|
||||
$d->close();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
return rmdir( $dir );
|
||||
}
|
||||
|
||||
function FindFileID($file){
|
||||
global $tableinfo;
|
||||
foreach($tableinfo['sm_smfiles'] as $fname => $id)
|
||||
if($file == $fname)
|
||||
return $id;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
function FindUnusedid($arrayname){
|
||||
global $tableinfo;
|
||||
// if(!isset($tableinfo[ $arrayname ]))
|
||||
// return 0;
|
||||
|
||||
$tempinfo = array_flip($tableinfo[ $arrayname ]);
|
||||
$i = 0;
|
||||
//Hope this works!!
|
||||
while( TRUE ){
|
||||
if(!isset($tempinfo[ $i ]))
|
||||
return $i;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($downloadnew)
|
||||
DownloadNew();
|
||||
if(strlen(trim($dir)) == 0)
|
||||
$dir = $thebasedir . '/build/addons/sourcemod/scripting/include';
|
||||
$files = Array();
|
||||
|
||||
if(!($dir_handle = opendir($dir))){
|
||||
exit('Could not open ' . $dir);
|
||||
}
|
||||
|
||||
while($file = readdir($dir_handle)){
|
||||
if($file == "." || $file == "..") continue;
|
||||
|
||||
if(substr($file, -4, 4) == ".inc"){
|
||||
$filedir = $dir . "/" . $file;
|
||||
|
||||
// if($file == "version.inc"){
|
||||
// GetVersion($filedir);
|
||||
// } else {
|
||||
$files[] = Array(
|
||||
'Addr' => $filedir,
|
||||
'name' => $file,
|
||||
// 'fcount' => 0,
|
||||
// 'ccount' => 0,
|
||||
'content' => DecodeTheFile($filedir),
|
||||
);
|
||||
// }
|
||||
}
|
||||
}
|
||||
closedir($dir_handle);
|
||||
|
||||
$link = mysql_connect($host, $user, $password)
|
||||
or die('Could not connect: ' . mysql_error());
|
||||
mysql_select_db($database) or die('Could not select database');
|
||||
|
||||
|
||||
db_query("TRUNCATE TABLE `sm_smconst`");
|
||||
db_query("TRUNCATE TABLE `sm_smfilescon`");
|
||||
db_query("TRUNCATE TABLE `sm_smdefine`");
|
||||
db_query("UPDATE sm_smfunctions SET depreached = 2 WHERE typeof <> 4");
|
||||
|
||||
//db_query("TRUNCATE TABLE `smfiles`");
|
||||
//db_query("TRUNCATE TABLE `smfunctions`");
|
||||
|
||||
$tables = Array (
|
||||
'sm_smfiles' => Array ('filename','id'),
|
||||
'sm_smfunctions' => Array ('func','id'),
|
||||
);
|
||||
|
||||
foreach ($tables as $name => $table){
|
||||
$result = db_query('SELECT ' . $table[0] . ',' . $table[1] . ' FROM ' . $name);
|
||||
|
||||
$tableinfo[$name] = Array();
|
||||
|
||||
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
|
||||
$tableinfo[$name][$line[0]] = $line[1];
|
||||
}
|
||||
|
||||
mysql_free_result($result);
|
||||
}
|
||||
|
||||
foreach($files as $file){
|
||||
$onlyname = str_replace('.inc','',$file['name']);
|
||||
|
||||
if(!isset($tableinfo['sm_smfiles'][ $file['name'] ])){
|
||||
//0 is a ID, so count will make it just right...
|
||||
$tableinfo['sm_smfiles'][ $file['name'] ] = FindUnusedid('sm_smfiles');
|
||||
db_query('INSERT INTO sm_smfiles(id,name,filename) VALUES ('. $tableinfo['sm_smfiles'][ $file['name'] ] .',"'.$onlyname.'","'.$file['name'].'")');
|
||||
}
|
||||
|
||||
db_query('INSERT INTO `sm_smfilescon` VALUES ('. $tableinfo['sm_smfiles'][ $file['name'] ] .',\''. addslashes( $file['content'] ) .'\')');
|
||||
|
||||
$javascript .= 'SMfiles['. $tableinfo['sm_smfiles'][ $file['name'] ] .'] = "'. $onlyname .'"' . "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
foreach($funcs as $go){
|
||||
$gop = str_replace('"', '\"', $go );
|
||||
|
||||
$fid = FindFileID($gop['file']);
|
||||
|
||||
$javacontent = PrepareJava($gop['description'] );
|
||||
|
||||
if(isset($tableinfo['sm_smfunctions'][ $gop['function'] ])){
|
||||
$sql = 'UPDATE sm_smfunctions
|
||||
SET fullfunc = "'.$gop['fullfunc'].'",
|
||||
description = "'.$gop['description'].'",
|
||||
`treturn` = "'.$gop['return'].'",
|
||||
`onerror` = "'.$gop['onerror'].'",
|
||||
`funcinput` = "'.$gop['input'].'",
|
||||
inc = '.$fid.',
|
||||
incname = "'.$gop['file'].'",
|
||||
typeof ='.$gop['typeof'].',
|
||||
depreached = '.$gop['depreached'].'
|
||||
WHERE id = '. $tableinfo['sm_smfunctions'][ $gop['function'] ] .'';
|
||||
} else {
|
||||
$tableinfo['sm_smfunctions'][ $gop['function'] ] = FindUnusedid('sm_smfunctions');
|
||||
$sql = 'INSERT INTO sm_smfunctions(id,func,fullfunc,description,`treturn`,`onerror`,`funcinput`,inc,incname,typeof,version) VALUES
|
||||
('. $tableinfo['sm_smfunctions'][ $gop['function'] ] .',
|
||||
"'.$gop['function'].'",
|
||||
"'.$gop['fullfunc'].'",
|
||||
"'.$javacontent.'",
|
||||
"'.$gop['return'].'",
|
||||
"'.$gop['onerror'].'",
|
||||
"'.$gop['input'].'",
|
||||
'.$fid.',
|
||||
"'.$gop['file'].'",
|
||||
'.$gop['typeof'].',
|
||||
\''.$version.'\'
|
||||
)';
|
||||
}
|
||||
|
||||
$javascript .= 'SMfunctions['. $tableinfo['sm_smfunctions'][ $gop['function'] ] .'] = Array ("'.$gop['function'].'","'.$javacontent.'");' . "\n";
|
||||
|
||||
$filefunclist[$fid][] = $tableinfo['sm_smfunctions'][ $gop['function'] ];
|
||||
|
||||
$query = db_query($sql);
|
||||
}
|
||||
|
||||
foreach($consts as $go){
|
||||
$gop = str_replace('"', '\"', $go );
|
||||
$fid = FindFileID($gop['file']);
|
||||
|
||||
$sql = 'INSERT INTO sm_smconst(fileid,descrip,`fulltext`) VALUES
|
||||
('.$fid.',
|
||||
"'.$gop['info'].'",
|
||||
"'.$gop['content'].'"
|
||||
)';
|
||||
|
||||
$query = db_query($sql);
|
||||
}
|
||||
|
||||
foreach($filefunclist as $id => $go){
|
||||
$javascript .= 'SMfiledata['. $id .'] = Array ('. implode(",",$go) .');' . "\n";
|
||||
}
|
||||
|
||||
foreach($defines as $id => $go){
|
||||
$gop = str_replace('"', '\"', $go );
|
||||
$sql = 'INSERT INTO `sm_smdefine` (`id`,`variable` ,`value` ,`comment`) VALUES ('.$id.',"'.$gop['variable'].'", "'.$gop['value'].'", "'.$gop['comment'].'")';
|
||||
$javascript .= 'SMconstant['.$id.'] = Array ("'. PrepareJava($gop['variable']) .'","'. PrepareJava($gop['value']) .'","'. PrepareJava($gop['comment']) .'");' . "\n";
|
||||
db_query($sql);
|
||||
}
|
||||
|
||||
db_query('UPDATE `sm_sminfo` SET infob = "'.$version.'" WHERE master = "version"');
|
||||
|
||||
foreach($tableinfo['sm_smfiles'] as $fid){
|
||||
db_query('UPDATE sm_smfiles SET
|
||||
`fcount` = (SELECT COUNT(*) FROM sm_smfunctions WHERE inc = '.$fid.'),
|
||||
`ccount` = (SELECT COUNT(*) FROM sm_smconst WHERE fileid = '.$fid.')
|
||||
WHERE id = '.$fid.'');
|
||||
}
|
||||
|
||||
$res = mysql_query("SELECT id FROM sm_smfunctions WHERE depreached = 2");
|
||||
while (($row = mysql_fetch_array($res)) !== FALSE)
|
||||
{
|
||||
db_query("DELETE FROM sm_smposts WHERE func = " . $row[0]);
|
||||
db_query("DELETE FROM sm_smfunctions WHERE id = " . $row[0]);
|
||||
}
|
||||
|
||||
mysql_free_result($res);
|
||||
|
||||
mysql_close($link);
|
||||
|
||||
//$filename = "SMfuncs.js";
|
||||
if (!$handle = fopen($filename, 'w')) {
|
||||
echo "Cannot open file ($filename)";
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $javascript;
|
||||
|
||||
// Write $somecontent to our opened file.
|
||||
if (fwrite($handle, $javascript) === FALSE) {
|
||||
echo "Cannot write to file ($filename)";
|
||||
exit;
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
|
||||
?>
|
163
tools/docgen/sql/schema.sql
Normal file
163
tools/docgen/sql/schema.sql
Normal file
@ -0,0 +1,163 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.2.2
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Host: db01
|
||||
-- Generation Time: Jul 31, 2014 at 12:10 PM
|
||||
-- Server version: 5.5.11-log
|
||||
-- PHP Version: 5.5.13
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
--
|
||||
-- Database: `smdocs`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `sm_smconst`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sm_smconst` (
|
||||
`id` int(11) NOT NULL,
|
||||
`fileid` int(11) NOT NULL,
|
||||
`descrip` tinytext NOT NULL,
|
||||
`fulltext` text NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=141 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `sm_smdefine`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sm_smdefine` (
|
||||
`id` int(11) NOT NULL,
|
||||
`variable` varchar(64) NOT NULL,
|
||||
`value` tinytext NOT NULL,
|
||||
`comment` tinytext NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `sm_smfiles`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sm_smfiles` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(32) NOT NULL,
|
||||
`filename` varchar(32) NOT NULL,
|
||||
`fcount` int(11) NOT NULL,
|
||||
`ccount` int(11) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `sm_smfilescon`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sm_smfilescon` (
|
||||
`id` int(11) NOT NULL,
|
||||
`cont` text NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `sm_smfunctions`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sm_smfunctions` (
|
||||
`id` int(11) NOT NULL,
|
||||
`func` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||
`fullfunc` text NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`treturn` tinytext NOT NULL,
|
||||
`onerror` tinytext NOT NULL,
|
||||
`funcinput` text NOT NULL,
|
||||
`exemple` text NOT NULL,
|
||||
`inc` int(11) NOT NULL,
|
||||
`incname` varchar(32) NOT NULL,
|
||||
`typeof` int(11) NOT NULL,
|
||||
`depreached` tinyint(1) NOT NULL,
|
||||
`version` varchar(32) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `sm_sminfo`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sm_sminfo` (
|
||||
`master` varchar(32) NOT NULL,
|
||||
`infoa` int(11) NOT NULL,
|
||||
`infob` varchar(32) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `sm_smposts`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sm_smposts` (
|
||||
`id` int(11) NOT NULL,
|
||||
`file` int(11) NOT NULL,
|
||||
`func` int(11) NOT NULL,
|
||||
`time` int(11) NOT NULL,
|
||||
`poster` varchar(32) NOT NULL,
|
||||
`body` text NOT NULL,
|
||||
`ip` varchar(16) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=311 ;
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `sm_smconst`
|
||||
--
|
||||
ALTER TABLE `sm_smconst`
|
||||
ADD PRIMARY KEY (`id`), ADD KEY `fileid` (`fileid`);
|
||||
|
||||
--
|
||||
-- Indexes for table `sm_smdefine`
|
||||
--
|
||||
ALTER TABLE `sm_smdefine`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `sm_smfiles`
|
||||
--
|
||||
ALTER TABLE `sm_smfiles`
|
||||
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`name`);
|
||||
|
||||
--
|
||||
-- Indexes for table `sm_smfilescon`
|
||||
--
|
||||
ALTER TABLE `sm_smfilescon`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `sm_smfunctions`
|
||||
--
|
||||
ALTER TABLE `sm_smfunctions`
|
||||
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`func`), ADD KEY `inc` (`inc`);
|
||||
|
||||
--
|
||||
-- Indexes for table `sm_sminfo`
|
||||
--
|
||||
ALTER TABLE `sm_sminfo`
|
||||
ADD KEY `master` (`master`);
|
||||
|
||||
--
|
||||
-- Indexes for table `sm_smposts`
|
||||
--
|
||||
ALTER TABLE `sm_smposts`
|
||||
ADD PRIMARY KEY (`id`), ADD KEY `ip` (`ip`);
|
||||
|
112
tools/docgen/www/Login.php
Normal file
112
tools/docgen/www/Login.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
if (!defined('Nican'))
|
||||
die('Hacking attempt...');
|
||||
|
||||
$context['user']['guest'] = true;
|
||||
$context['user']['id'] = 0;
|
||||
$context['user']['ip'] = getenv("REMOTE_ADDR");
|
||||
|
||||
//Check if the user is logged in
|
||||
function CheckLogin(){
|
||||
global $context, $dbname, $cookiename;
|
||||
|
||||
//First check for the cookie existence
|
||||
if (!isset($_COOKIE[$cookiename]))
|
||||
return;
|
||||
|
||||
//Uncompile the data
|
||||
//0 = id, 1 = md5(password . ip)
|
||||
$array = @unserialize($_COOKIE[$cookiename]);
|
||||
|
||||
if($array === FALSE)
|
||||
return;
|
||||
|
||||
$array[0] = (int) $array[0];
|
||||
|
||||
if($array[0] == 0)
|
||||
return;
|
||||
|
||||
//Go to BAILOPAN Database to steal some data
|
||||
mysql_select_db('am');
|
||||
|
||||
$query = db_query('SELECT username, password FROM vb_user WHERE userid = '. $array[0] .'');
|
||||
|
||||
if(mysql_num_rows($query) == 0){
|
||||
mysql_free_result($query);
|
||||
mysql_select_db($dbname);
|
||||
return;
|
||||
}
|
||||
|
||||
//Sinse userid is PRIMARY, it should only have 1 result, no need for WHILE
|
||||
$info = mysql_fetch_array($query, MYSQL_ASSOC);
|
||||
|
||||
//print_r($array);
|
||||
//print_r($info);
|
||||
|
||||
//Omg! it is him! Let him in
|
||||
if( md5($info['password'] . $context['user']['ip'] ) == $array[1]){
|
||||
$context['user']['guest'] = false;
|
||||
$context['user']['id'] = $array[0];
|
||||
$context['user']['name'] = $info['username'];
|
||||
}
|
||||
|
||||
mysql_free_result($query);
|
||||
mysql_select_db($dbname);
|
||||
}
|
||||
|
||||
function LoginUser(){
|
||||
global $context, $dbname, $cookieaddr, $cookiename;
|
||||
|
||||
if(!isset($_REQUEST['pw']) || !isset($_REQUEST['user']))
|
||||
return 'Information not entered.';
|
||||
else
|
||||
|
||||
|
||||
//'Pw' should be in MD5 and the user column can't be bigger then 100
|
||||
if(strlen($_REQUEST['pw']) != 32 || strlen($_REQUEST['user']) > 100)
|
||||
return 'Invalid user or password.';
|
||||
|
||||
mysql_select_db('am');
|
||||
|
||||
$query = db_query('SELECT userid, password, salt FROM vb_user WHERE username = "'. mysql_real_escape_string($_REQUEST['user']) .'"');
|
||||
|
||||
if(mysql_num_rows($query) == 0){
|
||||
mysql_free_result($query);
|
||||
mysql_select_db($dbname);
|
||||
return 'Invalid user or password.';
|
||||
}
|
||||
|
||||
$info = mysql_fetch_array($query, MYSQL_ASSOC);
|
||||
|
||||
$pw = md5($_REQUEST['pw'] . $info['salt'] );
|
||||
|
||||
//echo $pw . '<br>';
|
||||
|
||||
if($pw != $info['password']){
|
||||
mysql_free_result($query);
|
||||
mysql_select_db($dbname);
|
||||
return 'Invalid user or password.';
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['forever']) && $_REQUEST['forever'] == 1)
|
||||
$time = 0;
|
||||
else
|
||||
$time = time() + 3600 * 24;
|
||||
|
||||
|
||||
$data = serialize( Array($info['userid'], md5($pw . $context['user']['ip'])) );
|
||||
|
||||
//print_r($data);
|
||||
|
||||
//Yay, by now he has login and password correct, let's give him a cookie
|
||||
setcookie($cookiename, $data, $time, '/', $cookieaddr, 0 ,1);
|
||||
|
||||
mysql_free_result($query);
|
||||
mysql_select_db($dbname);
|
||||
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
19
tools/docgen/www/Settings.php
Executable file
19
tools/docgen/www/Settings.php
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
if (!defined('Nican'))
|
||||
die('Hacking attempt...');
|
||||
|
||||
$dbname = '';
|
||||
$dbuser = '';
|
||||
$dbpass = '';
|
||||
$dbhost = '';
|
||||
|
||||
($link = mysql_connect($dbhost, $dbuser, $dbpass)) or die ("could not connect");;
|
||||
mysql_select_db($dbname) or die('Could not select database');
|
||||
|
||||
$scripturl = 'http://docs.sourcemod.net/api/index.php';
|
||||
$cookieaddr = 'docs.sourcemod.net';
|
||||
|
||||
|
||||
$cookiename = '';
|
||||
|
||||
?>
|
358
tools/docgen/www/Source.php
Normal file
358
tools/docgen/www/Source.php
Normal file
@ -0,0 +1,358 @@
|
||||
<?php
|
||||
if (!defined('Nican'))
|
||||
die('Hacking attempt...');
|
||||
|
||||
|
||||
function db_query($query){
|
||||
$q = mysql_query($query);
|
||||
if($q === FALSE){
|
||||
echo "\n" . mysql_error() . "\n" . $query . "<hr>";
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
function Main(){
|
||||
global $context;
|
||||
$context['optheader'] = "Main";
|
||||
|
||||
$resul = db_query('SELECT id,name,fcount,ccount FROM `sm_smfiles`',__FILE__,__LINE__);
|
||||
while ($line = mysql_fetch_array($resul, MYSQL_ASSOC)) {
|
||||
$context['fileinfo'][] = Array(
|
||||
'id' => $line['id'],
|
||||
'name' => $line['name'],
|
||||
);
|
||||
}
|
||||
|
||||
usort($context['fileinfo'], "SortByName");
|
||||
|
||||
}
|
||||
|
||||
function SortByName($a, $b)
|
||||
{
|
||||
if ($a['name'] == $b['name']) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['name'] < $b['name']) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
function ShowOpts(){
|
||||
global $context;
|
||||
|
||||
if(!isset($_GET['id']) || $_GET['id'] == "")
|
||||
exit("No Results found.");
|
||||
|
||||
if(strlen($_GET['id']) > 30)
|
||||
exit("No Results found.");
|
||||
|
||||
$context['usetopandbo'] = Array ( false,false);
|
||||
|
||||
$query = 'SELECT id,func,inc FROM `sm_smfunctions` WHERE LCASE(func) LIKE \'%'.strtolower(mysql_real_escape_string($_GET['id'])).'%\' OR description LIKE \'%'.mysql_real_escape_string($_GET['id']).' %\' COLLATE latin1_swedish_ci';
|
||||
$result = db_query($query,__FILE__,__LINE__);
|
||||
|
||||
$context['answers'] = Array();
|
||||
|
||||
$context['numresults'] = mysql_num_rows($result);
|
||||
|
||||
if($context['numresults'] > 100)
|
||||
return;
|
||||
|
||||
$files = Array ();
|
||||
$i = 0;
|
||||
|
||||
if($context['numresults'] > 0){
|
||||
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$context['answers'][ $line['inc'] ][ $line['id'] ] = $line['func'];
|
||||
|
||||
$context['lastone'][ $line['inc'] ] = $line['id'];
|
||||
|
||||
if(!isset( $files [ $line['inc'] ])){
|
||||
$files [ $line['inc'] ] = $i;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$fliped = array_flip( $files );
|
||||
$query = db_query('SELECT id,name FROM `sm_smfiles` WHERE id IN ('. implode(",",$fliped) .')',__FILE__,__LINE__);
|
||||
|
||||
while ($line = mysql_fetch_array($query, MYSQL_ASSOC)) {
|
||||
$context['files'][ $line['id'] ] = $line['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ShowInfo(){
|
||||
global $context;
|
||||
|
||||
if(!isset($_GET['id']) || $_GET['id'] == "")
|
||||
exit("No Results found.");
|
||||
|
||||
$query = 'SELECT func,fullfunc,description,treturn,funcinput,exemple,inc,incname,typeof,onerror,version FROM `sm_smfunctions` WHERE id = '.intval($_GET['id']).' LIMIT 1';
|
||||
$result = db_query($query,__FILE__,__LINE__);
|
||||
|
||||
|
||||
$context['numresults'] = mysql_num_rows($result);
|
||||
|
||||
if($context['numresults'] > 0){
|
||||
$context['answers'] = mysql_fetch_array($result, MYSQL_ASSOC);
|
||||
$context['topmenu'][] = Array (
|
||||
$context['answers']['incname'],
|
||||
'index.php?action=file&id='.$context['answers']['inc']
|
||||
);
|
||||
$context['optheader'] = $context['answers']['func'];
|
||||
|
||||
|
||||
$result = db_query('SELECT fcount,ccount FROM `sm_smfiles` WHERE id = '.$context['answers']['inc'].' LIMIT 1',__FILE__,__LINE__);
|
||||
$context['fileinfo'] = mysql_fetch_array($result, MYSQL_ASSOC);
|
||||
|
||||
$result = db_query('SELECT time,poster,body FROM `sm_smposts` WHERE file = '.$context['answers']['inc'].' AND func = '.intval($_GET['id']).'',__FILE__,__LINE__);
|
||||
$context['sm']['pcount'] = mysql_num_rows($result);
|
||||
if($context['sm']['pcount'] > 0){
|
||||
$context['sm']['posts'] = Array();
|
||||
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$context['sm']['posts'][] = Array (
|
||||
'poster' => $line['poster'],
|
||||
'time' => date("F j, Y, g:i a",$line['time']),
|
||||
'body' => parse_bbc($line['body']),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ShowFile(){
|
||||
global $context;
|
||||
|
||||
if(!isset($_GET['id']) || $_GET['id'] == "" || strlen($_GET['id']) > 2)
|
||||
exit("No Results found.");
|
||||
|
||||
$result = db_query('SELECT name,filename,fcount,ccount FROM `sm_smfiles` WHERE id = '.intval($_GET['id']).' LIMIT 1',__FILE__,__LINE__);
|
||||
|
||||
$context['letters'] = Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v');
|
||||
$context['numresults'] = mysql_num_rows($result);
|
||||
|
||||
if($context['numresults'] > 0){
|
||||
$info = mysql_fetch_array($result, MYSQL_ASSOC);
|
||||
|
||||
$context['name'] = $info['name'];
|
||||
$context['filename'] = $info['filename'];
|
||||
$context['fcount'] = $info['fcount'];
|
||||
$context['ccount'] = $info['ccount'];
|
||||
$context['optheader'] = $info['filename'];
|
||||
|
||||
$result = db_query('SELECT time,poster,body FROM `sm_smposts` WHERE file = '.intval($_GET['id']).' AND func = -1',__FILE__,__LINE__);
|
||||
$context['sm']['pcount'] = mysql_num_rows($result);
|
||||
if($context['sm']['pcount'] > 0){
|
||||
$context['sm']['posts'] = Array();
|
||||
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$context['sm']['posts'][] = Array (
|
||||
'poster' => $line['poster'],
|
||||
'time' => date("F j, Y, g:i a",$line['time']),
|
||||
'body' => parse_bbc($line['body']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$context['topmenu'][] = Array (
|
||||
$context['filename'],
|
||||
'index.php?action=file&id='.$_GET['id']
|
||||
);
|
||||
|
||||
if(isset($_GET['type']) && $info['fcount'] > 0) return LoadThis(0);
|
||||
if(isset($_GET['file'])) return LoadThis(2);
|
||||
if($info['ccount'] > 0) return LoadThis(1);
|
||||
if($info['fcount'] > 0) return LoadThis(0);
|
||||
return LoadThis(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function LoadThis($type){
|
||||
global $context;
|
||||
$context['goon'] = $type;
|
||||
|
||||
switch($type){
|
||||
case 0:
|
||||
$resul = db_query('SELECT id,func,description FROM `sm_smfunctions` WHERE inc = '.intval($_GET['id']).'',__FILE__,__LINE__);
|
||||
while ($line = mysql_fetch_array($resul, MYSQL_ASSOC)) {
|
||||
$context['infos'][] = Array(
|
||||
'id' => $line['id'],
|
||||
'func' => $line['func'],
|
||||
'desc' => $line['description'],
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
$resul = db_query('SELECT descrip,`fulltext` FROM `sm_smconst` WHERE fileid = '.intval($_GET['id']).'',__FILE__,__LINE__);
|
||||
while ($line = mysql_fetch_array($resul, MYSQL_ASSOC)) {
|
||||
$context['infos'][] = $line;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$resul = db_query('SELECT cont FROM `sm_smfilescon` WHERE id = '.intval($_GET['id']).'',__FILE__,__LINE__);
|
||||
$context['infos'] = mysql_fetch_array($resul, MYSQL_ASSOC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function HighLight(){
|
||||
global $context;
|
||||
|
||||
$context['goon'] = isset($_GET['goon']);
|
||||
|
||||
if($context['goon']){
|
||||
if(isset($_POST['signature']) && trim($_POST['signature']) != ""){
|
||||
$newinfo =stripslashes($_POST['signature']);
|
||||
HighLightThis($newinfo);
|
||||
} elseif (is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {
|
||||
switch ($_FILES['uploadedfile']['error']){
|
||||
case 1: $context['imagerror'] = 'The uploaded file exceeds max size.'; break;
|
||||
case 2: $context['imagerror'] = 'The uploaded file exceeds max size.'; break;
|
||||
case 3: $context['imagerror'] = 'The uploaded file was only partially uploaded.'; break;
|
||||
case 7: $context['imagerror'] = 'Failed to write file to disk.'; break;
|
||||
case 8: $context['imagerror'] = 'File upload stopped by extension.'; break;
|
||||
}
|
||||
|
||||
if(isset($context['imagerror']))
|
||||
return;
|
||||
|
||||
$code = file_get_contents($_FILES['uploadedfile']['tmp_name']);
|
||||
HighLightThis($code);
|
||||
|
||||
$context['topmenu'][] = Array (
|
||||
$_FILES['uploadedfile']['name'],
|
||||
'index.php?action=codehigh'
|
||||
);
|
||||
} else {
|
||||
$context['imagerror'] = 'Could not upload file, or no data found.';
|
||||
$context['topmenu'][] = Array (
|
||||
'MyCode',
|
||||
'index.php?action=codehigh'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function HighLightThis($code){
|
||||
global $context;
|
||||
|
||||
$search[0] = Array('<?php ','?>');
|
||||
$replace[1] = Array('','');
|
||||
|
||||
$theresults = Array();
|
||||
|
||||
$result = mysql_query('SELECT id,func FROM sm_smfunctions') or die('Query failed: ' . mysql_error());
|
||||
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$theresults[] = Array (
|
||||
'id' => $line['id'],
|
||||
'func' => $line['func'],
|
||||
'strlen' => strlen($line['func']),
|
||||
);
|
||||
}
|
||||
|
||||
//I need to sort it and do that stupid thing of $thereplaceid so that one function becomes two, like SetClientListeningFlags and SetClientListening
|
||||
usort($theresults, "CompareSTRLEN");
|
||||
|
||||
foreach($theresults as $go){
|
||||
$thereplaceid = "<!<" . $go['id'] . ">!>";
|
||||
$search[0][] = $go['func'];
|
||||
$replace[0][] = $thereplaceid;
|
||||
|
||||
$search[1][] = $thereplaceid;
|
||||
$replace[1][] = '<a href="index.php?action=show&id='.$go['id'].'" onmouseout="hideSMFunc()" onmouseover="showSMfunc('.$go['id'].')">' . $go['func'] . '</a>';
|
||||
}
|
||||
|
||||
$result = mysql_query('SELECT id,variable FROM sm_smdefine') or die('Query failed: ' . mysql_error());
|
||||
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$search[2][] = $line['variable'];
|
||||
$replace[2][] = '<a onmouseout="hideSMFunc()" onmouseover="showSMconst('.$line['id'].')">' . $line['variable'] . '</a>';
|
||||
}
|
||||
|
||||
$str = highlight_string('<?php ' . $code . ' ?>', true);
|
||||
$str = str_replace($search[0], $replace[0], $str);
|
||||
$str = str_replace($search[1], $replace[1], $str);
|
||||
$str = str_replace($search[2], $replace[2], $str);
|
||||
|
||||
$context['str'] = $str; //explode("<br />",$str);
|
||||
}
|
||||
|
||||
function PreviewPost(){
|
||||
echo parse_bbc(stripslashes($_POST['message']));
|
||||
die();
|
||||
}
|
||||
|
||||
function PostThis(){
|
||||
global $context,$templatefunc;
|
||||
|
||||
if($context['user']['guest'])
|
||||
exit("3");
|
||||
|
||||
if(!isset($_GET['id']) || $_GET['id'] == '' || strlen($_GET['id']) > 5)
|
||||
exit("0");
|
||||
|
||||
$typearray = Array ( 'file' , 'func');
|
||||
if(!isset($_GET['type']) || array_search($_GET['type'], $typearray) === false)
|
||||
exit("0");
|
||||
|
||||
if(!isset($_POST['message']) || $_POST['message'] == '')
|
||||
exit("1");
|
||||
|
||||
$time = time();
|
||||
|
||||
$query = db_query('SELECT time FROM sm_smposts WHERE ip = "'.$context['user']['ip'].'" ORDER BY time DESC LIMIT 1',__FILE__,__LINE__);
|
||||
if(mysql_num_rows($query) > 0){
|
||||
$line = mysql_fetch_array($query, MYSQL_NUM);
|
||||
if($time < $line[0] + 15)
|
||||
exit("2");
|
||||
}
|
||||
|
||||
|
||||
switch($_GET['type']){
|
||||
case "file":
|
||||
$query = db_query('SELECT id FROM sm_smfiles WHERE id = '.intval($_GET['id']).' LIMIT 1',__FILE__,__LINE__);
|
||||
if(mysql_num_rows($query) == 0)
|
||||
exit("0");
|
||||
|
||||
|
||||
$file = $_GET['id'];
|
||||
$func = -1;
|
||||
|
||||
$afterfunc = "ShowFile";
|
||||
break;
|
||||
case "func":
|
||||
$query = db_query('SELECT inc FROM sm_smfunctions WHERE id = '.intval($_GET['id']).' LIMIT 1',__FILE__,__LINE__);
|
||||
if(mysql_num_rows($query) == 0)
|
||||
exit("0");
|
||||
|
||||
$line = mysql_fetch_array($query);
|
||||
|
||||
$file = $line[0];
|
||||
$func = $_GET['id'];
|
||||
|
||||
$afterfunc = "ShowInfo";
|
||||
break;
|
||||
}
|
||||
|
||||
db_query('INSERT INTO sm_smposts(file,func,time,poster,body,ip) VALUES
|
||||
('.$file.','.$func.','.$time.',"'. $context['user']['name'] .'",\''.mysql_real_escape_string($_POST['message']).'\',"'.$context['user']['ip'].'")',__FILE__,__LINE__);
|
||||
|
||||
$afterfunc();
|
||||
$templatefunc = $afterfunc . "_template";
|
||||
}
|
||||
|
||||
function LoginWebiste(){
|
||||
echo LoginUser();
|
||||
exit;
|
||||
}
|
||||
|
||||
function LogOutWebsite(){
|
||||
global $cookieaddr, $scripturl, $cookiename;
|
||||
setcookie ($cookiename, '', time() - 100000, '/', $cookieaddr, 0 ,1);
|
||||
|
||||
echo 'Logging out...';
|
||||
sleep(2);
|
||||
echo '<script type="text/javascript">window.location="'.$scripturl.'"</script>';
|
||||
exit;
|
||||
}
|
||||
?>
|
1560
tools/docgen/www/bbc_parse.php
Normal file
1560
tools/docgen/www/bbc_parse.php
Normal file
File diff suppressed because it is too large
Load Diff
BIN
tools/docgen/www/header.jpg
Normal file
BIN
tools/docgen/www/header.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
tools/docgen/www/imgs/channel.gif
Normal file
BIN
tools/docgen/www/imgs/channel.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 628 B |
BIN
tools/docgen/www/imgs/tree_end.gif
Normal file
BIN
tools/docgen/www/imgs/tree_end.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 B |
BIN
tools/docgen/www/imgs/tree_mid.gif
Normal file
BIN
tools/docgen/www/imgs/tree_mid.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 B |
58
tools/docgen/www/index.php
Normal file
58
tools/docgen/www/index.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
define('Nican', 1);
|
||||
|
||||
include_once('Settings.php');
|
||||
|
||||
include_once('Login.php');
|
||||
include_once('Source.php');
|
||||
include_once('bbc_parse.php');
|
||||
include_once('template.php');
|
||||
|
||||
$resul =db_query('SELECT * FROM `sm_sminfo`',__FILE__,__LINE__);
|
||||
while ($line = mysql_fetch_array($resul, MYSQL_NUM)) {
|
||||
$context['globalinfo'][$line[0]] = Array ($line[1] , $line[2]);
|
||||
}
|
||||
|
||||
//Check if the user is logged in
|
||||
CheckLogin();
|
||||
|
||||
$context['sm']['haslibary'] = true;
|
||||
|
||||
$actions = Array (
|
||||
'main' => 'Main',
|
||||
'file' => 'ShowFile',
|
||||
'gethint' => 'ShowOpts',
|
||||
'show' => 'ShowInfo',
|
||||
'codehigh' => 'HighLight',
|
||||
'previewpost' => 'PreviewPost',
|
||||
'post' => 'PostThis',
|
||||
'login' => 'LoginWebiste',
|
||||
'logout' => 'LogOutWebsite',
|
||||
);
|
||||
|
||||
$context['optheader'] = "";
|
||||
$context['usetopandbo'] = Array ( true, true );
|
||||
$context['topmenu'] = Array();
|
||||
|
||||
if(!isset($_GET['action']))
|
||||
$action = $actions['main'];
|
||||
else
|
||||
$action = isset($actions[$_GET['action']]) ? $actions[$_GET['action']] : $actions['main'];
|
||||
|
||||
$templatefunc = $action . "_template";
|
||||
|
||||
$action();
|
||||
|
||||
|
||||
// Check if compressed output is enabled, supported, and not already being done.
|
||||
if (!headers_sent() && ob_get_length() == 0){
|
||||
// If zlib is being used, turn off output compression.
|
||||
if (@ini_get('zlib.output_compression') != '1' && @ini_get('output_handler') != 'ob_gzhandler' && @version_compare(PHP_VERSION, '4.2.0') != -1)
|
||||
ob_start('ob_gzhandler');
|
||||
}
|
||||
if($context['usetopandbo'][0]) Headertemplate();
|
||||
$templatefunc();
|
||||
if($context['usetopandbo'][1]) Footertemplate();
|
||||
|
||||
//print_r($context);
|
||||
?>
|
248
tools/docgen/www/md5.js
Normal file
248
tools/docgen/www/md5.js
Normal file
@ -0,0 +1,248 @@
|
||||
/*
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
|
||||
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
|
||||
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
|
||||
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length
|
||||
*/
|
||||
function core_md5(x, len)
|
||||
{
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << ((len) % 32);
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
|
||||
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
|
||||
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
|
||||
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
|
||||
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
|
||||
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
|
||||
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
|
||||
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
|
||||
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
|
||||
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
|
||||
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
|
||||
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
|
||||
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
|
||||
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
|
||||
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
|
||||
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
|
||||
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
|
||||
|
||||
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
|
||||
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
|
||||
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
|
||||
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
|
||||
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
|
||||
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
|
||||
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
|
||||
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
|
||||
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
|
||||
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
|
||||
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
|
||||
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
|
||||
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
|
||||
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
|
||||
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
|
||||
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
|
||||
|
||||
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
|
||||
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
|
||||
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
|
||||
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
|
||||
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
|
||||
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
|
||||
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
|
||||
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
|
||||
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
|
||||
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
|
||||
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
|
||||
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
|
||||
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
|
||||
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
|
||||
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
|
||||
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
|
||||
|
||||
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
|
||||
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
|
||||
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
|
||||
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
|
||||
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
|
||||
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
|
||||
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
|
||||
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
|
||||
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
|
||||
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
|
||||
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
|
||||
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
|
||||
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
|
||||
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
|
||||
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
|
||||
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
}
|
||||
return Array(a, b, c, d);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions implement the four basic operations the algorithm uses.
|
||||
*/
|
||||
function md5_cmn(q, a, b, x, s, t)
|
||||
{
|
||||
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
|
||||
}
|
||||
function md5_ff(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
||||
}
|
||||
function md5_gg(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
||||
}
|
||||
function md5_hh(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
function md5_ii(a, b, c, d, x, s, t)
|
||||
{
|
||||
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-MD5, of a key and some data
|
||||
*/
|
||||
function core_hmac_md5(key, data)
|
||||
{
|
||||
var bkey = str2binl(key);
|
||||
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
|
||||
return core_md5(opad.concat(hash), 512 + 128);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bit_rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a string to an array of little-endian words
|
||||
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
|
||||
*/
|
||||
function str2binl(str)
|
||||
{
|
||||
var bin = Array();
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < str.length * chrsz; i += chrsz)
|
||||
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
|
||||
return bin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a string
|
||||
*/
|
||||
function binl2str(bin)
|
||||
{
|
||||
var str = "";
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < bin.length * 32; i += chrsz)
|
||||
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a hex string.
|
||||
*/
|
||||
function binl2hex(binarray)
|
||||
{
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i++)
|
||||
{
|
||||
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
|
||||
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a base-64 string
|
||||
*/
|
||||
function binl2b64(binarray)
|
||||
{
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i += 3)
|
||||
{
|
||||
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
|
||||
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
|
||||
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
|
||||
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
421
tools/docgen/www/script.js
Normal file
421
tools/docgen/www/script.js
Normal file
@ -0,0 +1,421 @@
|
||||
opnedtab = -1;
|
||||
var previewPopupWindow;
|
||||
MainInformation = "";
|
||||
var smf_images_url = "http://nican132.com/forum/Themes/halflife_11final/images";
|
||||
var smf_formSubmitted = false;
|
||||
var currentSwap = true;
|
||||
|
||||
function FlipPostSpan(){
|
||||
document.getElementById("postspan").style.display = currentSwap ? "" : "none";
|
||||
currentSwap = !currentSwap;
|
||||
}
|
||||
|
||||
currentLoginSwap = true;
|
||||
|
||||
function FlipLoginBox(){
|
||||
document.getElementById("LoginBox").style.display = currentLoginSwap ? "" : "none";
|
||||
currentLoginSwap = !currentLoginSwap;
|
||||
}
|
||||
|
||||
function myMouseMove(e){
|
||||
if (!e){
|
||||
var e = window.event;
|
||||
}
|
||||
if (e.pageX){
|
||||
myDiv.style.left = (e.pageX + 10) + "px";
|
||||
myDiv.style.top = (e.pageY + 10) + "px";
|
||||
}else{
|
||||
myDiv.style.left = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + 20;
|
||||
myDiv.style.top = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + 20;
|
||||
}
|
||||
}
|
||||
|
||||
function ResetSearch(){
|
||||
document.getElementById("txt1").value="";
|
||||
showHint("");
|
||||
}
|
||||
|
||||
function hideSMFunc(){
|
||||
myDiv = document.getElementById("serverbox");
|
||||
myDiv.style.visibility = "hidden";
|
||||
document.onmousemove = "";
|
||||
}
|
||||
|
||||
function LoadPopUP(html){
|
||||
myDiv = document.getElementById("serverbox");
|
||||
myDiv.innerHTML = html;
|
||||
myDiv.style.visibility = "visible";
|
||||
document.onmousemove = myMouseMove;
|
||||
}
|
||||
|
||||
|
||||
function showSMfunc(id){
|
||||
html = '<div style="background-color: #00AAAA"><b>';
|
||||
html += SMfunctions[id][0];
|
||||
html += '</b></div><div style="padding: 2px;">';
|
||||
html += SMfunctions[id][1];
|
||||
html += '</div>';
|
||||
|
||||
LoadPopUP(html);
|
||||
}
|
||||
|
||||
function showSMconst(id){
|
||||
html = '<div style="background-color: #00AAAA"><b>';
|
||||
html += SMconstant[id][0];
|
||||
html += '</b></div><div style="padding: 2px;"><i>';
|
||||
html += SMconstant[id][1];
|
||||
html += '</i><br/>';
|
||||
html += SMconstant[id][2];
|
||||
html += '</div>';
|
||||
|
||||
LoadPopUP(html);
|
||||
}
|
||||
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^\s*/, "").replace(/\s*$/, "");
|
||||
}
|
||||
|
||||
function PrintMain(x){
|
||||
html = '<div style="margin: 2px;" onclick="SpanArea('+x+')">';
|
||||
html += '<img style="vertical-align: bottom" src="imgs/channel.gif" alt="#" /> ';
|
||||
html += SMfiles[x] + '</div><div id="'+ SMfiles[x] +'"></div>';
|
||||
return html;
|
||||
}
|
||||
|
||||
var xmlHttp
|
||||
var BodyHttp
|
||||
|
||||
function showHint(str){
|
||||
str=str.trim();
|
||||
if (str.length==0){
|
||||
//html = "";
|
||||
//for (x in SMfiles){
|
||||
// html += PrintMain(x);
|
||||
//}
|
||||
document.getElementById("txtHint").innerHTML= MainInformation;
|
||||
return
|
||||
}
|
||||
|
||||
xmlHttp=GetXmlHttpObject()
|
||||
|
||||
if (xmlHttp==null){
|
||||
alert ("Browser does not support HTTP Request")
|
||||
return
|
||||
}
|
||||
|
||||
document.getElementById("txtHint").innerHTML="<i>Loading...</i>"
|
||||
|
||||
var url="index.php?action=gethint&id="+str;
|
||||
xmlHttp.onreadystatechange=stateChanged
|
||||
xmlHttp.open("GET",url,true)
|
||||
xmlHttp.send(null)
|
||||
}
|
||||
|
||||
function stateChanged(){
|
||||
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
|
||||
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
|
||||
}
|
||||
}
|
||||
|
||||
function LoadMainPage(url){
|
||||
BodyHttp=GetXmlHttpObject()
|
||||
|
||||
if (BodyHttp==null){
|
||||
alert ("Browser does not support HTTP Request")
|
||||
return
|
||||
}
|
||||
ShowLoading()
|
||||
|
||||
BodyHttp.onreadystatechange=MainStateChanged
|
||||
BodyHttp.open("GET",url,true)
|
||||
BodyHttp.send(null)
|
||||
}
|
||||
|
||||
function MainStateChanged(){
|
||||
if (BodyHttp.readyState==4 || BodyHttp.readyState=="complete"){
|
||||
HideLoading()
|
||||
document.getElementById("MainBody").innerHTML=BodyHttp.responseText
|
||||
}
|
||||
}
|
||||
|
||||
function ShowCustomLink(page){
|
||||
LoadMainPage("index.php?" + page);
|
||||
}
|
||||
|
||||
function ShowFunction(id){
|
||||
hideSMFunc()
|
||||
LoadMainPage("index.php?action=show&id="+id);
|
||||
}
|
||||
|
||||
function ShowFileInfo(id){
|
||||
LoadMainPage("index.php?action=file&id="+id);
|
||||
}
|
||||
function ShowLoading(){
|
||||
ly = document.getElementById("AdminPopUP");
|
||||
|
||||
ly.style.zindex = "100";
|
||||
ly.style.display = "block";
|
||||
}
|
||||
|
||||
function HideLoading(){
|
||||
document.getElementById("AdminPopUP").style.display = "none";
|
||||
}
|
||||
|
||||
function SpanArea(id, hashtml){
|
||||
if(opnedtab >= 0){
|
||||
document.getElementById( SMfiles[opnedtab] ).innerHTML="";
|
||||
if(opnedtab == id){
|
||||
opnedtab = -1;
|
||||
return
|
||||
}
|
||||
}
|
||||
opnedtab = id;
|
||||
ShowFileInfo(id);
|
||||
|
||||
if(!SMfiledata[id])
|
||||
return;
|
||||
|
||||
html = "";
|
||||
arycount = SMfiledata[id].length -1
|
||||
|
||||
for (x in SMfiledata[id]){
|
||||
html += '<img style="vertical-align: bottom" src="imgs/tree_';
|
||||
if(x == arycount) html+= 'end'; else html+= 'mid';
|
||||
html += '.gif" alt="├" /><a onclick="ShowFunction('+ SMfiledata[id][x] +')" onmouseout="hideSMFunc()" onmouseover="showSMfunc('+ SMfiledata[id][x] +')">';
|
||||
html += SMfunctions[ SMfiledata[id][x] ][0] + "</a><br>";
|
||||
|
||||
}
|
||||
if(html != "")
|
||||
document.getElementById( SMfiles[id] ).innerHTML=html
|
||||
|
||||
}
|
||||
|
||||
function getHTMLDocument(url, callback)
|
||||
{
|
||||
if (!window.XMLHttpRequest)
|
||||
return false;
|
||||
|
||||
var myDoc = new XMLHttpRequest();
|
||||
if (typeof(callback) != "undefined")
|
||||
{
|
||||
myDoc.onreadystatechange = function ()
|
||||
{
|
||||
if (myDoc.readyState != 4)
|
||||
return;
|
||||
|
||||
if (myDoc.responseText != null && myDoc.status == 200){
|
||||
callback(myDoc.responseText);
|
||||
}
|
||||
};
|
||||
}
|
||||
myDoc.open('GET', url, true);
|
||||
myDoc.send(null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SubmitLoginInfo(){
|
||||
ShowLoading();
|
||||
|
||||
var url = "index.php?action=login&user=" + document.getElementById("user").value;
|
||||
url += "&pw=" + hex_md5(document.getElementById("pw").value);
|
||||
if(document.getElementById("forever").checked)
|
||||
url += "&forever=1";
|
||||
else
|
||||
url += "&forever=0";
|
||||
|
||||
getHTMLDocument(url, Revivelogin);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function Revivelogin(html){
|
||||
HideLoading();
|
||||
if(html == "ok"){
|
||||
window.location="index.php"
|
||||
return;
|
||||
}
|
||||
|
||||
alert(html);
|
||||
}
|
||||
|
||||
// Send a post form to the server using XMLHttpRequest.
|
||||
function senHTMLDocument(url, content, callback)
|
||||
{
|
||||
if (!window.XMLHttpRequest)
|
||||
return false;
|
||||
|
||||
var sendDoc = new window.XMLHttpRequest();
|
||||
if (typeof(callback) != "undefined")
|
||||
{
|
||||
sendDoc.onreadystatechange = function ()
|
||||
{
|
||||
if (sendDoc.readyState != 4)
|
||||
return;
|
||||
|
||||
if (sendDoc.responseText != null && sendDoc.status == 200)
|
||||
callback(sendDoc.responseText);
|
||||
else
|
||||
callback(false);
|
||||
};
|
||||
}
|
||||
sendDoc.open('POST', url, true);
|
||||
if (typeof(sendDoc.setRequestHeader) != "undefined")
|
||||
sendDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
sendDoc.send(content);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetXmlHttpObject(){
|
||||
var xmlHttp=null;
|
||||
try{
|
||||
// Firefox, Opera 8.0+, Safari
|
||||
xmlHttp=new XMLHttpRequest();
|
||||
}
|
||||
catch (e){
|
||||
// Internet Explorer
|
||||
try{
|
||||
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
|
||||
}
|
||||
catch (e){
|
||||
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
}
|
||||
return xmlHttp;
|
||||
}
|
||||
|
||||
function surroundText(text1, text2, textarea)
|
||||
{
|
||||
// Can a text range be created?
|
||||
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
|
||||
{
|
||||
var caretPos = textarea.caretPos, temp_length = caretPos.text.length;
|
||||
|
||||
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
|
||||
|
||||
if (temp_length == 0)
|
||||
{
|
||||
caretPos.moveStart("character", -text2.length);
|
||||
caretPos.moveEnd("character", -text2.length);
|
||||
caretPos.select();
|
||||
}
|
||||
else
|
||||
textarea.focus(caretPos);
|
||||
}
|
||||
// Mozilla text range wrap.
|
||||
else if (typeof(textarea.selectionStart) != "undefined")
|
||||
{
|
||||
var begin = textarea.value.substr(0, textarea.selectionStart);
|
||||
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
|
||||
var end = textarea.value.substr(textarea.selectionEnd);
|
||||
var newCursorPos = textarea.selectionStart;
|
||||
var scrollPos = textarea.scrollTop;
|
||||
|
||||
textarea.value = begin + text1 + selection + text2 + end;
|
||||
|
||||
if (textarea.setSelectionRange)
|
||||
{
|
||||
if (selection.length == 0)
|
||||
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
|
||||
else
|
||||
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
|
||||
textarea.focus();
|
||||
}
|
||||
textarea.scrollTop = scrollPos;
|
||||
}
|
||||
// Just put them on the end, then.
|
||||
else
|
||||
{
|
||||
textarea.value += text1 + text2;
|
||||
textarea.focus(textarea.value.length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
function textToEntities(text)
|
||||
{
|
||||
var entities = "";
|
||||
for (var i = 0; i < text.length; i++)
|
||||
{
|
||||
var charcode = text.charCodeAt(i);
|
||||
if ((charcode >= 48 && charcode <= 57) || (charcode >= 65 && charcode <= 90) || (charcode >= 97 && charcode <= 122))
|
||||
entities += text.charAt(i);
|
||||
else
|
||||
entities += "&#" + charcode + ";";
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
function bbc_highlight(something, mode){
|
||||
something.style.backgroundImage = "url(" + smf_images_url + (mode ? "/bbc/bbc_hoverbg.gif)" : "/bbc/bbc_bg.gif)");
|
||||
}
|
||||
|
||||
function PreviewPost(){
|
||||
x = new Array();
|
||||
var textFields = ["message"];
|
||||
|
||||
ShowLoading();
|
||||
|
||||
for (i in textFields)
|
||||
if (document.forms.postmodify.elements[textFields[i]])
|
||||
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
|
||||
|
||||
senHTMLDocument("index.php?action=previewpost", x.join("&"), PreviewPostSent);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function PreviewPostSent(html){
|
||||
if (previewPopupWindow)
|
||||
previewPopupWindow.close();
|
||||
|
||||
HideLoading();
|
||||
|
||||
thespan = document.getElementById("previewspan");
|
||||
|
||||
thespan.style.display = "";
|
||||
thespan.innerHTML = "Preview: <br/> <div style=\"padding: 5px\">" + html + "</div>";
|
||||
}
|
||||
|
||||
function submitThisOnce(form,id,post)
|
||||
{
|
||||
if (typeof(form.form) != "undefined")
|
||||
form = form.form;
|
||||
|
||||
for (var i = 0; i < form.length; i++)
|
||||
if (typeof(form[i]) != "undefined" && form[i].tagName.toLowerCase() == "textarea")
|
||||
form[i].readOnly = true;
|
||||
|
||||
x = new Array();
|
||||
var textFields = ["message","poster"];
|
||||
|
||||
ShowLoading();
|
||||
|
||||
|
||||
for (i in textFields)
|
||||
if (document.forms.postmodify.elements[textFields[i]])
|
||||
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
|
||||
|
||||
senHTMLDocument("index.php?action=post&id=" + id + "&type=" + post, x.join("&"), SentPost);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function SentPost(html){
|
||||
HideLoading();
|
||||
html=html.trim();
|
||||
|
||||
if(html == "0")
|
||||
return alert("Invalid data.")
|
||||
else if (html == "1")
|
||||
return alert("No body data.")
|
||||
else if (html == "2")
|
||||
return alert("Please at least wait 15 secs between each post.");
|
||||
else if (html == "3")
|
||||
return alert("Please login before posting.");
|
||||
else
|
||||
document.getElementById("MainBody").innerHTML= html;
|
||||
|
||||
}
|
||||
|
81
tools/docgen/www/style.css
Normal file
81
tools/docgen/www/style.css
Normal file
@ -0,0 +1,81 @@
|
||||
tr.tpc:hover
|
||||
{
|
||||
background-color: #595959;
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
text-decoration: none;
|
||||
color: blue;
|
||||
}
|
||||
a:hover
|
||||
{
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a img{
|
||||
border: 0;
|
||||
}
|
||||
|
||||
body, td, th , tr
|
||||
{
|
||||
font-size: small;
|
||||
font-family: verdana, sans-serif;
|
||||
}
|
||||
|
||||
/* The main body of the entire forum. */
|
||||
body
|
||||
{
|
||||
background-color: #bebebe;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.descript{
|
||||
visibility: hidden;
|
||||
z-index: 200;
|
||||
position: absolute;
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid black;
|
||||
font-size: x-small;
|
||||
font-family: verdana, sans-serif;
|
||||
}
|
||||
|
||||
.UpperTab{
|
||||
background-color: #D0D2D6;
|
||||
width: 100px;
|
||||
font-size: 12pt;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.LoadingBox{
|
||||
background-color: #D8D8D8;
|
||||
border: 1px solid black;
|
||||
position: absolute;
|
||||
padding: 10px;
|
||||
right: 50px;
|
||||
top: 50px;
|
||||
}
|
||||
|
||||
.phpcode
|
||||
{
|
||||
color: #000000;
|
||||
background-color: #D7DADC;
|
||||
border: 1px solid #000000;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
font-size: x-small;
|
||||
line-height: 1.4em;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.smfunc
|
||||
{
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.smconst
|
||||
{
|
||||
color: blue;
|
||||
font-weight: bold;
|
||||
}
|
347
tools/docgen/www/template.php
Normal file
347
tools/docgen/www/template.php
Normal file
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
|
||||
function Headertemplate(){
|
||||
|
||||
}
|
||||
|
||||
//padding: 10px;
|
||||
function Main_template(){
|
||||
global $context, $scripturl;
|
||||
|
||||
$search = isset($_GET['query']) ? $_GET['query'] : "";
|
||||
|
||||
echo '<html><head>
|
||||
<title>'.$context['optheader'] .' - SourceMod Scripting API Reference</title>
|
||||
<script src="script.js"></script>
|
||||
<script src="SMfuncs.js"></script>
|
||||
<script src="md5.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="serverbox" class="descript"></div>
|
||||
<div id="AdminPopUP" class="LoadingBox" style="display:none;">Loading...</div>
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr><td style="border-right-style: groove; background-color: #D0D2D6;width: 12%; height: 42;">
|
||||
<a href="'.$scripturl.'"><img src="header.jpg" alt="SourceMod Logo"></a>';
|
||||
|
||||
|
||||
if($context['user']['guest']){
|
||||
echo '<table width="100%" cellpadding="0" cellspacing="0"><tr><td>Welcome <i>Guest</i>.</td>
|
||||
<td style="text-align: right;"><a href="#" onclick="FlipLoginBox()">Login</a></td></tr></table>
|
||||
<div style="border: 1px solid black;margin:2px;padding:1px;display:none" id="LoginBox" >
|
||||
<form onsubmit="SubmitLoginInfo(); return false;">
|
||||
User: <input type="text" name="user" id="user" value="" size="16"/><br/>
|
||||
Pass: <input type="password" name="pw" id="pw" value="" size="16"/><br/>
|
||||
Remember me: <input type="checkbox" name="forever" id="forever" value="1" />
|
||||
<input type="submit" value="Enter"><br/>
|
||||
</form></div>';
|
||||
} else{
|
||||
echo '<table width="100%" cellpadding="0" cellspacing="0"><tr><td>Hey, <b>'.$context['user']['name'].'</b>.</td>
|
||||
<td style="text-align: right;"><a href="'.$scripturl.'?action=logout">Logout</a></td></tr></table>';
|
||||
}
|
||||
|
||||
echo ' </td><td style="background-color: WhiteSmoke; font-size: 9pt" rowspan="2" id="MainBody" valign="top">
|
||||
<br><br>
|
||||
Welcome to the SourceMod Scripting API Reference. <br><br>
|
||||
For more information, see the <a href="http://wiki.alliedmods.net/Category:SourceMod_Scripting">SourceMod Scripting Wiki</a>, which contains tutorials on specific topics.
|
||||
<br><br>
|
||||
<br><br>
|
||||
<b>Your browser must support JavaScript to use this tool.</b>
|
||||
Enter a search term on the left to look for symbols in the SourceMod include files. <br><br>
|
||||
Alternately, click a file on the left to browse its functions/symbols or see its contents. <br><br>
|
||||
Click "Reset" to get back to the main page, or "Link to page" to link someone to the page you\'re seeing.<br>
|
||||
<br>
|
||||
</td></tr>
|
||||
<tr><td style="border-right-style: groove; border-top: 1px solid black; width: 12%; background-color: #E4E8EB" valign="top">
|
||||
<table width="85%" align="center" cellpadding="3" cellspacing="0"><tr>
|
||||
<td style="background-color: #A5A5A5" align="center"><a href="http://forums.alliedmods.net/forumdisplay.php?f=52" target="_blank">Forums</a></td><td width="5%"></td>
|
||||
<td style="background-color: #A5A5A5" align="center"><a href="http://wiki.alliedmods.net/Category:SourceMod_Scripting" target="_blank">Articles</a></td>
|
||||
</tr></table>
|
||||
<hr width="95%">
|
||||
<div style="padding: 3px;">';
|
||||
|
||||
echo 'Search: <input type="text" name="search" value="'.$search.'" size="18" id="txt1" onkeyup="showHint(this.value)">';
|
||||
|
||||
|
||||
echo '<div style="text-align: right;width: 85%"><a onclick="ResetSearch()"><small>Reset</small></a></div>
|
||||
<div style="font-size: 10pt" id="txtHint">';
|
||||
|
||||
foreach($context['fileinfo'] as $file){
|
||||
echo '<div style="margin: 2px;" onclick="SpanArea('.$file['id'].')">
|
||||
<img style="vertical-align: bottom" src="imgs/channel.gif" alt="#" />
|
||||
'.$file['name'].'
|
||||
</div><font id="'.$file['name'].'"></font>';
|
||||
}
|
||||
|
||||
echo '</div>
|
||||
</div>
|
||||
</td></tr>
|
||||
|
||||
<tr><td colspan="2" style="border-top-style: groove; background-color: #bebebe; text-align: right">
|
||||
API site created by Nican | SourceMod v.<b>'. $context['globalinfo']['version'][1] .'</td></tr>
|
||||
</table>';
|
||||
|
||||
echo '<script>
|
||||
MainInformation = document.getElementById("txtHint").innerHTML;';
|
||||
|
||||
if(isset($_GET['fastload']))
|
||||
echo 'ShowCustomLink("'.GenerateLink(true).'");';
|
||||
|
||||
if($search != ""){
|
||||
echo 'showHint("'.$search.'");';
|
||||
}
|
||||
|
||||
echo '</script>';
|
||||
}
|
||||
|
||||
function GenerateLink($backwards = false){
|
||||
$link = "";
|
||||
foreach($_GET as $name => $info){
|
||||
$link .= htmlspecialchars(urlencode($name)) . '=' . htmlspecialchars(urlencode($info)) . '&';
|
||||
}
|
||||
|
||||
if($backwards)
|
||||
$link = str_replace("fastload","action",$link);
|
||||
else
|
||||
$link = str_replace("action","fastload",$link);
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
function PrintUpperTab($fileid, $fcount, $ccount){
|
||||
global $context;
|
||||
$fileid = (int)$fileid;
|
||||
echo '<table cellpadding="0" cellspacing="0" style="height: 25px;"><tr><td style="width: 25px;"></td>
|
||||
<td class="UpperTab">';
|
||||
|
||||
if( $ccount > 0)
|
||||
echo '<a onclick="ShowCustomLink(\'action=file&id='.$fileid.'\')">Constants</a>';
|
||||
else
|
||||
echo 'Constants';
|
||||
|
||||
echo '</td><td style="width: 10px;"></td><td class="UpperTab">';
|
||||
|
||||
if($fcount > 0)
|
||||
echo '<a onclick="ShowCustomLink(\'action=file&id='.$fileid.'&type\')">Functions</a>';
|
||||
else
|
||||
echo 'Functions';
|
||||
|
||||
echo '</td><td style="width: 10px;"></td>';
|
||||
echo '<td class="UpperTab"><a onclick="ShowCustomLink(\'action=file&id='.$fileid.'&file\')">File</a></td>
|
||||
<td style="width: 10px;"></td>
|
||||
<td valign="top"><small><a href="index.php?'.GenerateLink().'">Link to page</a></small></td>
|
||||
</tr></table>';
|
||||
}
|
||||
|
||||
function ShowOpts_template(){
|
||||
global $context;
|
||||
|
||||
if($context['numresults'] > 100){
|
||||
echo 'More than 100 results found. <br/> Please try something smaller';
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<div id="ts2_layer" style="font-size: 8pt">';
|
||||
if($context['numresults'] > 0){
|
||||
foreach ($context['files'] as $fid => $file){
|
||||
echo '<span class="t_c" style="cursor: pointer" onclick="ShowFileInfo('.$fid.')">
|
||||
<img style="vertical-align: bottom" src="imgs/channel.gif" alt="#" /> <b>'. $file .'</b></span>';
|
||||
|
||||
foreach ($context['answers'][ $fid ] as $id => $func){
|
||||
echo '<br/><img style="vertical-align: bottom" src="imgs/tree_' , $context['lastone'][$fid] == $id ? 'end' : 'mid' , '.gif" alt="├" /><a onclick="ShowFunction('.$id.')" onmouseout="hideSMFunc()" onmouseover="showSMfunc('.$id.')">' . $func . "</a>";
|
||||
}
|
||||
echo '<br>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
echo $context['numresults']. ' results found.';
|
||||
|
||||
}
|
||||
|
||||
//func,fullfunc,description,treturn,funcinput,exemple,inc,typeof
|
||||
|
||||
function ShowInfo_template(){
|
||||
global $context;
|
||||
|
||||
if($context['numresults'] > 0){
|
||||
PrintUpperTab( $context['answers']['inc'] , $context['fileinfo']['fcount'], $context['fileinfo']['fcount']);
|
||||
|
||||
echo '<div style="padding: 25px;">';
|
||||
|
||||
//echo '<a href="index.php">[ Source Mod ]</a> <a href="index.php?action=file&id='.$context['answers']['inc'].'"> [ '.$context['answers']['incname'].' ]</a>';
|
||||
echo '<h2 style="padding-left: 10px;">' . $context['answers']['func'] . '</h2>
|
||||
<b>Syntax:</b><div style="padding-left: 25px;" class="smalltext">';
|
||||
|
||||
highlight_string($context['answers']['fullfunc']);
|
||||
|
||||
echo '</div><br/><b>Usage: </b><pre style="padding-left: 25px;">' . $context['answers']['funcinput'] . '</pre>';
|
||||
|
||||
echo '<b>Notes</b>: <div style="padding-left: 25px;">'. $context['answers']['description'] . '
|
||||
|
||||
</div><br/><b>Return: </b><div style="padding-left: 25px;">' , $context['answers']['treturn'] != "0" ? $context['answers']['treturn'] : '<i>No return.</i>' , '</div>';
|
||||
|
||||
echo '<br /><b>Version Added:</b><pre style="padding-left: 25px;">' . $context['answers']['version'] . '</pre>';
|
||||
|
||||
if($context['answers']['onerror'] != "")
|
||||
echo '<br/><b>On error / Errors: </b><div style="padding-left: 25px;">' , $context['answers']['onerror'] != "" ? $context['answers']['onerror'] : '<i>No error.</i>' , '</div>';
|
||||
|
||||
echo '</div><br/><br/>';
|
||||
|
||||
PrintPostingSection('func');
|
||||
} else
|
||||
echo 'No result found on that id.';
|
||||
|
||||
}
|
||||
|
||||
function ShowFile_template(){
|
||||
global $context;
|
||||
|
||||
if($context['numresults'] > 0){
|
||||
PrintUpperTab( $_GET['id'] , $context['fcount'], $context['ccount']);
|
||||
|
||||
echo '<div style="padding: 25px;">';
|
||||
|
||||
switch($context['goon']){
|
||||
case 0:
|
||||
echo '<table border="1" class="tpc">';
|
||||
foreach($context['infos'] as $i => $ans){
|
||||
echo '<tr style="background-color: ',$i%2 ? '#D8D8D8' : '#C8C8C8',';"><td><a onclick="ShowFunction('.$ans['id'].')">' . $ans['func'] . '</a></td><td>' . $ans['desc'] . '</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
break;
|
||||
case 1:
|
||||
echo '<ul>';
|
||||
foreach($context['infos'] as $id => $info){
|
||||
echo '<li><a href="#'.$context['letters'][$id].'">' . $info['descrip'] . '</a></li>';
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
foreach($context['infos'] as $id => $info){
|
||||
echo '<a name="'.$context['letters'][$id].'"></a>
|
||||
<b>' . $info['descrip'] . '</b>
|
||||
<div style="padding-left: 25px;"><pre>'. $info['fulltext'] .'</pre></div><br/><br/>';
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
echo '<pre>'.$context['infos']['cont'].'</pre>';
|
||||
break;
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
PrintPostingSection('file');
|
||||
|
||||
} else
|
||||
echo 'No result found on that id.';
|
||||
}
|
||||
|
||||
function PrintPostingSection($type){
|
||||
global $context;
|
||||
|
||||
echo '<table style="border: medium solid #bebebe; width: 98%" cellpadding="0" cellspacing="0" align="center">
|
||||
<tr style="background-color: #bebebe"><td>0 comments</td><td align="right"><a onclick="FlipPostSpan()">Post a new comment</a></td></tr>
|
||||
|
||||
<tr id="postspan" style="display:none;"><td colspan="2">';
|
||||
|
||||
if($context['user']['guest']){
|
||||
echo '<center><i><h2>Please login before posting</h2></i></center>';
|
||||
} else {
|
||||
echo '<form action="index.php?fastload=file&id='.$_GET['id'].'" method="post" accept-charset="ISO-8859-1" name="postmodify" id="postmodify" onsubmit="return false;" enctype="multipart/form-data" style="margin: 0;">
|
||||
|
||||
<table style="width: 95%;">
|
||||
<tr></td><td><td>
|
||||
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[sm]\', \'[/sm]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/sm.png" align="bottom" width="23" height="22" alt="SM code" title="SM code" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<img src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" />
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[b]\', \'[/b]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/bold.gif" align="bottom" width="23" height="22" alt="Bold" title="Bold" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[i]\', \'[/i]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/italicize.gif" align="bottom" width="23" height="22" alt="Italicized" title="Italicized" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[u]\', \'[/u]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/underline.gif" align="bottom" width="23" height="22" alt="Underline" title="Underline" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[s]\', \'[/s]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/strike.gif" align="bottom" width="23" height="22" alt="Strikethrough" title="Strikethrough" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<img src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" />
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[pre]\', \'[/pre]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/pre.gif" align="bottom" width="23" height="22" alt="Preformatted Text" title="Preformatted Text" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[left]\', \'[/left]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/left.gif" align="bottom" width="23" height="22" alt="Left Align" title="Left Align" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[center]\', \'[/center]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/center.gif" align="bottom" width="23" height="22" alt="Centered" title="Centered" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[right]\', \'[/right]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/right.gif" align="bottom" width="23" height="22" alt="Right Align" title="Right Align" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<img src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" />
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[size=10pt]\', \'[/size]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/size.gif" align="bottom" width="23" height="22" alt="Font Size" title="Font Size" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<a href="javascript:void(0);" onclick="surroundText(\'[font=Verdana]\', \'[/font]\', document.forms.postmodify.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="http://nican132.com/forum/Themes/halflife_11final/images/bbc/face.gif" align="bottom" width="23" height="22" alt="Font Face" title="Font Face" style="background-image: url(http://nican132.com/forum/Themes/halflife_11final/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>
|
||||
<select onchange="surroundText(\'[color=\' + this.options[this.selectedIndex].value.toLowerCase() + \']\', \'[/color]\', document.forms.postmodify.message); this.selectedIndex = 0; document.forms.postmodify.message.focus(document.forms.postmodify.message.caretPos);" style="margin-bottom: 1ex;">
|
||||
<option value="" selected="selected">Change Color</option>
|
||||
<option value="Black">Black</option>
|
||||
<option value="Red">Red</option>
|
||||
<option value="Yellow">Yellow</option>
|
||||
<option value="Pink">Pink</option>
|
||||
<option value="Green">Green</option>
|
||||
<option value="Orange">Orange</option>
|
||||
<option value="Purple">Purple</option>
|
||||
<option value="Blue">Blue</option>
|
||||
<option value="Beige">Beige</option>
|
||||
<option value="Brown">Brown</option>
|
||||
<option value="Teal">Teal</option>
|
||||
<option value="Navy">Navy</option>
|
||||
<option value="Maroon">Maroon</option>
|
||||
<option value="LimeGreen">Lime Green</option>
|
||||
</select>
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td valign="top">Body:<br/><small>All BBC codes are avaliable.</small></td><td><textarea cols="75" rows="12" style="width: 95%; height: 250px;" name="message" tabindex="1"></textarea></td></tr>
|
||||
<tr><td></td><td align="center">
|
||||
<input type="submit" name="post" value="Post" tabindex="3" onclick="return submitThisOnce(this,\''.$_GET['id'].'\',\''.$type.'\');" accesskey="s" />
|
||||
<input type="submit" name="preview" value="Preview" tabindex="4" onclick="return PreviewPost();" accesskey="p" />
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</form>';
|
||||
|
||||
}
|
||||
|
||||
echo '</td></tr>
|
||||
<tr><td id="previewspan" style="display:none;" colspan="2"></td></tr>';
|
||||
if($context['sm']['pcount'] > 0){
|
||||
foreach($context['sm']['posts'] as $post){
|
||||
echo '<tr style="background-color: #D9D9D9"><td style="border-top: medium solid #bebebe;"><b>'. $post['poster'] .'</b></td><td align="right" style="border-top: medium solid #bebebe;"><small>'. $post['time'] .'</small></td></tr>
|
||||
<tr><td colspan="2" style="padding: 5px"><div>'. $post['body'] .'</div></td>';
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td colspan="2" align="center" style="border-top: medium solid #bebebe;"> <i> No posts posted </i> </td></tr>';
|
||||
}
|
||||
echo '</table><br/>';
|
||||
}
|
||||
|
||||
function Footertemplate(){
|
||||
global $context;
|
||||
|
||||
/*echo '<hr>
|
||||
<div width="85%" align="right">
|
||||
<a href="http://www.nican132.com/forum/index.php"> Nican132.com </a> | SourceMod v.<b>'. $context['globalinfo']['version'][1] .'</b>
|
||||
</div>';*/
|
||||
|
||||
}
|
||||
|
||||
function HighLight_template(){
|
||||
global $context;
|
||||
|
||||
if($context['goon']){
|
||||
if(isset($context['imagerror']))
|
||||
echo 'There was an error:' . $context['imagerror'];
|
||||
else {
|
||||
echo "\n" . '<div id="serverbox" class="descript"></div><script src="SMfuncs.js"></script>' . "\n" . $context['str'];
|
||||
}
|
||||
} else {
|
||||
echo '<br/>
|
||||
In this section you can upload any file .sp and the website will automaticly highlight the codes in a easy way to understang it.<br/><small>Function still beta.</small><br/><br/>
|
||||
|
||||
Upload a file:
|
||||
<form action="index.php?action=codehigh&goon" method="post" enctype="multipart/form-data">
|
||||
<input name="uploadedfile" type="file" size="80"/><br/>
|
||||
<br><h1 style="color:red">OR</h1><br/>
|
||||
Enter the code here:<br/>
|
||||
<textarea name="signature" rows="12" cols="80"></textarea><br/>
|
||||
<input type="submit" value="Submit" />
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user