add Web Page

This commit is contained in:
dennydai 2016-02-26 23:33:00 +08:00
parent c7198386eb
commit f68cea8903
3 changed files with 57 additions and 2 deletions

View File

@ -3,7 +3,7 @@ class Base
{ {
public function msg($id, $msg) public function msg($id, $msg)
{ {
echo $msg; echo "<pre>".$msg;
return; return;
} }
} }

View File

@ -2,4 +2,10 @@
$BOT = new Base; $BOT = new Base;
$from = 'WebClient'; $from = 'WebClient';
$text = $_GET['c']; if (file_get_contents("php://input")) {
$text = file_get_contents("php://input");
}elseif (!empty($_SERVER['QUERY_STRING'])){
$text = $_SERVER['QUERY_STRING'];
}else{
exit;
}

49
index.php Normal file
View File

@ -0,0 +1,49 @@
<?php
//init
$Pre_Type = 'Web';
require_once('config.php');
$plugins = array();
require(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'Base.php');
require_once(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'init.php');
//load plugins
$load_plugins = glob(PATH.'plugins'.DIRECTORY_SEPARATOR.'*.php');
foreach ($load_plugins as $key => $value) {
if ($value == PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php') {
unset($load_plugins[$key]);
}
}
foreach ($TAGs as $TAG) {
foreach ($load_plugins as $value) {
$plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4);
if (preg_match("/^(".preg_quote($TAG, '/').$plugin_name."|".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.") (.*)$/", $text, $matches)) {
$plugin_text = $matches[2];
$plugin_sendto = $from;
if (!empty($plugin_text)){
require_once $value;
}else{
$BOT->msg($plugin_sendto, "Missing argument(s)");
}
break;
}elseif (preg_match("/^(".preg_quote($TAG, '/').$plugin_name.")|(".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) {
$plugin_text = $matches[2];
$plugin_sendto = $from;
if (!empty($plugin_text)){
require_once $value;
}else{
$BOT->msg($plugin_sendto, "Missing argument(s)");
}
break;
}
}
}
require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php';
//function
function PluginSet($desc){
global $plugins,$plugin_name,$TAG;
$plugins[] .= $TAG.$plugin_name." ".$desc;
}
?>