Restore legacy webig, ref kaetemi/ryzomclassic#4
@ -0,0 +1,403 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('../login/config.php');
|
||||
|
||||
// LOG database
|
||||
$StatsDBHost = $DBHost;
|
||||
$StatsDBUserName = $DBUserName;
|
||||
$StatsDBPassword = $DBPassword;
|
||||
$StatsDBName = "stats";
|
||||
|
||||
error_reporting(E_ERROR | E_PARSE);
|
||||
set_error_handler('err_callback');
|
||||
|
||||
// global var
|
||||
$link = NULL;
|
||||
$page_max = 100;
|
||||
$dev_ip="192.168.1.169"; //ip where sql error are displayed
|
||||
$private_network = "/192\.168\.1\./i"; //ip where the cmd=log&msg=dump function works
|
||||
$page_name = "stats.php";
|
||||
|
||||
|
||||
|
||||
//get the ip of the viewer
|
||||
function getIp()
|
||||
{
|
||||
if (getenv("HTTP_CLIENT_IP"))
|
||||
{
|
||||
$ip = getenv("HTTP_CLIENT_IP");
|
||||
}
|
||||
elseif(getenv("HTTP_X_FORWARDED_FOR"))
|
||||
{
|
||||
$ip = getenv("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
else
|
||||
{
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
}
|
||||
return $ip;
|
||||
}
|
||||
|
||||
|
||||
// if the player ip is the dev ip then the sql error is explain
|
||||
function die2($debug_str)
|
||||
{
|
||||
global $private_network;
|
||||
if ( preg_match($private_network, getIp()) )
|
||||
{
|
||||
die($debug_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
die("GENERIC_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
// get head or post infos return default if no valuees
|
||||
function getPost($value, $default=NULL)
|
||||
{
|
||||
if ( isSet($_GET[$value]) ) { return $_GET[$value]; }
|
||||
if ( isSet($_POST[$value]) ) { return $_POST[$value]; }
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
// log error in bdd
|
||||
function debug($str)
|
||||
{
|
||||
global $StatsDBHost;
|
||||
global $StatsDBUserName;
|
||||
global $StatsDBPassword;
|
||||
global $StatsDBName;
|
||||
global $link;
|
||||
|
||||
$newConnection = 0;
|
||||
|
||||
if ($link == NULL)
|
||||
{
|
||||
$link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." Can't connect to database host:$StatsDBHost user:$StatsDBUserName");
|
||||
$newConnection = 1;
|
||||
|
||||
mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." Can't access to the table dbname:$StatsDBName");
|
||||
}
|
||||
|
||||
|
||||
$str = str_replace("'", "", $str);
|
||||
$str = str_replace( '"', "", $str);
|
||||
|
||||
|
||||
$query= "INSERT INTO `log` ( `log` )"
|
||||
. "VALUES ("
|
||||
. "'$str'"
|
||||
. ")";
|
||||
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
if ($newConnection == 1)
|
||||
{
|
||||
mysql_close($link);
|
||||
$link = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
function err_callback($errno, $errmsg, $filename, $linenum, $vars)
|
||||
{
|
||||
debug("$filename $linenum $errmsg");
|
||||
}
|
||||
|
||||
|
||||
// debug( getenv("QUERY_STRING") );
|
||||
|
||||
// extract the cmd
|
||||
$cmd = getPost("cmd" ,"log");
|
||||
if ($cmd == "")
|
||||
{
|
||||
echo "0:Missing cmd";
|
||||
die2();
|
||||
}
|
||||
|
||||
// check for 'clear password' tag
|
||||
switch ($cmd)
|
||||
{
|
||||
// log <=> display php page
|
||||
case "log":
|
||||
$date = date('Y-m-d H:i:s', time());
|
||||
$ip = getIp();
|
||||
$log = getenv("QUERY_STRING");
|
||||
$link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." Can't connect to database host:$StatsDBHost user:$StatsDBUserName");
|
||||
mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." Can't access to the table dbname:$StatsDBName");
|
||||
|
||||
|
||||
$msg = getPost("msg", "");
|
||||
switch ($msg)
|
||||
{
|
||||
//display php infos
|
||||
|
||||
|
||||
|
||||
case "start_download":
|
||||
|
||||
$query = "SELECT max(`session_id`) as `res` from `sessions`";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
$session_id = 1000;
|
||||
if( mysql_num_rows($result) != 0)
|
||||
{
|
||||
$row = mysql_fetch_array($result);
|
||||
$session_id = $row["res"] + 1;
|
||||
}
|
||||
|
||||
$now = date("Y-m-d H:i:s", time());
|
||||
$server = getPost("server", "");
|
||||
$application = getPost("application", "");
|
||||
$version = getPost("version", "");
|
||||
$lang = getPost("lang","");
|
||||
$type = getPost("application", "");
|
||||
$package = getPost("package", "");
|
||||
$protocol = getPost("protocol", "");
|
||||
$size_download =getPost("size_download", "");
|
||||
$size_install = getPost("size_install", "");
|
||||
$user_id = getPost("user_id", "0");
|
||||
$previous_download = getPost("previous_download", "0");
|
||||
|
||||
|
||||
$query= "INSERT INTO `sessions` ( `session_id`, `user_id` , `server`, `application`, `ip` , `lang`, `type`, `package`, `protocol`, `size_download`, `size_install`, `start_download`, `stop_download`, `previous_download` )"
|
||||
|
||||
. "VALUES ("
|
||||
. "'$session_id', '$user_id' ,'$server', '$application', '$ip', '$lang', '$type', '$package', '$protocol', '$size_download', '$size_install', '$now', '$now', '$previous_download'"
|
||||
. ")";
|
||||
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
|
||||
|
||||
$query= "UPDATE `install_users` set install_count = install_count + 1, state='DU_DL', last_install='$now' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
|
||||
echo "<session_id>".$session_id."</session_id>";
|
||||
break;
|
||||
|
||||
case "stop_download":
|
||||
|
||||
$session_id =getPost("session_id", "0");
|
||||
$now = date("Y-m-d H:i:s", time());
|
||||
$query = "UPDATE `sessions` SET `stop_download` = '$now', `percent_download` ='100' WHERE `session_id` = '$session_id' LIMIT 1";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_IN' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
|
||||
break;
|
||||
// update the percent of download
|
||||
case "update_download":
|
||||
|
||||
$session_id =getPost("session_id", "0");
|
||||
$percent = getPost("percent", "0");
|
||||
$now = date("Y-m-d H:i:s", time());
|
||||
$query = "UPDATE `sessions` SET `percent_download` ='$percent', `stop_download` = '$now' WHERE `session_id` = '$session_id' LIMIT 1";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
// update the percent of finish
|
||||
case "update_install":
|
||||
|
||||
$now = date("Y-m-d H:i:s", time());
|
||||
$session_id =getPost("session_id", "0");
|
||||
$percent = getPost("percent", "0");
|
||||
$query = "UPDATE `sessions` SET `percent_install` ='$percent', `stop_download` = '$now' WHERE `session_id` = '$session_id' LIMIT 1";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case "no_install":
|
||||
|
||||
$session_id = getPost("session_id", "0");
|
||||
$now = date("Y-m-d H:i:s", time());
|
||||
$query = "UPDATE `sessions` SET `size_download` = '0', `start_install` = '$now', `stop_install` = '$now', `percent_install` ='100' WHERE `session_id` = '$session_id' LIMIT 1";
|
||||
echo $query;
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
// install is finished
|
||||
case "stop_install":
|
||||
$session_id = getPost("session_id", "0");
|
||||
$now = date("Y-m-d H:i:s", time());
|
||||
$query = "UPDATE `sessions` SET `stop_install` = '$now', `stop_download` = '$now', `percent_install` ='100' WHERE `session_id` = '$session_id' LIMIT 1";
|
||||
echo $query;
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_FI' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
// addd user info to database
|
||||
case "start_install":
|
||||
$session_id = getPost("session_id", "");
|
||||
$now = date("Y-m-d H:i:s", time());
|
||||
$query = "UPDATE `sessions` SET `start_install` = '$now', `stop_download` = '$now' WHERE `session_id` = '$session_id' LIMIT 1";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
|
||||
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_IN' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
case "login_step_video_mode_setup":
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_VMS' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
case "login_step_video_mode_setup_high_color":
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_VMSHS' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
case "login_step_login_screen":
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_AL' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
case "login_step_post_login":
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_PL' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
case "login_step_character_selection":
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_CS' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
case "login_step_game_entry":
|
||||
$user_id = getPost("user_id", "0");
|
||||
$query= "UPDATE `install_users` set state='DU_AG' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
break;
|
||||
|
||||
|
||||
case "login_step_game_exit":
|
||||
$user_id = getPost("user_id", "0");
|
||||
$play_time = getPost("play_time", "0");
|
||||
// manualy estimate the duration of the previous session
|
||||
{
|
||||
$query = "SELECT `state` from install_users where `user_id` = '$user_id'";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
$state = "AG";
|
||||
if( mysql_num_rows($result) > 0)
|
||||
{
|
||||
$row = mysql_fetch_array($result);
|
||||
$state = $row["state"];
|
||||
}
|
||||
|
||||
if ($state == "DU_P1")
|
||||
{
|
||||
$play_time = $play_time + 30 *60;
|
||||
}
|
||||
else if ($state == "DU_P2")
|
||||
{
|
||||
$play_time = $play_time + 60* 60;
|
||||
}
|
||||
else if ($state == "DU_P3")
|
||||
{
|
||||
$play_time = $play_time + 2*60* 60; // P3 will stat P3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($play_time > 2*60*60) // time played > 2 h
|
||||
{
|
||||
$query= "UPDATE `install_users` set state='DU_P3' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
}
|
||||
else if ($play_time > 60*60) // time played > 2 h
|
||||
{
|
||||
$query= "UPDATE `install_users` set state='DU_P2' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
}
|
||||
else if ($play_time > 30*60) // time played > 30 m
|
||||
{
|
||||
$query= "UPDATE `install_users` set state='DU_P1' where user_id='$user_id';";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
}
|
||||
break;
|
||||
|
||||
// addd user info to database
|
||||
case "init":
|
||||
$query = "SELECT max(`user_id`) as max_id from `install_users`";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
$user_id = 1;
|
||||
if( mysql_num_rows($result) != 0)
|
||||
{
|
||||
$row = mysql_fetch_array($result);
|
||||
$user_id = $row["max_id"] + 1;
|
||||
}
|
||||
|
||||
$install_id = getPost("install_id", "0");
|
||||
$os = getPost("os", "Unknown");
|
||||
$proc = getPost("proc", "Unknown");
|
||||
$memory = getPost("memory", "Unknown");
|
||||
$video_card = getPost("video_card", "Unknown");
|
||||
$driver_version = getPost("driver_version", "Unknown");
|
||||
|
||||
$query = "INSERT INTO `install_users` SET `user_id` = '$user_id', `install_id`='$install_id', `os`='$os', `proc`='$proc', `memory`='$memory', `video_card`='$video_card', `driver_version`='$driver_version', `last_install`='".date('Y-m-d H:i:s', time()) . "', `first_install`=`last_install`";
|
||||
|
||||
|
||||
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
echo "<user_id>$user_id</user_id>";
|
||||
break;
|
||||
|
||||
// first log if empyt user_id is return then must init
|
||||
case "login":
|
||||
$install_id = getPost("install_id", "0");
|
||||
$query = "SELECT `user_id` from install_users where `install_id` = '$install_id'";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
|
||||
if( mysql_num_rows($result) == 0)
|
||||
{
|
||||
echo "<user_id></user_id>";
|
||||
break;
|
||||
}
|
||||
$row = mysql_fetch_array($result);
|
||||
$user_id = $row["user_id"];
|
||||
echo "<user_id>$user_id</user_id>";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
echo "unknown command: $msg $log";
|
||||
}
|
||||
|
||||
|
||||
mysql_close($link);
|
||||
unset($link);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "0:Unknown command";
|
||||
die2();
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -0,0 +1,939 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('../login/config.php');
|
||||
|
||||
// LOG database
|
||||
$StatsDBHost = $DBHost;
|
||||
$StatsDBUserName = $DBUserName;
|
||||
$StatsDBPassword = $DBPassword;
|
||||
$StatsDBName = "stats";
|
||||
|
||||
error_reporting(E_ERROR | E_PARSE);
|
||||
set_error_handler('err_callback');
|
||||
|
||||
// for error handling, buffer all output
|
||||
|
||||
$link = NULL;
|
||||
$page_name="stats_query.php";
|
||||
$page_max = 50;
|
||||
$dev_ip="192.168.1.169"; //ip WHERE sql error are displayed
|
||||
// $private_network = "/192\.168\.1\./i"; //ip WHERE the cmd=view function works
|
||||
|
||||
|
||||
function toHMS($time)
|
||||
{
|
||||
$ret = "";
|
||||
if ($time <= 0) { return "0 s";}
|
||||
if ($time > 60*60*24)
|
||||
{
|
||||
$days = floor($time / (60*60*24));
|
||||
$time = floor($time - $days * 60*60*24);
|
||||
if ($days != 0) {
|
||||
$ret = $ret . $days . "d ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($time > 60*60)
|
||||
{
|
||||
$hours = floor($time / (60*60));
|
||||
$time = floor($time - $hours * 60*60);
|
||||
if ($hours != 0) {
|
||||
$ret = $ret . $hours . "h ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($time > 60)
|
||||
{
|
||||
$mins = floor($time / 60);
|
||||
$time = floor($time - $mins * 60);
|
||||
if ($mins != 0) {
|
||||
$ret = $ret . $mins . "m ";
|
||||
}
|
||||
}
|
||||
if ($time != 0) {
|
||||
$ret = $ret . $time . "s ";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
//get the ip of the viewer
|
||||
function getIp()
|
||||
{
|
||||
if (getenv("HTTP_CLIENT_IP"))
|
||||
{
|
||||
$ip = getenv("HTTP_CLIENT_IP");
|
||||
}
|
||||
elseif(getenv("HTTP_X_FORWARDED_FOR"))
|
||||
{
|
||||
$ip = getenv("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
else
|
||||
{
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
}
|
||||
return $ip;
|
||||
}
|
||||
|
||||
|
||||
// if the player ip is the dev ip then the sql error is explain
|
||||
function die2($debug_str)
|
||||
{
|
||||
// global $private_network;
|
||||
// if ( preg_match($private_network, getIp()) )
|
||||
// {
|
||||
die($debug_str);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// die("GENERIC_ERROR");
|
||||
// }
|
||||
}
|
||||
|
||||
// get head or post infos return default if no valuees
|
||||
function getPost($value, $default=NULL)
|
||||
{
|
||||
if ( isSet($_GET[$value]) ) { return $_GET[$value]; }
|
||||
if ( isSet($_POST[$value]) ) { return $_POST[$value]; }
|
||||
return $default;
|
||||
}
|
||||
|
||||
$cmd = getPost("cmd", "view");
|
||||
|
||||
$show_dl=getPost("show_dl", "1");
|
||||
$show_ddl=getPost("show_ddl", "1");
|
||||
$show_du=getPost("show_du", "1");
|
||||
$show_hdu=getPost("show_hdu", "1");
|
||||
$show_hdu2=getPost("show_hdu2", "1");
|
||||
$show_hddetails=getPost("show_hddetails", "0");
|
||||
|
||||
function getHref()
|
||||
{
|
||||
|
||||
global $show_dl;
|
||||
global $show_ddl;
|
||||
global $show_du;
|
||||
global $show_hdu;
|
||||
global $show_hdu2;
|
||||
global $selected;
|
||||
global $page_name;
|
||||
global $display;
|
||||
global $show_hddetails;
|
||||
return "$page_name?cmd=view&show_dl=$show_dl&show_ddl=$show_ddl&show_du=$show_du&show_hdu=$show_hdu&show_hdu2=$show_hdu2&selected=$selected&display=$display&show_hddetails=$show_hddetails";
|
||||
}
|
||||
|
||||
|
||||
// do a simple sql query return the result of the query
|
||||
function getSimpleQueryResult($query, &$link)
|
||||
{
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: $query<br/>".mysql_error()."<br/> ");
|
||||
|
||||
if ( ($row = mysql_fetch_array($result)) )
|
||||
{
|
||||
return $row["ret"];
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// log error in bdd
|
||||
function debug($str)
|
||||
{
|
||||
global $StatsDBHost;
|
||||
global $StatsDBUserName;
|
||||
global $StatsDBPassword;
|
||||
global $StatsDBName;
|
||||
global $link;
|
||||
|
||||
$newConnection = 0;
|
||||
|
||||
if ($link == NULL)
|
||||
{
|
||||
$link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." can't connect to database host:$StatsDBHost user:$StatsDBUserName");
|
||||
$newConnection = 1;
|
||||
|
||||
mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." can't access to the table dbname:$StatsDBName");
|
||||
}
|
||||
|
||||
|
||||
$str = str_replace("'", "", $str);
|
||||
$str = str_replace( '"', "", $str);
|
||||
|
||||
|
||||
$query= "INSERT INTO `log` ( `log` )"
|
||||
. "VALUES ("
|
||||
. "'$str'"
|
||||
. ")";
|
||||
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
if ($newConnection == 1)
|
||||
{
|
||||
mysql_close($link);
|
||||
$link = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
function err_callback($errno, $errmsg, $filename, $linenum, $vars)
|
||||
{
|
||||
echo "error: line $linenum, $errmsg <br/>";
|
||||
// debug($errmsg);
|
||||
}
|
||||
|
||||
//extract infos FROM sessions
|
||||
function getStats($mode, $day, &$link)
|
||||
{
|
||||
|
||||
$day2 = date('Y-m-d', $day);
|
||||
$day_first = date('Y-m-d H:i:s', strtotime( date('Y-m-d', $day) ) );
|
||||
$day_last = date('Y-m-d H:i:s', strtotime(date('Y-m-d', $day + 3600*24)) - 1);
|
||||
$condition1 = "install_users.first_install >= '$day_first' AND install_users.first_install <= '$day_last' ";
|
||||
$condition2 = "`sessions`.`start_download` >= '$day_first' AND `sessions`.`start_download` <= '$day_last' ";
|
||||
|
||||
if (!isSet($condition))
|
||||
{
|
||||
$condition = "1";
|
||||
}
|
||||
$ret = array();
|
||||
|
||||
if ($mode == 2)
|
||||
{
|
||||
|
||||
// false = not optimized
|
||||
if (true)
|
||||
{
|
||||
//true == optimized: Request is optimized we use one query instead of many
|
||||
$query = "SELECT "
|
||||
."SUM(IF(install_users.state = 'DU_P3', 1, 0)) AS DU_P3, "
|
||||
."SUM(IF(install_users.state = 'DU_P2', 1, 0)) AS DU_P2, "
|
||||
."SUM(IF(install_users.state = 'DU_P1', 1, 0)) AS DU_P1, "
|
||||
."SUM(IF(install_users.state = 'DU_AG', 1, 0)) AS DU_AG, "
|
||||
."SUM(IF(install_users.state = 'DU_CS', 1, 0)) AS DU_CS, "
|
||||
."SUM(IF(install_users.state IN ('DU_AL', 'DU_PL' ), 1, 0)) AS DU_AL, "
|
||||
."SUM(IF(install_users.state IN ('DU_FI', 'DU_VMS', 'DU_VMSHS' ), 1, 0)) AS DU_FI,"
|
||||
."SUM(IF(install_users.state = 'DU_IN', 1, 0)) AS DU_IN, "
|
||||
."SUM(IF(install_users.state = 'DU_DL', 1, 0)) AS DU_DL "
|
||||
."FROM install_users "
|
||||
."WHERE $condition1 "
|
||||
."AND install_users.user_id "
|
||||
."IN ( SELECT sessions.user_id FROM sessions WHERE $condition2 )";
|
||||
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
if ( ($row = mysql_fetch_array($result)) )
|
||||
{
|
||||
|
||||
$ret["DU_P3"] = $row["DU_P3"];
|
||||
$ret["DU_P2"] = $row["DU_P2"] + $ret["DU_P3"];
|
||||
$ret["DU_P1"] = $row["DU_P1"] + $ret["DU_P2"];
|
||||
$ret["DU_AG"] = $row["DU_AG"] + $ret["DU_P1"];
|
||||
$ret["DU_CS"] = $row["DU_CS"] + $ret["DU_AG"];
|
||||
$ret["DU_AL"] = $row["DU_AL"] + $ret["DU_CS"];
|
||||
$ret["DU_FI"] = $row["DU_FI"] + $ret["DU_AL"];
|
||||
$ret["DU_IN"] = $row["DU_IN"] + $ret["DU_FI"];
|
||||
$ret["DU_DL"] = $row["DU_DL"] + $ret["DU_IN"];
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$ret["DU_P3"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_P3'", $link) ;
|
||||
$ret["DU_P2"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_P2'", $link) + $ret['DU_P3'];
|
||||
$ret["DU_P1"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_P1'", $link) + $ret['DU_P2'];
|
||||
$ret["DU_AG"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_AG'", $link) + $ret['DU_P1'];
|
||||
$ret["DU_CS"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`= 'DU_CS'", $link) + $ret['DU_AG'];
|
||||
$ret["DU_AL"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state` IN ('DU_AL', 'DU_PL' ) ", $link) + $ret['DU_CS'];
|
||||
$ret["DU_FI"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state` IN ('DU_FI', 'DU_VMS', 'DU_VMSHS' )", $link) + $ret['DU_AL'];
|
||||
$ret["DU_IN"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_IN'", $link) + $ret['DU_FI'];
|
||||
$ret["DU_DL"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_DL'", $link) + $ret['DU_IN'];
|
||||
}
|
||||
}
|
||||
|
||||
$ret["all_session"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2", $link);
|
||||
|
||||
if ($mode == 1)
|
||||
{
|
||||
|
||||
$ret["distinct_user"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(sessions.user_id)) AS ret FROM `sessions` WHERE $condition2 ORDER BY sessions.user_id", $link);
|
||||
//true == optimized: Request is optimized we use one query instead of many
|
||||
if (true)
|
||||
{
|
||||
$query = "SELECT"
|
||||
. " COUNT(session_id) AS all_session,"
|
||||
. " SUM(IF(sessions.previous_download IN ('0', '0.00B', '0.000B'), 1, 0)) AS clean_start,"
|
||||
. " SUM(IF(sessions.percent_download = '100', 1, 0)) AS download_finished,"
|
||||
. " SUM(IF(sessions.percent_install = '100', 1, 0)) AS install_finished,"
|
||||
. " SUM(IF(sessions.package = 'full', 1, 0)) AS download_full,"
|
||||
. " SUM(IF(sessions.lang = 'fr', 1, 0)) AS fr,"
|
||||
. " SUM(IF(sessions.lang = 'en', 1, 0)) AS en,"
|
||||
. " SUM(IF(sessions.lang = 'de', 1, 0)) AS de"
|
||||
. " FROM sessions"
|
||||
. " WHERE $condition2";
|
||||
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
if ( ($row = mysql_fetch_array($result) ) )
|
||||
{
|
||||
$ret["all_session"] = $row["all_session"];
|
||||
$ret["clean_start"] = $row["clean_start"];
|
||||
$ret["download_finished"] = $row["download_finished"];
|
||||
$ret["install_finished"] = $row["install_finished"];
|
||||
$ret["download_full"] = $row["download_full"];
|
||||
$ret["fr"] = $row["fr"];
|
||||
$ret["en"] = $row["en"];
|
||||
$ret["de"] = $row["de"];
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$ret["clean_start"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND previous_download IN ('0', '0.000b', '0.00B')", $link);
|
||||
$ret["download_finished"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `percent_download` = '100'", $link);
|
||||
$ret["install_finished"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `percent_install` = '100' ", $link);
|
||||
$ret["download_full"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `package` = 'full'", $link);
|
||||
$ret["fr"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `lang` = 'fr'", $link);
|
||||
$ret["en"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `lang` = 'en'", $link);
|
||||
$ret["de"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `lang` = 'de'", $link);
|
||||
}
|
||||
$ret["restart"] = $ret['all_session'] - $ret['clean_start'];
|
||||
|
||||
}
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// display download infos
|
||||
// condition is the condition for displaying users (time condition)
|
||||
// max_reslut is the number of result that could be displayed
|
||||
function displayDownload($link)
|
||||
{
|
||||
global $show_dl;
|
||||
global $selected;
|
||||
|
||||
$date = getdate($selected);
|
||||
$date_first = date('Y-m-d H:i:s', strtotime( date('Y-m-1', $selected) ) );
|
||||
$date_first_int = strtotime($date_first);
|
||||
$date_last = date('Y-m-d H:i:s', strtotime(date('Y-m-1', $selected + 31*24*3600)) - 1);
|
||||
$date_last_int = strtotime($date_last);
|
||||
$nbday = round( ($date_last_int +1 - $date_first_int ) / (24*3600));
|
||||
|
||||
//display sumary infos (if title clicked make apears or disapears the menu)
|
||||
$old_value = $show_dl;
|
||||
$show_dl = !$show_dl;
|
||||
echo '<h2><a href="'.getHref().'">downloads</a></h2>';
|
||||
$show_dl = $old_value;
|
||||
|
||||
if ($show_dl == 1)
|
||||
{
|
||||
|
||||
|
||||
echo '<table summary="texte">'."\n";
|
||||
echo "<tr>\n"
|
||||
. "<th>week day</th>\n"
|
||||
. "<th>".$date['month']. " ".$date['year']."</th>\n"
|
||||
. "<th>distinct users(today)</th>\n"
|
||||
. "<th>first start</th>\n"
|
||||
. "<th>restart</th>\n"
|
||||
. "<th>total download</th>\n"
|
||||
. "<th>download finished</th>\n"
|
||||
. "<th>install finished</th>\n"
|
||||
. "<th>full version</th>\n"
|
||||
. "<th>fr</th>\n"
|
||||
. "<th>en</th>\n"
|
||||
. "<th>de</th>\n"
|
||||
. "</tr>\n";
|
||||
|
||||
|
||||
// for each day of the month with download display infos
|
||||
for ($i = 0; $i < $nbday; $i++)
|
||||
{
|
||||
$day = $date_first_int + $i*24*3600;
|
||||
|
||||
if ($day >= time())// + 24*3600)
|
||||
{
|
||||
break;
|
||||
}
|
||||
$day_first = date('Y-m-d H:i:s', strtotime( date('Y-m-d', $day) ) );
|
||||
$day_last = date('Y-m-d H:i:s', strtotime(date('Y-m-d', $day + 3600*24)) - 1);
|
||||
|
||||
$res = getStats(1, $day, $link);
|
||||
$date_today = getdate($day);
|
||||
// display only if active download
|
||||
if ($res['all_session'] != 0 )
|
||||
{
|
||||
|
||||
echo "<tr>\n"
|
||||
|
||||
. "<td>".$date_today['weekday']."</td>";
|
||||
|
||||
|
||||
if (date('Y-m-d', $day)==date('Y-m-d', $selected))
|
||||
{
|
||||
echo "<td>".($i+1)."</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<td><a href=\"".getHref()."&selected=$day\">".($i+1)."</a></td>";
|
||||
}
|
||||
|
||||
echo "<td>".$res['distinct_user']."</td>"
|
||||
//. "<td>".$res['all_session']."</td>"
|
||||
. "<td>".$res['clean_start']."</td>"
|
||||
. "<td>".$res['restart']."</td>"
|
||||
. "<td>".($res['restart'] + $res['clean_start'])." (". $res['clean_start']. "+" . $res['restart'] .")</td>"
|
||||
|
||||
. "<td>".$res['download_finished']."</td>"
|
||||
. "<td>".$res['install_finished']."</td>"
|
||||
. "<td>".$res['download_full']."</td>"
|
||||
. "<td>".$res['fr']."</td>"
|
||||
. "<td>".$res['en']."</td>"
|
||||
. "<td>".$res['de']."</td>"
|
||||
. "</tr>\n";
|
||||
}
|
||||
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
//display next mont, prev month link
|
||||
echo '<a href="'.getHref().'&page_users=1&page_users2=1&page_download=1&selected='.strtotime(date('Y-m-1', $selected-1)).'">'." < last month". '</a> ';
|
||||
echo ", ";
|
||||
echo '<a href="'.getHref().'&page_users=1&page_users2=1&page_download=1&selected='.strtotime(date('Y-m-1', $selected+31*24*3600)).'">'."next month >". '</a> ';
|
||||
}
|
||||
}
|
||||
|
||||
function displayDistinctUsers($link)
|
||||
{
|
||||
global $show_du;
|
||||
global $selected;
|
||||
|
||||
$date = getdate($selected);
|
||||
$date_first = date('Y-m-d H:i:s', strtotime( date('Y-m-1', $selected) ) );
|
||||
$date_first_int = strtotime($date_first);
|
||||
$date_last = date('Y-m-d H:i:s', strtotime(date('Y-m-1', $selected + 31*24*3600)) - 1);
|
||||
$date_last_int = strtotime($date_last);
|
||||
$nbday = round( ($date_last_int +1 - $date_first_int ) / (24*3600));
|
||||
|
||||
// when click on title, the content apears or disapers
|
||||
$old_value = $show_du;
|
||||
$show_du = !$show_du;
|
||||
echo '<h2><a href="'.getHref().'">distinct new users</a></h2>';
|
||||
$show_du = $old_value;
|
||||
|
||||
if ($show_du == 1)
|
||||
{
|
||||
echo '<table summary="texte">'."\n";
|
||||
echo "<tr>\n"
|
||||
. "<th>week day</th>\n"
|
||||
. "<th>".$date['month']. " ".$date['year']."</th>\n"
|
||||
. "<th>started dl</th>\n"
|
||||
. "<th>finished dl</th>\n"
|
||||
. "<th>finished inst</th>\n"
|
||||
. "<th>arrive login</th>\n"
|
||||
. "<th>arrive char sel</th>\n"
|
||||
. "<th>arrive in game</th>\n"
|
||||
. "<th>play 30 min</th>\n"
|
||||
. "<th>play 1hr</th>\n"
|
||||
. "<th>play 2hr</th>\n"
|
||||
. "</tr>\n";
|
||||
for ($i = 0; $i < $nbday; $i++)
|
||||
{
|
||||
|
||||
$day = $date_first_int + $i*24*3600;
|
||||
if ($day >= time())// + 24*3600)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// $row = getStats("`sessions`.`start_download` >= '$day_first' AND `sessions`.`start_download` <= '$day_last' ", $link);
|
||||
$row = getStats(2, $day, $link);
|
||||
|
||||
$date_today = getdate($day);
|
||||
if ($row['all_session'] != 0)
|
||||
{
|
||||
echo "<tr>";
|
||||
|
||||
echo "<td>".$date_today['weekday']."</td>";
|
||||
if (date('Y-m-d', $day)==date('Y-m-d', $selected))
|
||||
{
|
||||
echo "<td>".($i+1)."</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<td><a href=\"".getHref()."&selected=$day\">".($i+1)."</a></td>";
|
||||
}
|
||||
|
||||
echo "<td>".$row["DU_DL"]."</td>\n";
|
||||
echo "<td>".$row["DU_IN"]."</td>\n";
|
||||
echo "<td>".$row["DU_FI"]."</td>\n";
|
||||
echo "<td>".$row["DU_AL"]."</td>\n";
|
||||
echo "<td>".$row["DU_CS"]."</td>\n";
|
||||
echo "<td>".$row["DU_AG"]."</td>\n";
|
||||
echo "<td>".$row["DU_P1"]."</td>\n";
|
||||
echo "<td>".$row["DU_P2"]."</td>\n";
|
||||
echo "<td>".$row["DU_P3"]."</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo '<a href="'.getHref().'&page_users=1&page_users2=1&page_download=1&selected='.strtotime(date('Y-m-1', $selected-1)).'">'." < last month". '</a> ';
|
||||
echo ", ";
|
||||
echo '<a href="'.getHref().'&page_users=1&page_users2=1&page_download=1&selected='.strtotime(date('Y-m-1', $selected+31*24*3600)).'">'."next month >". '</a> ';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function displayDownloadDetails($condition, $link)
|
||||
{
|
||||
global $page_max;
|
||||
global $show_ddl;
|
||||
global $page_download;
|
||||
global $page_users;
|
||||
global $page_users2;
|
||||
global $selected;
|
||||
|
||||
|
||||
$query = "SELECT COUNT(`session_id`) AS max"
|
||||
. " FROM `sessions`"
|
||||
. " WHERE $condition";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
$max_result = 0;
|
||||
if ( ($row = mysql_fetch_array($result)) ) { $max_result = $row["max"];}
|
||||
|
||||
//display sumary infos (if title clicked make apears or disapears the menu)
|
||||
$old_value = $show_ddl;
|
||||
$show_ddl = !$show_ddl;
|
||||
echo '<h2><a href="'.getHref().'">download details('.$max_result.')</a></h2>';
|
||||
$show_ddl = $old_value;
|
||||
if ($show_ddl == 1)
|
||||
{
|
||||
echo '<table summary="texte">'."\n";
|
||||
echo "<tr>\n"
|
||||
. "<th>user_id</th>\n"
|
||||
. "<th>ip</th>\n"
|
||||
. "<th>lang</th>\n"
|
||||
. "<th>sku</th>\n"
|
||||
. "<th>protocol</th>\n"
|
||||
. "<th>sz dl</th>\n"
|
||||
. "<th>sz inst</th>\n"
|
||||
. "<th>start</th>\n"
|
||||
. "<th>start inst</th>\n"
|
||||
. "<th>finish</th>\n"
|
||||
. "<th>time</th>\n"
|
||||
. "<th>% dl</th>\n"
|
||||
. "<th>% inst</th>\n"
|
||||
. "<th>prev dl</th>\n"
|
||||
. "</tr>\n";
|
||||
|
||||
$query = "SELECT COUNT(`session_id`) AS max FROM `sessions` WHERE $condition";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
$max_result=0;
|
||||
if ( ($row = mysql_fetch_array($result)) ) { $max_result = $row["max"]; }
|
||||
|
||||
|
||||
|
||||
$query = "SELECT `session_id` , `user_id` , `server` , `application` , `version` , `ip` , `lang` , `type` , `package` , `protocol` , `size_download` , `size_install` , `start_download` , `stop_download` , `start_install` , `stop_install` , `percent_download` , `percent_install` , `previous_download`"
|
||||
. " FROM `sessions`"
|
||||
. " WHERE $condition"
|
||||
. " ORDER by `user_id` desc, `start_download` desc"
|
||||
. " LIMIT ".($page_download * $page_max)." , ".$page_max;
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
|
||||
while ( ($row = mysql_fetch_array($result)) )
|
||||
{
|
||||
echo "<tr>";
|
||||
echo "<td>"
|
||||
.$row["user_id"]
|
||||
."</td>\n";
|
||||
echo "<td>".$row["ip"]."</td>\n";
|
||||
echo "<td>".$row["lang"]."</td>\n";
|
||||
echo "<td>".$row["package"]."</td>\n";
|
||||
echo "<td>".$row["protocol"]."</td>\n";
|
||||
echo "<td>".$row["size_download"]."</td>\n";
|
||||
echo "<td>".$row["size_install"]."</td>\n";
|
||||
echo "<td>".$row["start_download"]."</td>\n";
|
||||
echo "<td>".$row["start_install"]."</td>\n";
|
||||
echo "<td>".$row["stop_install"]."</td>\n";
|
||||
echo "<td>" . toHMS(strtotime($row["stop_download"]) - strtotime($row["start_download"]) ) ."</td>\n";
|
||||
echo "<td>".$row["percent_download"]."</td>\n";
|
||||
echo "<td>".$row["percent_install"]."</td>\n";
|
||||
echo "<td>".$row["previous_download"]."</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
for ($i = 1 ;$i < ($max_result / $page_max)+1; $i = $i+1)
|
||||
{
|
||||
if ($page_download + 1 == $i)
|
||||
{
|
||||
echo ($i)." ";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a href="'.getHref().'&page_users='.($page_users+1).'&page_users2='.($page_users2+1).'&page_download='.$i.'&selected='.$selected.'">'.($i). '</a> ';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function lastSession($id, $condition, $link)
|
||||
{
|
||||
$query = "SELECT install_users.user_id, sessions.session_id, sessions.stop_download, sessions.start_download, sessions.percent_download, sessions.percent_install "
|
||||
. " FROM install_users, sessions "
|
||||
. " WHERE install_users.user_id='" . $id . "' AND install_users.user_id = sessions.user_id AND $condition"
|
||||
. " ORDER BY sessions.session_id DESC";
|
||||
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
if ( ($row = mysql_fetch_array($result)) )
|
||||
{
|
||||
$ret["session_id"] = $row["session_id"];
|
||||
$ret["time"] = strtotime($row["stop_download"]) - strtotime($row["start_download"]) ;
|
||||
$ret["percent"] = $row["percent_download"] . "/". $row["percent_install"];
|
||||
return $ret;
|
||||
}
|
||||
$ret["time"] = "?";
|
||||
$ret["percent"] = "?";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// display infos on user hardware
|
||||
// condition is the condition for displaying users (time condition)
|
||||
function displayHardwareNewUserImpl($install_state, $title, $condition, $condition2, $link)
|
||||
{
|
||||
|
||||
global $page_max;
|
||||
global $page_users;
|
||||
global $page_users2;
|
||||
global $selected;
|
||||
global $show_hdu;
|
||||
global $show_hdu2;
|
||||
global $show_hddetails;
|
||||
|
||||
|
||||
// $query = "SELECT COUNT(install_users.user_id) AS max FROM install_users WHERE $condition2 AND install_users.user_id in (SELECT DISTINCT(sessions.user_id) from sessions where $condition)";
|
||||
$query = "SELECT COUNT(DISTINCT(sessions.user_id)) AS max FROM `install_users`,`sessions` WHERE $condition2 AND install_users.user_id = sessions.user_id AND $condition";
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
$max_result = 0;
|
||||
if ( ($row = mysql_fetch_array($result)) ) { $max_result = $row["max"];}
|
||||
|
||||
if ($install_state==1)
|
||||
{
|
||||
$old_value = $show_hdu;
|
||||
$show_hdu = 1-$show_hdu;
|
||||
echo '<h2><a href="'.getHref().'">Hardware users - Unfinished install ('.$max_result.')</a></h2>';
|
||||
$show_hdu = $old_value;
|
||||
$nbpages = $page_users;
|
||||
}
|
||||
else
|
||||
{
|
||||
$old_value = $show_hdu2;
|
||||
$show_hdu2 = 1-$show_hdu2;
|
||||
echo '<h2><a href="'.getHref().'">Hardware users - Finished install ('.$max_result.')</a></h2>';
|
||||
$show_hdu2 = $old_value;
|
||||
$nbpages = $page_users2;
|
||||
}
|
||||
|
||||
// Show / Hide os column
|
||||
{
|
||||
$old_value = $show_hddetails;
|
||||
$show_hddetails = 1 - $show_hddetails;
|
||||
if ($show_hddetails == 1)
|
||||
{
|
||||
echo '<h3><a href="'.getHref().'">Show details</a></h3>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<h3><a href="'.getHref().'">Hide details</a></h3>';
|
||||
}
|
||||
$show_hddetails = $old_value;
|
||||
}
|
||||
|
||||
|
||||
//display sumary infos (if title clicked make apears or disapears the menu)
|
||||
|
||||
if (($install_state==1 && $show_hdu == 1) || ($install_state==2 && $show_hdu2 == 1) )
|
||||
{
|
||||
|
||||
|
||||
echo '<table summary="texte">'."\n";
|
||||
echo "<tr>\n"
|
||||
. "<th>user_id</th>\n";
|
||||
if ($show_hddetails == 0)
|
||||
{
|
||||
|
||||
echo "<th>first_install</th>\n"
|
||||
. "<th>last_install</th>\n"
|
||||
. "<th>install_count</th>\n"
|
||||
. "<th>install time</th>\n"
|
||||
. "<th>last install time</th>\n";
|
||||
}
|
||||
if ($install_state) { echo "<th>last install state</th>\n"; }
|
||||
echo "<th>memory</th>\n";
|
||||
if ($show_hddetails == 1)
|
||||
{
|
||||
echo "<th>os</th>\n"
|
||||
. "<th>proc</th>\n"
|
||||
|
||||
. "<th>video_card</th>\n"
|
||||
. "<th>driver_version</th>\n";
|
||||
}
|
||||
|
||||
echo "<th>current state</th>\n"
|
||||
. "</tr>\n";
|
||||
|
||||
$query = "SELECT `install_users`.`user_id` , `install_users`.`first_install`, `install_users`.`last_install`, `install_users`.`install_count`, `install_users`.`os` , `install_users`.`proc` , `install_users`.`memory` , `install_users`.`video_card` , `install_users`.`driver_version`, `install_users`.`state`, "
|
||||
."SUM( IF(sessions.stop_download >sessions.start_download, UNIX_TIMESTAMP(sessions.stop_download) - UNIX_TIMESTAMP(sessions.start_download) , 0))AS waiting_time, count(sessions.session_id) AS install_count2"
|
||||
. " FROM `install_users`, `sessions`"
|
||||
. " WHERE `sessions`.`user_id` = `install_users`.`user_id` AND $condition AND $condition2"
|
||||
. " GROUP by `sessions`.`user_id`"
|
||||
. " ORDER by `sessions`.`user_id` desc"
|
||||
. " LIMIT ".($nbpages * $page_max)." , ".$page_max;
|
||||
$result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
|
||||
|
||||
|
||||
while ( ($row = mysql_fetch_array($result)) )
|
||||
{
|
||||
$ret = lastSession($row["user_id"], $condition, $link);
|
||||
echo "<tr>";
|
||||
echo "<td>".$row["user_id"]."</td>\n";
|
||||
if ($show_hddetails == 0)
|
||||
{
|
||||
echo "<td>".$row["first_install"]."</td>\n";
|
||||
echo "<td>".$row["last_install"]."</td>\n";
|
||||
echo "<td>".$row["install_count2"]."</td>\n";
|
||||
echo "<td>".toHMS($row["waiting_time"])."</td>\n";
|
||||
echo "<td>".toHMS($ret["time"])."</td>\n";
|
||||
}
|
||||
if ($install_state) { echo "<td>".$ret["percent"]."</td>\n"; }
|
||||
echo "<td>".$row["memory"]."</td>\n";
|
||||
if ($show_hddetails == 1)
|
||||
{
|
||||
echo "<td>".$row["os"]."</td>\n";
|
||||
echo "<td>".$row["proc"]."</td>\n";
|
||||
|
||||
echo "<td>".$row["video_card"]."</td>\n";
|
||||
echo "<td>".$row["driver_version"]."</td>\n";
|
||||
}
|
||||
echo "<td>".$row["state"]."</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
|
||||
}
|
||||
if (($install_state==1 && $show_hdu == 1) || ($install_state==2 && $show_hdu2 == 1) )
|
||||
{
|
||||
for ($i = 1 ;$i < ($max_result / $page_max)+1; $i = $i+1)
|
||||
{
|
||||
if ($nbpages + 1 == $i)
|
||||
{
|
||||
echo ($i)." ";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($install_state==1)
|
||||
{
|
||||
echo '<a href="'.getHref().'&page_users='.($i).'&page_users2='.($page_users2+1).'">'.($i). '</a> ';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a href="'.getHref().'&page_users='.($page_users+1).'&page_users2='.($i).'">'.($i). '</a> ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function displayHardwareNewUser($condition, $link)
|
||||
{
|
||||
|
||||
global $display;
|
||||
if ($display == 4)
|
||||
{
|
||||
displayHardwareNewUserImpl(1, "unfinished Install", $condition, " install_users.state IN ('DU_DL', 'DU_IN')", $link);
|
||||
}
|
||||
if ($display == 5)
|
||||
{
|
||||
displayHardwareNewUserImpl(2, "finished Install", $condition, " NOT (install_users.state IN ('DU_DL', 'DU_IN') )", $link);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// extract the cmd
|
||||
|
||||
if ($cmd == "")
|
||||
{
|
||||
echo "0:missing cmd";
|
||||
die2();
|
||||
}
|
||||
|
||||
// check for 'clear password' tag
|
||||
switch ($cmd)
|
||||
{
|
||||
// log <=> display php pabe
|
||||
case "view":
|
||||
$dt = gettimeofday();
|
||||
$date = date('Y-m-d H:i:s', time());
|
||||
$ip = getIp();
|
||||
$log = getenv("query_string");
|
||||
$link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." can't connect to database host:$StatsDBHost user:$StatsDBUserName");
|
||||
mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." can't access to the table dbname:$StatsDBName");
|
||||
|
||||
|
||||
//verify passwd AND ip is private
|
||||
// if (preg_match($private_network, getIp()) )
|
||||
{
|
||||
//xhtml header + style
|
||||
echo '<!doctype html public "-//w3c//dtd html 4.01 transitional//en>'."\n"
|
||||
. '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">'."\n";
|
||||
|
||||
|
||||
echo "<head><style =\"text/css\">\n";
|
||||
|
||||
echo "table {"
|
||||
. "border: medium solid #000000;"
|
||||
. "width: 100%;"
|
||||
|
||||
. " }";
|
||||
echo "th {"
|
||||
|
||||
. " border: thin solid #6495ed;"
|
||||
//. " width: 20%;"
|
||||
. " background-color:#fcc"
|
||||
. " }";
|
||||
|
||||
echo "td {"
|
||||
|
||||
. " border: thin solid #6495ed;"
|
||||
//. " width: 20%;"
|
||||
. " background-color:#eee;"
|
||||
. " }";
|
||||
|
||||
|
||||
|
||||
echo "a {"
|
||||
." color : #0033bb;"
|
||||
." text-decoration : none; "
|
||||
." }"
|
||||
."a:hover {"
|
||||
." text-decoration : underline;"
|
||||
."}";
|
||||
|
||||
echo "body {"
|
||||
. "padding-left: 5em;"
|
||||
. "margin-right:100px;"
|
||||
// . "width:850px;"
|
||||
. " }";
|
||||
|
||||
echo "h1 {"
|
||||
|
||||
. "text-align: center;"
|
||||
//. "padding-left: 10em;"
|
||||
. " }";
|
||||
|
||||
|
||||
echo "</style>\n";
|
||||
echo "</head>\n";
|
||||
echo "<body>\n";
|
||||
|
||||
//display summary stat by day for current month
|
||||
|
||||
$selected = getPost("selected", strtotime(date('Y-m-d', time())));
|
||||
$page_download = getPost("page_download", "1");
|
||||
$page_download = $page_download -1;
|
||||
if ($page_download < 0) { $page_download = 0;}
|
||||
$page_users = getPost("page_users", "1");
|
||||
$page_users = $page_users -1;
|
||||
$page_users2 = getPost("page_users2", "1");
|
||||
$page_users2 = $page_users2 -1;
|
||||
if ($page_users < 0) { $page_users = 0;}
|
||||
if ($page_users2 < 0) { $page_users2 = 0;}
|
||||
|
||||
|
||||
$date_first = date('Y-m-d H:i:s', strtotime( date('Y-m-1', $selected) ) );
|
||||
$date_first_int = strtotime($date_first);
|
||||
$date_last = date('Y-m-d H:i:s', strtotime(date('Y-m-1', $selected + 31*24*3600)) - 1);
|
||||
$date_last_int = strtotime($date_last);
|
||||
$nbday = round( ($date_last_int +1 - $date_first_int ) / (24*3600));
|
||||
|
||||
$display = getPost("display", "0");
|
||||
|
||||
$date = getdate($selected);
|
||||
// display server time
|
||||
echo "<h4>server time: ".date("Y-m-d H:i:s", time())."</h4>\n";
|
||||
|
||||
|
||||
|
||||
// display title
|
||||
echo '<h1>'.$date['weekday'].' '.$date['mday'].' '.$date['month'].' '.$date['year'].'</h1>';
|
||||
|
||||
echo '<h2><a href="'.getHref().'&display=1">downloads</a></h2>';
|
||||
echo '<h2><a href="'.getHref().'&display=2">distinct new users</a></h2>';
|
||||
echo '<h2><a href="'.getHref().'&display=3">download details</a></h2>';
|
||||
echo '<h2><a href="'.getHref().'&display=4">Hardware users - Unfinished install</a></h2>';
|
||||
echo '<h2><a href="'.getHref().'&display=5">Hardware users - Finished install</a></h2>';
|
||||
|
||||
echo "<hr/><br/>";
|
||||
/*
|
||||
to add display function copy a display* function (add a global variable to indicates if the content must be display
|
||||
add this variable to the getHref function
|
||||
*/
|
||||
if ($display==1)
|
||||
{
|
||||
displayDownload($link);
|
||||
}
|
||||
if ($display ==2)
|
||||
{
|
||||
displayDistinctUsers($link);
|
||||
}
|
||||
|
||||
//display current session
|
||||
|
||||
$current_day = date("Y-m-d", $selected);
|
||||
$next_day = date("Y-m-d", $selected + 24*3600);
|
||||
$condition = "`sessions`.`start_download` >= '$current_day' AND `sessions`.`start_download` < '$next_day'";
|
||||
if ($display == 3)
|
||||
{
|
||||
displayDownloadDetails($condition, $link);
|
||||
}
|
||||
$condition2 = "`install_users`.`first_install` >= '$current_day' AND `install_users`.`first_install` < '$next_day'";
|
||||
displayHardwareNewUser($condition2, $link);
|
||||
|
||||
$dt2= gettimeofday();
|
||||
echo "<br/><br/>computed in " . ( $dt2["sec"] - $dt["sec"] + ($dt2["usec"] - $dt["usec"]) / 1000000 ). "s";
|
||||
echo "</body>\n</html>\n";
|
||||
|
||||
mysql_close($link);
|
||||
unset($link);
|
||||
|
||||
} //end check ip
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "0:unknown command";
|
||||
die2();
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('thread_utils.php');
|
||||
include_once('mail_utils.php');
|
||||
include_once('admin_utils.php');
|
||||
|
||||
if (($user_login != "support" || ($remote_addr != "192.168.1.153" && $remote_addr != "192.168.3.1")) && $remote_addr != "127.0.0.1")
|
||||
{
|
||||
die();
|
||||
}
|
||||
|
||||
importParam('recover_forum');
|
||||
if ($recover_forum)
|
||||
{
|
||||
echo "recover forum $recover_forum<br>\n";
|
||||
recover_thread($recover_forum);
|
||||
die();
|
||||
}
|
||||
|
||||
importParam('recover_thread');
|
||||
importParam('recover_threadthread');
|
||||
if ($recover_thread && isset($recover_threadthread))
|
||||
{
|
||||
echo "recover forum $recover_thread<br>\n";
|
||||
recover_one_thread($recover_thread, $recover_threadthread);
|
||||
die();
|
||||
}
|
||||
|
||||
importParam('rename_forum');
|
||||
importParam('into_forum');
|
||||
if ($rename_forum)
|
||||
{
|
||||
echo "rename forum $rename_forum into $into_forum<br>\n";
|
||||
rename_forum($rename_forum, $into_forum);
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
importParam('shard');
|
||||
|
||||
importParam('mailbox');
|
||||
importParam('mail');
|
||||
|
||||
if ($mail)
|
||||
{
|
||||
$mdir = get_user_dir($mailbox, $shard);
|
||||
readfile($mdir.$mail);
|
||||
die();
|
||||
}
|
||||
else if ($mailbox)
|
||||
{
|
||||
display_mailbox_content($shard, $mailbox);
|
||||
die();
|
||||
}
|
||||
|
||||
importParam('forum');
|
||||
importParam('thread');
|
||||
|
||||
if ($thread)
|
||||
{
|
||||
display_thread_content($shard, $forum, $thread);
|
||||
die();
|
||||
}
|
||||
else if ($forum)
|
||||
{
|
||||
display_forum_content($shard, $forum);
|
||||
die();
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$server = "localhost";
|
||||
$port = 80;
|
||||
|
||||
// import HTTP_GET_VARS as _GET if _GET doesn't exist
|
||||
if (!isset($_GET) && isset($HTTP_GET_VARS))
|
||||
$_GET = &$HTTP_GET_VARS;
|
||||
|
||||
echo "<form method='get' action='$PHP_SELF'>\n";
|
||||
echo "SHARD: <input type='text' name='shard' value='".$_GET['shard']."'><br>\n";
|
||||
echo "MAILBOX: <input type='text' name='mailbox' value='".$_GET['mailbox']."'><br>\n";
|
||||
echo "FORUM: <input type='text' name='forum' value='".$_GET['forum']."'><br>\n";
|
||||
echo "<input type='submit' value='Retrieve'><br>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
if ($_GET["mailbox"])
|
||||
{
|
||||
echo "Get mailbox ".$_GET["mailbox"]." content:<br>\n";
|
||||
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
|
||||
fputs($s,"GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&mailbox=".$_GET["mailbox"]." HTTP/1.0\n\n");
|
||||
|
||||
while(!feof($s))
|
||||
{
|
||||
$l = trim(fgets($s, 2048));
|
||||
if (ereg("^FILE:(.*)", $l, $reg))
|
||||
echo "<a href=\"$PHP_SELF?shard=".$_GET["shard"]."&mailbox=".$_GET["mailbox"]."&mail=".$reg[1]."\">".$reg[1]."</a><br>\n";
|
||||
}
|
||||
|
||||
fclose($s);
|
||||
echo "<br><br>\n";
|
||||
}
|
||||
|
||||
if ($_GET["mail"])
|
||||
{
|
||||
echo "Get mail ".$_GET["mailbox"]."/".$_GET["mail"]." content:<br>\n";
|
||||
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
|
||||
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&mail=".$_GET["mail"]."&mailbox=".$_GET["mailbox"]." HTTP/1.0\n\n");
|
||||
|
||||
echo "Content of mail:<br>\n";
|
||||
while(!feof($s))
|
||||
echo nl2br(htmlentities(trim(fgets($s, 2048))));
|
||||
|
||||
fclose($s);
|
||||
echo "<br><br>\n";
|
||||
}
|
||||
|
||||
if ($_GET["recover_thread"])
|
||||
{
|
||||
echo "Recover thread ".$_GET["forum"]." ".$_GET["recover_thread"]."<br>\n";
|
||||
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
|
||||
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&recover_thread=".$_GET["forum"]."&recover_threadthread=".$_GET["recover_thread"]." HTTP/1.0\n\n");
|
||||
fclose($s);
|
||||
echo "<br><br>\n";
|
||||
}
|
||||
|
||||
if ($_GET["forum"])
|
||||
{
|
||||
echo "Get forum ".$_GET["forum"]." content:<br>\n";
|
||||
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
|
||||
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&forum=".$_GET["forum"]." HTTP/1.0\n\n");
|
||||
|
||||
while(!feof($s))
|
||||
{
|
||||
$l = trim(fgets($s, 2048));
|
||||
if (ereg("^FILE:(.*)", $l, $reg))
|
||||
{
|
||||
echo "<a href=\"$PHP_SELF?shard=".$_GET["shard"]."&forum=".$_GET["forum"]."&thread=".trim($reg[1])."\">".trim($reg[1])."</a>\n";
|
||||
if ($reg[1]{0} == '_')
|
||||
{
|
||||
echo " <a href=\"$PHP_SELF?shard=".$_GET["shard"]."&forum=".$_GET["forum"]."&recover_thread=".trim($reg[1])."\">recover thread</a>\n";
|
||||
}
|
||||
echo "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
fclose($s);
|
||||
echo "<br><br>\n";
|
||||
}
|
||||
|
||||
if ($_GET["thread"])
|
||||
{
|
||||
echo "Get thread ".$_GET["forum"]."/".$_GET["thread"]." content:<br>\n";
|
||||
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
|
||||
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&forum=".$_GET["forum"]."&thread=".$_GET["thread"]." HTTP/1.0\n\n");
|
||||
|
||||
echo "Content of thread:<br>\n";
|
||||
while(!feof($s))
|
||||
{
|
||||
$l = trim(fgets($s, 2048));
|
||||
if (ereg("^TOPIC:(.*) SUBMIT:(.*)$", $l, $reg))
|
||||
echo nl2br(htmlentities(" TOPIC:".$reg[1]."SUBMITED BY: ".$reg[2]."\n"));
|
||||
if (ereg("^AUTHOR:(.*) DATE:(.*) POST:(.*)", $l, $reg))
|
||||
echo nl2br(htmlentities("AUTHOR: ".$reg[1]." DATE:".$reg[2]." POST:".$reg[3]."\n"));
|
||||
}
|
||||
|
||||
fclose($s);
|
||||
echo "<br><br>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
function display_mailbox_content($shard, $user)
|
||||
{
|
||||
$udir = get_user_dir($user, $shard);
|
||||
|
||||
echo "-- MAILBOX $user ($udir)\n";
|
||||
$dir = opendir($udir);
|
||||
while ($dir && ($file = readdir($dir)))
|
||||
if (ereg("^mail_([0-9]*)\.html", $file) || ereg("^_mail_([0-9]*)\.html", $file))
|
||||
echo "FILE:$file\n";
|
||||
echo "-- END MAILBOX $user\n";
|
||||
}
|
||||
|
||||
function display_forum_content($shard, $user)
|
||||
{
|
||||
$udir = get_user_dir($user, $shard);
|
||||
|
||||
echo "-- FORUM $user ($udir)\n";
|
||||
$dir = opendir($udir);
|
||||
while ($dir && ($file = readdir($dir)))
|
||||
if (ereg("^thread_([0-9]*)\.index", $file) || ereg("^_thread_([0-9]*)\.index", $file))
|
||||
echo "FILE:$file\n";
|
||||
echo "-- END FORUM $user\n";
|
||||
}
|
||||
|
||||
function display_thread_content($shard, $forum, $thread)
|
||||
{
|
||||
$udir = get_user_dir($forum, $shard);
|
||||
read_index($udir.$thread, &$header, &$array);
|
||||
|
||||
$a = explode("%%", $header);
|
||||
|
||||
echo "-- THREAD $forum $thread\n";
|
||||
echo "TOPIC: ".$a[1]." SUBMIT: ".$a[0]."\n";
|
||||
if (count($array) > 0)
|
||||
{
|
||||
foreach ($array as $post)
|
||||
{
|
||||
echo "AUTHOR: ".$post[0]." DATE: ".$post[2]." POST: ".$post[1]."\n";
|
||||
}
|
||||
}
|
||||
echo "-- END THREAD $forum $thread\n";
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
unset($user);
|
||||
$user = $user_login;
|
||||
|
||||
$user_dir = get_user_dir($user, $shard);
|
||||
if (!is_dir($user_dir))
|
||||
die("0");
|
||||
|
||||
$fname = $user_dir.'new_mails';
|
||||
if (file_exists($fname))
|
||||
{
|
||||
unlink($fname);
|
||||
die("1");
|
||||
}
|
||||
else
|
||||
{
|
||||
die("0");
|
||||
}
|
||||
?>
|
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$USERS_DIR = '/home/nevrax/live/www'; // without final /
|
||||
$TEMPLATE_DIR = './template'; // without final /
|
||||
|
||||
?>
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('mail_utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the mailbox
|
||||
// $select_mail_%% mails to be removed
|
||||
//
|
||||
|
||||
read_template('confirm_delete_mail.html', $confirm_delete_mail);
|
||||
|
||||
$mails = array();
|
||||
$selected_mails = '';
|
||||
foreach ($_POST as $var => $value)
|
||||
{
|
||||
if (matchParam($var, "select_mail_", $mail))
|
||||
{
|
||||
$mails[] = $mail;
|
||||
$selected_mails .= "<input type='hidden' name='select_mail_$mail' value='selected'>\n";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
$instance = str_replace(array('%%MAIL%%', '%%SELECTED_MAILS%%'),
|
||||
array($mails[0], $selected_mails),
|
||||
$confirm_delete_mail);
|
||||
|
||||
echo $instance;
|
||||
?>
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('thread_utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $shard shard from which the user connects in
|
||||
// $post_from user who create the thread
|
||||
// $post_to forum in which the thread is to be created
|
||||
// $post_subject topic of the new thread
|
||||
// $post_content content of the first post (optional)
|
||||
//
|
||||
|
||||
importParam('post_from');
|
||||
importParam('post_to');
|
||||
importParam('post_subject');
|
||||
importParam('post_content');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $post_to);
|
||||
|
||||
// check mail is valid
|
||||
//if (!isset($post_from) || !isset($post_to) || !isset($post_subject))
|
||||
// die('Incomplete post to send');
|
||||
//if ($post_subject == '') $post_subject = 'No Subject';
|
||||
|
||||
// check recipient has an account
|
||||
$to_dir = build_user_dir($post_to, $shard);
|
||||
$to_index = $to_dir.'forum.index';
|
||||
|
||||
if (!file_exists($to_index))
|
||||
{
|
||||
build_forum_page($post_to);
|
||||
}
|
||||
|
||||
if (trim($post_subject) != '')
|
||||
{
|
||||
$post_from = clean_string($post_from);
|
||||
$post_to = clean_string($post_to);
|
||||
$post_subject = clean_string($post_subject);
|
||||
|
||||
//
|
||||
// send mail to recipient
|
||||
//
|
||||
|
||||
// create new thread index
|
||||
add_thread_to_forum_index($post_from, $post_to, $post_subject, $index);
|
||||
|
||||
// create thread file
|
||||
create_thread($post_from, $post_to, $post_subject, $index);
|
||||
|
||||
// add main post to thread
|
||||
if ($post_content != "")
|
||||
add_post($post_from, $post_to, $post_content, $index, $last_date);
|
||||
|
||||
// rebuild thread page
|
||||
build_thread_page($post_to, $index, $num_posts);
|
||||
|
||||
// update forum index since thread was touched
|
||||
update_forum_index($post_to, $index, $num_posts, $last_date);
|
||||
|
||||
// rebuild forum page
|
||||
build_forum_page($post_to);
|
||||
}
|
||||
|
||||
// redirect browser to new forum page
|
||||
//redirect("forum.php?forum=$post_to");
|
||||
exportParam('forum', $post_to);
|
||||
//$forum = $post_to;
|
||||
include('forum.php');
|
||||
?>
|
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('mail_utils.php');
|
||||
include_once('thread_utils.php');
|
||||
|
||||
if ($enter_login)
|
||||
{
|
||||
if ($login)
|
||||
setcookie('user_login', $login, time()+86400);
|
||||
else
|
||||
setcookie('user_login');
|
||||
}
|
||||
|
||||
if ($rebuild_mailbox)
|
||||
{
|
||||
build_mail_page($user);
|
||||
}
|
||||
|
||||
if ($rebuild_forum)
|
||||
{
|
||||
build_forum_page($user);
|
||||
}
|
||||
|
||||
if ($rebuild_thread)
|
||||
{
|
||||
build_thread_page($user, $thread, $num_posts);
|
||||
}
|
||||
|
||||
if ($remove_thread)
|
||||
{
|
||||
remove_thread($user, $thread);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function selectUser($var)
|
||||
{
|
||||
return "<select name='$var'>\n".
|
||||
"<option value='ace'>Ace\n".
|
||||
"<option value='ben'>Ben\n".
|
||||
"<option value='hulud'>Hulud\n".
|
||||
"<option value='lem'>Lem\n".
|
||||
"<option value='guild'>Guild\n".
|
||||
"<option value='guest'>Guest\n".
|
||||
"</select>\n";
|
||||
}
|
||||
|
||||
echo "<html><head><title>Fake post form</title></head>\n";
|
||||
echo "<body>\n";
|
||||
|
||||
echo "<table><form method=post action='form_post.php'>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit value='Refresh'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "<table><form method=post action='form_post.php'>\n";
|
||||
echo "<tr valign=top><td>Login</td><td><input type=text name='login' size=50 maxlength=255 value='$user_login'></td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit name='enter_login' value='Enter'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "Post a mail<br>\n";
|
||||
echo "<table><form method=post action='post_mail.php'>\n";
|
||||
echo "<tr valign=top><td>From</td><td>".selectUser('mail_from')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>To</td><td>".selectUser('mail_to')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>Subject</td><td><input type=text name='mail_subject' size=50 maxlength=255></td></tr>\n";
|
||||
echo "<tr valign=top><td>Content</td><td><textarea name='mail_content' rows=20 cols=50></textarea></td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit value='Send'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "Rebuild a mail box<br>\n";
|
||||
echo "<table><form method=post action='form_post.php'>\n";
|
||||
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit name='rebuild_mailbox' value='Rebuild'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
|
||||
|
||||
echo "Create a thread in a forum<br>\n";
|
||||
echo "<table><form method=post action='create_thread.php'>\n";
|
||||
echo "<tr valign=top><td>From</td><td>".selectUser('post_from')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>To</td><td>".selectUser('post_to')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>Subject</td><td><input type=text name='post_subject' size=50 maxlength=255></td></tr>\n";
|
||||
echo "<tr valign=top><td>Content</td><td><textarea name='post_content' rows=20 cols=50></textarea></td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit value='Post'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "Post a topic in a thread<br>\n";
|
||||
echo "<table><form method=post action='post.php'>\n";
|
||||
echo "<tr valign=top><td>From</td><td>".selectUser('post_from')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>To</td><td>".selectUser('post_to')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>Thread</td><td><input type=text name='post_thread' size=50 maxlength=255></td></tr>\n";
|
||||
echo "<tr valign=top><td>Content</td><td><textarea name='post_content' rows=20 cols=50></textarea></td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit value='Post'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "Rebuild a forum<br>\n";
|
||||
echo "<table><form method=post action='form_post.php'>\n";
|
||||
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit name='rebuild_forum' value='Rebuild'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "Rebuild a thread<br>\n";
|
||||
echo "<table><form method=post action='form_post.php'>\n";
|
||||
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>Thread</td><td><input type=text name='thread' size=50 maxlength=255></td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit name='rebuild_thread' value='Rebuild'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "Remove a thread<br>\n";
|
||||
echo "<table><form method=post action='form_post.php'>\n";
|
||||
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
|
||||
echo "<tr valign=top><td>Thread</td><td><input type=text name='thread' size=50 maxlength=255></td></tr>\n";
|
||||
echo "<tr valign=top><td></td><td><input type=submit name='remove_thread' value='Remove'></td></tr>\n";
|
||||
echo "</form></table>\n";
|
||||
|
||||
echo "<br><hr><br>\n";
|
||||
|
||||
echo "</body>\n";
|
||||
echo "</html>\n";
|
||||
|
||||
?>
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $shard shard from which the user connects in
|
||||
// $forum forum to view
|
||||
//
|
||||
|
||||
importParam('forum');
|
||||
importParam('page');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $forum);
|
||||
|
||||
$forum_dir = build_user_dir($forum, $shard);
|
||||
|
||||
$fname = $forum_dir.'forum'.(isset($page) && $page!="" && $page!="0" ? "_$page" : '').'.html';
|
||||
if (!file_exists($fname))
|
||||
{
|
||||
include_once('thread_utils.php');
|
||||
build_forum_page($forum);
|
||||
}
|
||||
|
||||
$f = fopen($fname, 'r');
|
||||
echo fread($f, filesize($fname));
|
||||
fclose($f);
|
||||
?>
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
die();
|
||||
|
||||
?>
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
unset($user);
|
||||
$user = $user_login;
|
||||
|
||||
importParam('msg');
|
||||
|
||||
$user_dir = get_user_dir($user, $shard);
|
||||
$fname = $user_dir."mail_$msg.html";
|
||||
if (!is_dir($user_dir) || !file_exists($fname))
|
||||
{
|
||||
include_once('mailbox.php');
|
||||
die();
|
||||
}
|
||||
|
||||
$f = fopen($fname, 'r');
|
||||
echo fread($f, filesize($fname));
|
||||
fclose($f);
|
||||
|
||||
/* display_time(); */
|
||||
?>
|
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
// -------------------------------------
|
||||
// add a new thread into user forum index
|
||||
// -------------------------------------
|
||||
function add_mail_to_index(&$from, &$to, &$subject, &$index)
|
||||
{
|
||||
global $shard;
|
||||
$to_dir = get_user_dir($to, $shard);
|
||||
$to_index = $to_dir.'mail.index';
|
||||
|
||||
use_index($to_index);
|
||||
|
||||
$f = fopen($to_index, 'r+');
|
||||
read_next_index($f, $index);
|
||||
append_to_index($f, trim($from).'%%'.strtr(trim($subject), "\n", " ").' %%'.displayable_date().'%%1%%'.$index);
|
||||
update_next_index($f, $index+1);
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// remove mail
|
||||
// -------------------------------------
|
||||
function remove_mail($user, $mails)
|
||||
{
|
||||
global $shard;
|
||||
$mail_dir = get_user_dir($user, $shard);
|
||||
|
||||
read_index($mail_dir.'mail.index', $header, $array);
|
||||
|
||||
sort($mails);
|
||||
$remove_mail = 0;
|
||||
|
||||
for ($i=0; $i<count($array); ++$i)
|
||||
if ($remove_mail >= count($mails) || $array[$i][4] != $mails[$remove_mail])
|
||||
$newarray[] = $array[$i];
|
||||
else
|
||||
++$remove_mail;
|
||||
|
||||
write_index($mail_dir.'mail.index', $header, $newarray);
|
||||
|
||||
build_mail_page($user);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// create new mail file
|
||||
// -------------------------------------
|
||||
function create_mail(&$from, &$to, &$subject, &$content, &$cleancontent, &$index)
|
||||
{
|
||||
global $shard;
|
||||
$to_dir = get_user_dir($to, $shard);
|
||||
|
||||
read_template('mail.html', $mail);
|
||||
|
||||
$inst_mailbox = str_replace(array('%%FROM%%', '%%UCFROM%%', '%%DATE%%', '%%SUBJECT%%', '%%CONTENT%%', '%%CLEANCONTENT%%', '%%MAIL%%'),
|
||||
array($from, ucfirst($from), displayable_date(), ucfirst($subject), $content, $cleancontent, $index),
|
||||
$mail);
|
||||
|
||||
// build mail message
|
||||
$f = fopen($to_dir."mail_$index.html", 'w');
|
||||
fwrite($f, $inst_mailbox);
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($to_dir.'new_mails', 'w');
|
||||
fwrite($f, '1');
|
||||
fclose($f);
|
||||
|
||||
srand((float) microtime()*1000000);
|
||||
$fname = md5(rand());
|
||||
global $USERS_DIR;
|
||||
if (!@is_dir($USERS_DIR.'/incoming'))
|
||||
@mkdir($USERS_DIR.'/incoming');
|
||||
$f = @fopen($USERS_DIR.'/incoming/'.$fname, "w");
|
||||
if ($f)
|
||||
{
|
||||
fwrite($f, "shard=$shard to=$to from=$from\n$$$$");
|
||||
fclose($f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// rebuild user mail box pages
|
||||
// -------------------------------------
|
||||
function build_mail_page($user)
|
||||
{
|
||||
global $shard;
|
||||
|
||||
$user_dir = get_user_dir($user, $shard);
|
||||
$user_index = $user_dir."mail.index";
|
||||
|
||||
// open thread index
|
||||
read_index($user_index, $header, $mails);
|
||||
|
||||
$num_mails = count($mails);
|
||||
$num_per_page = 10;
|
||||
$num_pages = (int)(($num_mails+$num_per_page-1) / $num_per_page);
|
||||
|
||||
$mail = $num_mails-1;
|
||||
$page = 0;
|
||||
|
||||
$altern_color = array("#333333", "#666666");
|
||||
$altern_index = 0;
|
||||
|
||||
$links_str = '';
|
||||
|
||||
read_template('mailbox_main.html', $mailbox_main);
|
||||
read_template('mailbox_mail.html', $mailbox_mail);
|
||||
|
||||
read_template('browse_link.html', $browse_link);
|
||||
|
||||
do
|
||||
{
|
||||
$num_in_page = 0;
|
||||
$inst_mail = '';
|
||||
|
||||
while ($num_in_page < 10 && $mail >= 0)
|
||||
{
|
||||
$m = &$mails[$mail];
|
||||
|
||||
$subject = ucfirst(displayable_string($m[1]));
|
||||
|
||||
$inst_mail .= str_replace(array('%%FROM%%', '%%UCFROM%%', '%%SUBJECT%%', '%%DATE%%', '%%USER%%', '%%MAIL%%', '%%COLOR%%'),
|
||||
array($m[0], ucfirst($m[0]), $subject, $m[2], $user, $m[4], $altern_color[$altern_index]),
|
||||
$mailbox_mail);
|
||||
|
||||
// step to next message
|
||||
++$num_in_page;
|
||||
--$mail;
|
||||
$altern_index = 1-$altern_index;
|
||||
}
|
||||
|
||||
$links_str = '';
|
||||
$link_previous = ($page == 0 ? "mailbox.php?page=".$page : "mailbox.php?page=".($page-1));
|
||||
for ($i=0; $i<$num_pages; ++$i)
|
||||
{
|
||||
$link = ($i == $page ? $i+1 : "<a href='mailbox.php?page=$i'>".($i+1)."</a>");
|
||||
$links_str .= str_replace(array('%%LINK%%'),
|
||||
array($link),
|
||||
$browse_link);
|
||||
}
|
||||
$link_next = (($page == $num_pages-1 || $num_pages <= 1) ? "mailbox.php?page=".$page : "mailbox.php?page=".($page+1));
|
||||
|
||||
$inst_mailbox = str_replace(array('%%MAILS%%', '%%PREVIOUS%%', '%%LINKS%%', '%%NEXT%%'),
|
||||
array($inst_mail, $link_previous, $links_str, $link_next),
|
||||
$mailbox_main);
|
||||
|
||||
$pagename = $user_dir."mailbox".($page==0 ? '' : '_'.$page).'.html';
|
||||
|
||||
$f = fopen($pagename, 'w');
|
||||
fwrite($f, $inst_mailbox);
|
||||
fclose($f);
|
||||
|
||||
++$page;
|
||||
}
|
||||
while ($mail >= 0);
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
importParam('page');
|
||||
|
||||
unset($user);
|
||||
$user = $user_login;
|
||||
|
||||
$user_dir = build_user_dir($user, $shard);
|
||||
|
||||
$fname = $user_dir.'mailbox.html';
|
||||
if (!file_exists($fname))
|
||||
{
|
||||
include_once('mail_utils.php');
|
||||
build_mail_page($user);
|
||||
}
|
||||
|
||||
$fname = $user_dir.'mailbox'.(isset($page) && $page!="" && $page!="0" ? "_$page" : '').'.html';
|
||||
if (!file_exists($fname))
|
||||
die("INTERNAL ERROR 10");
|
||||
|
||||
$f = fopen($fname, 'r');
|
||||
echo fread($f, filesize($fname));
|
||||
fclose($f);
|
||||
|
||||
// remove new_mails file when user checks its mailbox
|
||||
$fname = $user_dir.'new_mails';
|
||||
if (file_exists($fname))
|
||||
unlink($fname);
|
||||
|
||||
/* display_time(); */
|
||||
?>
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that write the mail
|
||||
// $mail_to user to send mail to (optional)
|
||||
// $mail_subject subject of the mail (optional)
|
||||
// $mail_content content of the mail (optional)
|
||||
//
|
||||
|
||||
importParam('mail_to');
|
||||
importParam('mail_subject');
|
||||
importParam('mail_content');
|
||||
|
||||
read_template('new_mail.html', $new_mail);
|
||||
|
||||
$instance = str_replace(array('%%FROM%%', '%%UCFROM%%', '%%TO%%', '%%UCTO%%', '%%SUBJECT%%', '%%CONTENT%%'),
|
||||
array($user_login, ucfirst($user_login), $mail_to, ucfirst($mail_to), ucfirst(displayable_string($mail_subject)), displayable_content($mail_content)),
|
||||
$new_mail);
|
||||
|
||||
echo $instance;
|
||||
?>
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $forum forum in which to post
|
||||
// $thread thread within the forum in which to post
|
||||
// $subject subject of the thread
|
||||
//
|
||||
|
||||
importParam('forum');
|
||||
importParam('thread');
|
||||
importParam('subject');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $forum);
|
||||
|
||||
read_template('new_post.html', $new_post);
|
||||
|
||||
$instance = str_replace(array('%%SENDER%%', '%%UCSENDER%%', '%%FORUM_POST%%', '%%FORUM%%', '%%UCFORUM%%', '%%THREAD%%', '%%SUBJECT%%'),
|
||||
array($user_login, ucfirst($user_login), $forum, nameToURL($forum), convert_forum_name($forum), $thread, $subject),
|
||||
$new_post);
|
||||
|
||||
echo $instance;
|
||||
?>
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $forum forum to create thread into
|
||||
//
|
||||
|
||||
importParam('forum');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $forum);
|
||||
|
||||
read_template('new_thread.html', $new_thread);
|
||||
|
||||
$instance = str_replace(array('%%SENDER%%', '%%UCSENDER%%', '%%FORUM_POST%%', '%%FORUM%%', '%%UCFORUM%%'),
|
||||
array($user_login, ucfirst($user_login), $forum, nameToURL($forum), convert_forum_name($forum)),
|
||||
$new_thread);
|
||||
|
||||
echo $instance;
|
||||
?>
|
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('thread_utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $shard shard from which the client connects in
|
||||
// $post_from user who post the message
|
||||
// $post_to forum in which to post the message
|
||||
// $post_thread thread within the forum in which to post the message
|
||||
// $post_content content of the post
|
||||
//
|
||||
|
||||
importParam('post_from');
|
||||
importParam('post_to');
|
||||
importParam('post_thread');
|
||||
importParam('post_content');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $post_to);
|
||||
|
||||
// check mail is valid
|
||||
//if (!isset($post_from) || !isset($post_to) || !isset($post_thread) || !isset($post_content))
|
||||
// die('Incomplete post to send');
|
||||
|
||||
// check recipient has an account
|
||||
$to_dir = build_user_dir($post_to, $shard);
|
||||
$to_index = $to_dir.'forum.index';
|
||||
|
||||
if (trim($post_content) != '')
|
||||
{
|
||||
$post_from = clean_string($post_from);
|
||||
$post_to = clean_string($post_to);
|
||||
$post_content = clean_content($post_content);
|
||||
|
||||
//
|
||||
// send mail to recipient
|
||||
//
|
||||
|
||||
// add main post to thread
|
||||
add_post($post_from, $post_to, $post_content, $post_thread, $last_date);
|
||||
|
||||
// rebuild thread page
|
||||
build_thread_page($post_to, $post_thread, $num_posts);
|
||||
|
||||
// update forum index since thread was touched
|
||||
update_forum_index($post_to, $post_thread, $num_posts, $last_date);
|
||||
|
||||
// rebuild forum page
|
||||
build_forum_page($post_to);
|
||||
}
|
||||
|
||||
// redirect browser to new forum page
|
||||
//redirect("thread.php?forum=$post_to&thread=$post_thread");
|
||||
exportParam('forum', $post_to);
|
||||
exportParam('thread', $post_thread);
|
||||
//$forum = $post_to;
|
||||
//$thread = $post_thread;
|
||||
include_once('thread.php');
|
||||
?>
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('mail_utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that posts a mail
|
||||
// $shard shard from which the client connects in
|
||||
// $mail_from login of the user that posts a mail
|
||||
// $mail_to login of the user that receives the mail
|
||||
// $mail_subject subject of the mail
|
||||
// $mail_content content of the mail
|
||||
//
|
||||
|
||||
importParam('mail_from');
|
||||
importParam('mail_to');
|
||||
importParam('mail_subject');
|
||||
importParam('mail_content');
|
||||
|
||||
// check mail is valid
|
||||
//if (!isset($mail_from) || $mail_from == "" || !isset($mail_to) || $mail_to == "" || !isset($mail_subject) || $mail_subject == "" || !isset($mail_content) || $mail_content == "" )
|
||||
// die('Incomplete mail to send');
|
||||
|
||||
// check recipient has an account
|
||||
|
||||
if (trim($mail_content) != '')
|
||||
{
|
||||
if ($mail_to == '' || !is_dir($to_dir = get_user_dir($mail_to, $shard)))
|
||||
{
|
||||
$mail_subject = "<i>uiMFUndelivrableMail</i> '$mail_subject'";
|
||||
$mail_cleansubject = $mail_subject;
|
||||
$mail_content = "<i>uiMFUndelivrableMailTo</i> '$mail_to'.\n<i>uiMFUndelivrableMailCheck</i><br>\n<br>\n<i>uiMFMailContent</i><br>\n$mail_content";
|
||||
$mail_cleancontent = "<i>uiMFUndelivrableMailTo</i> '$mail_to'.\n<i>uiMFUndelivrableMailCheck</i>\n\n<i>uiMFMailContent</i>\n$mail_content";
|
||||
$mail_to = $mail_from;
|
||||
$mail_from = '<i>uiMFMailServer</i>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mail_cleansubject = $mail_subject;
|
||||
$mail_subject = displayable_string(clean_string($mail_subject));
|
||||
$mail_cleancontent = displayable_content($mail_content);
|
||||
$mail_content = displayable_string($mail_content);
|
||||
$mail_from = displayable_string(clean_string($mail_from));
|
||||
$mail_to = displayable_string(clean_string($mail_to));
|
||||
}
|
||||
|
||||
$to_dir = build_user_dir($mail_to, $shard);
|
||||
$to_index = $to_dir.'mail.index';
|
||||
|
||||
//
|
||||
// send mail to recipient
|
||||
//
|
||||
|
||||
// create new mail index
|
||||
add_mail_to_index($mail_from, $mail_to, $mail_cleansubject, $mail_index);
|
||||
|
||||
// create mail file
|
||||
create_mail($mail_from, $mail_to, $mail_subject, $mail_content, $mail_cleancontent, $mail_index);
|
||||
|
||||
// rebuild recipient mailbox page
|
||||
build_mail_page($mail_to);
|
||||
}
|
||||
|
||||
|
||||
// redirect browser to new forum page
|
||||
//redirect("mailbox.php");
|
||||
include_once('mailbox.php');
|
||||
|
||||
?>
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('mail_utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the mailbox
|
||||
// $select_mail_%% mails to be removed
|
||||
//
|
||||
|
||||
$mails = array();
|
||||
|
||||
foreach ($_POST as $var => $value)
|
||||
if (matchParam($var, "select_mail_", $mail))
|
||||
$mails[] = $mail;
|
||||
|
||||
if (count($mails) > 0)
|
||||
remove_mail($user_login, $mails);
|
||||
|
||||
// redirect browser to new mailbox page
|
||||
//redirect("mailbox.php");
|
||||
include_once('mailbox.php');
|
||||
?>
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('thread_utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $forum forum to remove posts off
|
||||
// $thread thread to remove posts off
|
||||
// $select_post_%% posts to be removed
|
||||
//
|
||||
|
||||
importParam('forum');
|
||||
importParam('thread');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $forum);
|
||||
|
||||
/* if ($forum == $user_login) */
|
||||
{
|
||||
$posts = array();
|
||||
|
||||
foreach ($_POST as $var => $value)
|
||||
if (matchParam($var, "select_post_", $post))
|
||||
$posts[] = $post;
|
||||
|
||||
if (count($posts) > 0)
|
||||
remove_post($forum, $thread, $posts);
|
||||
}
|
||||
|
||||
// redirect browser to new forum page
|
||||
//redirect("thread.php?forum=$forum&thread=$thread");
|
||||
include_once('thread.php');
|
||||
?>
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('thread_utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $forum forum to remove threads off
|
||||
// $selected_thread_%% threads to be removed
|
||||
//
|
||||
|
||||
importParam('forum');
|
||||
importParam('thread');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $forum);
|
||||
|
||||
/* if ($forum == $user_login) */
|
||||
{
|
||||
foreach ($_POST as $var => $value)
|
||||
{
|
||||
if (matchParam($var, "select_thread_", $thread))
|
||||
{
|
||||
remove_thread($forum, $thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// redirect browser to new forum page
|
||||
//redirect("forum.php?forum=$forum");
|
||||
include_once('forum.php');
|
||||
?>
|
@ -0,0 +1,13 @@
|
||||
<td valign="middle" height="2" align="right" width="100%">
|
||||
<div align="left">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><b><font size="2" face="Arial, Helvetica, sans-serif"><a href="%%PREVIOUS%%"><img src="previous.gif" border="0" width="24" height="24" name="previous" alt="uiMFPrevious"></a></font></b></td>
|
||||
%%LINKS%%
|
||||
<td>
|
||||
<div align="right"><b><font size="2" face="Arial, Helvetica, sans-serif"><a href="%%NEXT%%"><img src="next.gif" border="0" width="24" height="24" name="next" alt="uiMFNext"></a></font></b></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
@ -0,0 +1 @@
|
||||
<td nowrap>%%LINK%%</td>
|
@ -0,0 +1,50 @@
|
||||
<html>
|
||||
<head>
|
||||
<title><i>uiMFDeleteMailTitle</i></title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#FFFFFF">
|
||||
<form method='post' action='remove_mail.php'>
|
||||
%%SELECTED_MAILS%%
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" height="80">
|
||||
<div align="center">
|
||||
<table width="100%" cellspacing="8" bgcolor="#000000">
|
||||
<tr valign="middle">
|
||||
<td width="3%"><img src="web_message.gif"></td>
|
||||
<td width="74%"><h1><i>uiMFEraseMail</i></h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr valign="bottom">
|
||||
<td height="27"><a href="mailbox.php"><img src="web_home.gif" global_color alt="uiWebHome" ></a>
|
||||
<a href="mail.php?msg=%%MAIL%%"><img src="web_back.gif" global_color alt="uiWebBack" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table cellspacing="4" bgcolor="#666666">
|
||||
<tr>
|
||||
<td><i>uiMFEraseMailQuestion</i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><input type="image" name="Submit" value="Submit" src="web_del.gif" alt="uiWebDelMess" ></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,57 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>%%UCFORUM%% Forum</title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#ffffff">
|
||||
<form method='post' action='remove_thread.php'>
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td height="80">
|
||||
<table width="100%" border="00" cellspacing="8" bgcolor="#000000" >
|
||||
<tr valign="middle">
|
||||
<td width="98%" ><h1>%%UCFORUM%%</h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table valign="middle" width="100%" border="0" cellspacing="2" cellpadding="0" l_margin="4" >
|
||||
<tr bgcolor="#000000">
|
||||
<h5>
|
||||
<td width="3%" height="30" bgcolor="#333333"></td>
|
||||
<td width="59%"><i>uiMFTopics</i></td>
|
||||
<td width="15%"><i>uiMFAuthor</i></td>
|
||||
<td width="8%"><i>uiMFPosts</i></td>
|
||||
<td width="15%"><i>uiMFLastPost</i></td>
|
||||
</h5>
|
||||
</tr>
|
||||
%%TOPICS%%
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" >
|
||||
<tr valign="middle">
|
||||
<td><a href="%%PREVIOUS%%"><img src="web_previous.gif" global_color alt="uiWebPrevious" ></a></td>
|
||||
%%LINKS%%
|
||||
<td width="100%"><a href="%%NEXT%%"><img src="web_next.gif" global_color alt="uiWebNext" ></a></td>
|
||||
<td><input type="image" name="del2" value="Submit" src="web_del.gif" alt="uiWebDelTopic" ></td>
|
||||
<td><a href="new_thread.php"><img src="web_topic.gif" alt="uiWebNewTopic" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,7 @@
|
||||
<tr bgcolor="%%COLOR%%">
|
||||
<td height="30" bgcolor="#333333"><input type="checkbox" name="select_thread_%%THREAD%%"></td>
|
||||
<td><a href="thread.php?thread=%%THREAD%%">%%SUBJECT%%</a></td>
|
||||
<td>%%UCSENDER%%</td>
|
||||
<td>%%NUMPOSTS%%</td>
|
||||
<td>%%DATE%%</td>
|
||||
</tr>
|
@ -0,0 +1,85 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Message From %%UCFROM%%</title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#FFFFFF">
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" height="80">
|
||||
<div align="center">
|
||||
<table width="100%" cellspacing="8" bgcolor="#000000">
|
||||
<tr valign="middle">
|
||||
<td width="3%"><img src="web_message.gif"></td>
|
||||
<td width="97%"><h1><i>uiMFMessageFrom</i> %%UCFROM%%</h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr valign="bottom">
|
||||
<td height="27"><a href="mailbox.php"><img src="web_home.gif" global_color alt="uiWebHome" ></a>
|
||||
<a href="mailbox.php"><img src="web_back.gif" global_color alt="uiWebBack" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" height="86" align="center">
|
||||
<table width="100%" cellspacing="2" l_margin="4" >
|
||||
<tr bgcolor="#333333" valign="middle">
|
||||
<h5><td width="10%" height="30" bgcolor="#000000"><i>uiMFAuthor</i></td></h5>
|
||||
<td width="90%" bgcolor="#666666">%%UCFROM%%</td>
|
||||
</tr>
|
||||
<tr bgcolor="#333333" valign="middle">
|
||||
<h5><td width="10%" height="30" bgcolor="#000000"><i>uiMFDate</i></td></h5>
|
||||
<td width="90%" bgcolor="#666666">%%DATE%%</td>
|
||||
</tr>
|
||||
<tr bgcolor="#333333" valign="middle" valign="middle">
|
||||
<h5><td width="10%" height="30" bgcolor="#000000"><i>uiMFSubject</i></td></h5>
|
||||
<td width="90%" bgcolor="#666666">%%SUBJECT%%</td>
|
||||
</tr>
|
||||
<tr bgcolor="#333333" valign="middle">
|
||||
<h5><td width="10%" height="30" bgcolor="#000000"><i>uiMFMessage</i></td></h5>
|
||||
<td width="90%" bgcolor="#666666">%%CONTENT%%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr align="right">
|
||||
<form method='post' action='confirm_remove_mail.php'>
|
||||
<input type='hidden' name='select_mail_%%MAIL%%' value='select'>
|
||||
<td width="100%"><input type="image" name="del" value="Submit" src="web_del.gif" alt="uiWebDelMess" ></td>
|
||||
</form>
|
||||
<form method='post' action='new_mail.php'>
|
||||
<input type='hidden' name='msg' value='%%MAIL%%'>
|
||||
<input type='hidden' name='mail_to' value='%%FROM%%'>
|
||||
<input type='hidden' name='mail_subject' value='Re: %%SUBJECT%%'>
|
||||
<input type='hidden' name='mail_content' value='%%UCFROM%% wrote:
|
||||
%%CLEANCONTENT%%'>
|
||||
<td><input type="image" name="del2" value="Submit" src="web_reply.gif" alt="uiWebReply" ></td>
|
||||
</form>
|
||||
<form method='post' action='new_mail.php'>
|
||||
<input type='hidden' name='msg' value='%%MAIL%%'>
|
||||
<input type='hidden' name='mail_subject' value='Tr: %%SUBJECT%%'>
|
||||
<input type='hidden' name='mail_content' value='%%UCFROM%% wrote:
|
||||
%%CLEANCONTENT%%'>
|
||||
<td><input type="image" name="del3" value="Submit" src="web_forward.gif" alt="uiWebForward" ></td>
|
||||
</form>
|
||||
<td><a href="new_mail.php"><img src="web_send.gif" alt="uiWebNewMessage" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,6 @@
|
||||
<tr bgcolor="%%COLOR%%">
|
||||
<td height="30" bgcolor="#333333"><input type="checkbox" name="select_mail_%%MAIL%%" ></td>
|
||||
<td><a href="mail.php?msg=%%MAIL%%">%%UCFROM%%</a></td>
|
||||
<td>%%SUBJECT%%</td>
|
||||
<td>%%DATE%%</td>
|
||||
</tr>
|
@ -0,0 +1,57 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Inbox</title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#FFFFFF">
|
||||
<form method='post' action='confirm_remove_mail.php'>
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td height="80">
|
||||
<table width="100%" border="00" cellspacing="8" bgcolor="#000000" >
|
||||
<tr valign="middle">
|
||||
<td width="2%"><img src="web_inbox.gif"></td>
|
||||
<td width="98%" ><h1><i>uiMFInbox</i></h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table valign="middle" width="100%" cellspacing="2" l_margin="4">
|
||||
<tr bgcolor="#000000">
|
||||
<h5>
|
||||
<td width="2%" height="30" bgcolor="#333333"></td>
|
||||
<td width="22%"><i>uiMFFrom</i></td>
|
||||
<td width="58%"><i>uiMFSubject</i></td>
|
||||
<td width="18%"><i>uiMFDate</i></td>
|
||||
</h5>
|
||||
</tr>
|
||||
%%MAILS%%
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%">
|
||||
<tr valign="middle">
|
||||
<td><a href="%%PREVIOUS%%"><img src="web_previous.gif" global_color alt="uiWebPrevious" ></a></td>
|
||||
%%LINKS%%
|
||||
<td width="100%"><a href="%%NEXT%%"><img src="web_next.gif" global_color alt="uiWebNext" ></a></td>
|
||||
<td><input type="image" name="del2" value="Submit" src="web_del.gif" alt="uiWebDelMessage" ></td>
|
||||
<td><a href="new_mail.php"><img src="web_send.gif" alt="uiWebNewMessage" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,69 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>New Message</title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#FFFFFF">
|
||||
<form method='post' action='post_mail.php'>
|
||||
<input type='hidden' name='mail_from' value='%%FROM%%'>
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td height="80">
|
||||
<table width="100%" border="00" cellspacing="8" bgcolor="#000000" >
|
||||
<tr valign="middle">
|
||||
<td width="2%"><img src="web_message.gif"></td>
|
||||
<td width="98%" ><h1><i>uiMFNewMessage</i></h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr valign="bottom">
|
||||
<td height="27"><a href="mailbox.php"><img src="web_home.gif" global_color alt="uiWebHome" ></a>
|
||||
<a href="mailbox.php"><img src="web_back.gif"global_color alt="uiWebBack" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table valign="middle" width="100%" cellspacing="2" l_margin="4">
|
||||
<tr>
|
||||
<h5><td width="10%" height="30" bgcolor="#000000">To</td></h5>
|
||||
<td width="90%" height="7" bgcolor="#666666" l_margin="0">
|
||||
<table border="4"><tr><td>
|
||||
<input type="text" name="mail_to" size="180" value="%%TO%%">
|
||||
</td></tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="middle">
|
||||
<h5><td width="10%" height="30" bgcolor="#000000"><i>uiMFSubject</i></td></h5>
|
||||
<td width="90%" height="3" bgcolor="#666666" l_margin="0">
|
||||
<table border="4"><tr><td>
|
||||
<input type="text" name="mail_subject" size="360" value="%%SUBJECT%%">
|
||||
</td></tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="middle">
|
||||
<h5><td width="10%" height="30" bgcolor="#000000"><i>uiMFMailBody</i></td></h5>
|
||||
<td width="90%" height="18" bgcolor="#666666" l_margin="0"><font face="Arial, Helvetica, sans-serif" size="2">
|
||||
<table border="4"><tr><td>
|
||||
<textarea name="mail_content" rows="8" cols="30">%%CONTENT%%</textarea>
|
||||
</td></tr></table>
|
||||
</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><input type="image" name="Submit2" value="Submit" src="web_submit.gif" alt="uiWebSend" ></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,57 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>New Message</title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#FFFFFF">
|
||||
<form method='post' action='post.php'>
|
||||
<input type='hidden' name='post_from' value='%%SENDER%%'>
|
||||
<input type='hidden' name='post_to' value='%%FORUM_POST%%'>
|
||||
<input type='hidden' name='post_thread' value='%%THREAD%%'>
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" height="80">
|
||||
<div align="center">
|
||||
<table width="100%" cellspacing="8" bgcolor="#000000">
|
||||
<tr valign="middle">
|
||||
<td width="74%"><h1>%%UCFORUM%%</h1></td>
|
||||
<td width="23%" align="right">%%SUBJECT%%</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr valign="bottom">
|
||||
<td height="27"><a href="forum.php"><img src="web_home.gif" global_color alt="uiWebHome" ></a>
|
||||
<a href="thread.php?thread=%%THREAD%%"><img src="web_back.gif" global_color alt="uiWebBack" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table cellspacing="4"bgcolor="#666666">
|
||||
<tr>
|
||||
<td><i>uiMFNewPost</i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<textarea name="post_content" cols="30"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><input type="image" name="Submit" value="Submit" src="web_submit.gif" alt="uiWebSubmit" ></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,53 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>New Topic</title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#FFFFFF">
|
||||
<form method='post' action='create_thread.php'>
|
||||
<input type='hidden' name='post_from' value='%%SENDER%%'>
|
||||
<input type='hidden' name='post_to' value='%%FORUM_POST%%'>
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" height="80">
|
||||
<div align="center">
|
||||
<table width="100%" cellspacing="8" bgcolor="#000000">
|
||||
<tr valign="middle">
|
||||
<td width="100%"><h1>%%UCFORUM%%</h1></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr valign="bottom">
|
||||
<td height="27"><a href="forum.php"><img src="web_home.gif" global_color alt="uiWebHome" ></a>
|
||||
<a href="forum.php"><img src="web_back.gif" global_color alt="uiWebBack" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table cellspacing="4" bgcolor="#666666">
|
||||
<tr>
|
||||
<td><i>uiMFNewtopic</i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="post_subject" size="200"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><input type="image" name="Submit" value="Submit" src="web_submit.gif" alt="uiWebSubmit" ></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,65 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Topic</title>
|
||||
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#333333" text="#FFFFFF">
|
||||
<form method='post' action='remove_post.php'>
|
||||
<input type='hidden' name='forum' value='%%FORUM_POST%%'>
|
||||
<input type='hidden' name='thread' value='%%THREAD%%'>
|
||||
<table width="100%" height="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top" height="80">
|
||||
<div align="center">
|
||||
<table width="100%" cellspacing="8" bgcolor="#000000">
|
||||
<tr valign="middle">
|
||||
<td width="74%"><h1>%%UCFORUM%%</h1></td>
|
||||
<td width="23%" align="right">%%SUBJECT%%</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr valign="bottom">
|
||||
<td height="27"><a href="forum.php"><img src="web_home.gif" global_color alt="uiWebHome" ></a>
|
||||
<a href="forum.php"><img src="web_back.gif" global_color alt="uiWebBack" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<table width="100%" valign="middle" cellspacing="2" cellpadding="0" l_margin="4" >
|
||||
<tr bgcolor="#000000">
|
||||
<h4>
|
||||
<td width="3%" height="30" bgcolor="#333333"> </td>
|
||||
<td width="20%"><i>uiMFAuthor</i></td>
|
||||
<td width="79%"><i>uiMFMessages</i></td>
|
||||
</h4>
|
||||
%%POSTS%%
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%">
|
||||
<tr valign="middle">
|
||||
<td><a href="%%PREVIOUS%%"><img src="web_previous.gif" global_color alt="uiWebPrevious" ></a></td>
|
||||
%%LINKS%%
|
||||
<td width="100%"><a href="%%NEXT%%"><img src="web_next.gif" global_color alt="uiWebNext" ></a></td>
|
||||
<td><input type="image" name="del2" value="Submit" src="web_del.gif" alt="uiWebDelPost" ></td>
|
||||
<td><a href="new_post.php?thread=%%THREAD%%&subject=%%SUBJECT%%"><img src="web_post.gif" alt="uiWebNewPost" ></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,5 @@
|
||||
<tr bgcolor="%%COLOR%%">
|
||||
<td width="3%" bgcolor="#333333" valign="top"><input type="checkbox" name="select_post_%%POST%%"></td>
|
||||
<td width="18%" valign="top">%%UCSENDER%%<br>%%DATE%%</td>
|
||||
<td width="79%">%%CONTENT%%</td>
|
||||
</tr>
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
//
|
||||
// INPUT:
|
||||
//
|
||||
// $user_login login of the user that consults the forum
|
||||
// $shard shard from which the client connects in
|
||||
// $forum forum to view
|
||||
// $thread thread within forum to view
|
||||
//
|
||||
|
||||
importParam('forum');
|
||||
importParam('thread');
|
||||
importParam('page');
|
||||
|
||||
check_character_belongs_to_guild($user_login, $forum);
|
||||
|
||||
$user_dir = build_user_dir($forum, $shard);
|
||||
|
||||
$fname = $user_dir."thread_$thread".(isset($page) && $page!="" && $page!="0" ? "_$page" : '').".html";
|
||||
if (!file_exists($fname))
|
||||
{
|
||||
include_once('forum.php');
|
||||
die();
|
||||
}
|
||||
|
||||
$f = fopen($fname, 'r');
|
||||
echo fread($f, filesize($fname));
|
||||
fclose($f);
|
||||
?>
|
@ -0,0 +1,440 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_once('utils.php');
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// add a new thread into user forum index
|
||||
// -------------------------------------
|
||||
function add_thread_to_forum_index(&$from, &$to, &$subject, &$index)
|
||||
{
|
||||
global $shard;
|
||||
$to_dir = get_user_dir($to, $shard);
|
||||
$to_index = $to_dir.'forum.index';
|
||||
|
||||
use_index($to_index);
|
||||
|
||||
$f = fopen($to_index, 'r+');
|
||||
read_next_index($f, $index);
|
||||
append_to_index($f, trim($from).'%%'.strtr(trim($subject), "\n", " ").' %%".displayable_date()."%%1%%'.$index);
|
||||
update_next_index($f, $index+1);
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// create new thread index
|
||||
// -------------------------------------
|
||||
function create_thread(&$from, &$to, &$subject, &$index)
|
||||
{
|
||||
global $shard;
|
||||
$to_dir = get_user_dir($to, $shard);
|
||||
|
||||
// build mail message
|
||||
$array = array();
|
||||
write_index($to_dir."thread_$index.index", trim($from).'%%'.strtr(trim($subject), "\n", " ").' %%'.displayable_date(), $array);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// remove thread
|
||||
// -------------------------------------
|
||||
function remove_thread($forum, $thread)
|
||||
{
|
||||
global $shard;
|
||||
$forum_dir = get_user_dir($forum, $shard);
|
||||
|
||||
read_index($forum_dir.'forum.index', $header, $array);
|
||||
|
||||
for ($i=0; $i<count($array); ++$i)
|
||||
if (trim($array[$i][4]) != trim($thread))
|
||||
$newarray[] = $array[$i];
|
||||
|
||||
write_index($forum_dir.'forum.index', $header, $newarray);
|
||||
|
||||
$compare = 'thread_'.$thread;
|
||||
$len = strlen($compare);
|
||||
|
||||
if ($dir = @opendir($forum_dir))
|
||||
{
|
||||
while($file = readdir($dir))
|
||||
if (!strncmp($file, $compare, $len))
|
||||
rename($forum_dir.$file, $forum_dir.'_'.$file);
|
||||
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
build_forum_page($forum);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// add post to thread
|
||||
// -------------------------------------
|
||||
function add_post(&$from, &$to, &$content, &$index, &$last_date)
|
||||
{
|
||||
global $shard;
|
||||
$to_dir = get_user_dir($to, $shard);
|
||||
|
||||
// build mail message
|
||||
$last_date = displayable_date();
|
||||
$fname = $to_dir."thread_$index.index";
|
||||
$f = fopen($fname, "a+");
|
||||
append_to_index($f, trim($from).'%%'.trim($content).' %%'.$last_date);
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// remove post
|
||||
// -------------------------------------
|
||||
function remove_post($forum, $thread, $posts)
|
||||
{
|
||||
global $shard;
|
||||
$forum_dir = get_user_dir($forum, $shard);
|
||||
|
||||
read_index($forum_dir.'thread_'.$thread.'.index', $header, $array);
|
||||
|
||||
sort($posts);
|
||||
$remove_post = 0;
|
||||
|
||||
for ($i=0; $i<count($array); ++$i)
|
||||
if ($remove_post >= count($posts) || $i != $posts[$remove_post])
|
||||
$newarray[] = $array[$i];
|
||||
else
|
||||
++$remove_post;
|
||||
|
||||
write_index($forum_dir.'thread_'.$thread.'.index', $header, $newarray);
|
||||
|
||||
build_thread_page($forum, $thread, $num_posts);
|
||||
update_forum_index($forum, $thread, $num_posts, "");
|
||||
build_forum_page($forum);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// update forum index after a thread is modified
|
||||
// -------------------------------------
|
||||
function update_forum_index($user, $thread, $num_posts, $last_date)
|
||||
{
|
||||
global $shard;
|
||||
$user_dir = get_user_dir($user, $shard);
|
||||
$user_index = $user_dir.'forum.index';
|
||||
|
||||
// read forum index
|
||||
read_index($user_index, $header, $threads);
|
||||
|
||||
// search for thread line
|
||||
for ($i=0; $i<count($threads); ++$i)
|
||||
{
|
||||
if (trim($threads[$i][4]) == trim($thread))
|
||||
{
|
||||
$threads[$i][2] = $last_date;
|
||||
$threads[$i][3] = $num_posts;
|
||||
}
|
||||
}
|
||||
|
||||
// write forum index
|
||||
write_index($user_index, $header, $threads);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// rebuild whole forum index
|
||||
// -------------------------------------
|
||||
function build_forum_index($forum)
|
||||
{
|
||||
global $shard;
|
||||
$forum_dir = get_user_dir($forum, $shard);
|
||||
$forum_index = $forum_dir.'forum.index';
|
||||
|
||||
read_index($forum_index, $header, $threads);
|
||||
|
||||
$threads = array();
|
||||
$browse_dir = opendir($forum_dir);
|
||||
while ($browse_dir && ($browse_file = readdir($browse_dir)))
|
||||
{
|
||||
if (ereg("^thread_([0-9]*)\.index", $browse_file, $regs))
|
||||
{
|
||||
echo "added $browse_file to forum<br>\n";
|
||||
$index = $regs[1];
|
||||
read_index($forum_dir.$browse_file, $fheader, $posts);
|
||||
|
||||
$fhdr = explode('%%', $fheader);
|
||||
|
||||
$threads[$index] = trim($fhdr[0]).'%%'.trim($fhdr[1]).'%%'.trim($fhdr[2]).'%%'.count($posts).'%%'.$index;
|
||||
}
|
||||
}
|
||||
|
||||
$icontent = array();
|
||||
for ($i=0; $i<$header; ++$i)
|
||||
{
|
||||
if ($threads[$i] == '')
|
||||
continue;
|
||||
|
||||
$icontent[] = array($threads[$i]);
|
||||
}
|
||||
|
||||
write_index($forum_index, $header, $icontent);
|
||||
|
||||
build_forum_page($forum);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// recover all deleted threads
|
||||
// -------------------------------------
|
||||
function recover_thread($forum)
|
||||
{
|
||||
global $shard;
|
||||
$forum_dir = get_user_dir($forum, $shard);
|
||||
|
||||
$browse_dir = opendir($forum_dir);
|
||||
while ($browse_dir && ($browse_file = readdir($browse_dir)))
|
||||
{
|
||||
if (ereg("^_thread_([0-9]*)\.(index|html)", $browse_file))
|
||||
{
|
||||
echo "recover file $browse_file<br>\n";
|
||||
rename($forum_dir.'/'.$browse_file, $forum_dir.'/'.substr($browse_file, 1));
|
||||
}
|
||||
}
|
||||
|
||||
build_forum_index($forum);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// recover all deleted threads
|
||||
// -------------------------------------
|
||||
function recover_one_thread($forum, $thread)
|
||||
{
|
||||
global $shard;
|
||||
$forum_dir = get_user_dir($forum, $shard);
|
||||
|
||||
if (file_exists($forum_dir.$thread))
|
||||
{
|
||||
rename($forum_dir.$thread, $forum_dir.substr($thread, 1));
|
||||
build_forum_index($forum);
|
||||
}
|
||||
else if (file_exists($forum_dir.'_thread_'.$thread.'.index'))
|
||||
{
|
||||
$file = 'thread_'.$thread.'.index';
|
||||
rename($forum_dir.'_'.$file, $forum_dir.$file);
|
||||
|
||||
if (file_exists($forum_dir.'_thread_'.$thread.'.html'))
|
||||
{
|
||||
$file = 'thread_'.$thread.'.html';
|
||||
rename($forum_dir.'_'.$file, $forum_dir.$file);
|
||||
}
|
||||
|
||||
build_forum_index(nameToFile($forum));
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// rename forum
|
||||
// -------------------------------------
|
||||
function rename_forum($forum, $into)
|
||||
{
|
||||
global $shard;
|
||||
|
||||
$olddir = build_user_dir($forum);
|
||||
$newdir = build_user_dir($into);
|
||||
|
||||
$dir = opendir($olddir);
|
||||
while ($dir && ($file = readdir($dir)))
|
||||
$files[] = $file;
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
copy($olddir.'/'.$file, $newdir.'/'.$file);
|
||||
delete($olddir.'/'.$file);
|
||||
}
|
||||
|
||||
build_forum_page($into);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// rebuild user mail box pages
|
||||
// -------------------------------------
|
||||
function build_forum_page($forum)
|
||||
{
|
||||
global $shard;
|
||||
$forum_dir = get_user_dir($forum, $shard);
|
||||
$forum_index = $forum_dir.'forum.index';
|
||||
|
||||
// open forum index
|
||||
read_index($forum_index, $header, $threads);
|
||||
|
||||
$num_threads = count($threads);
|
||||
$num_per_page = 10;
|
||||
$num_pages = (int)(($num_threads+$num_per_page-1) / $num_per_page);
|
||||
|
||||
$thread = $num_threads-1;
|
||||
$num_in_page = 0;
|
||||
$page = 0;
|
||||
|
||||
$altern_color = array("#333333", "#666666");
|
||||
|
||||
$links_str = '';
|
||||
|
||||
read_template('forum_main.html', $forum_main);
|
||||
read_template('forum_topic.html', $forum_topic);
|
||||
|
||||
read_template('browse_link.html', $browse_link);
|
||||
|
||||
do
|
||||
{
|
||||
$inst_topic = '';
|
||||
$num_in_page = 0;
|
||||
$altern_index = 0;
|
||||
|
||||
while ($num_in_page < 10 && $thread >= 0)
|
||||
{
|
||||
$t = &$threads[$thread];
|
||||
|
||||
// replace in topic
|
||||
$subject = ucfirst(displayable_string($t[1]));
|
||||
|
||||
$inst_topic .= str_replace(array('%%SUBJECT%%', '%%SENDER%%', '%%UCSENDER%%', '%%NUMPOSTS%%', '%%DATE%%', '%%FORUM%%', '%%UCFORUM%%', '%%THREAD%%', '%%COLOR%%'),
|
||||
array(ucfirst($subject), $t[0], ucfirst($t[0]), $t[3], $t[2], nameToURL($forum), convert_forum_name($forum), $t[4], $altern_color[$altern_index]),
|
||||
$forum_topic);
|
||||
|
||||
// step to next thread
|
||||
++$num_in_page;
|
||||
--$thread;
|
||||
$altern_index = 1-$altern_index;
|
||||
}
|
||||
|
||||
$links_str = '';
|
||||
$link_previous = ($page == 0 ? "forum.php?page=".$page : "forum.php?page=".($page-1));
|
||||
for ($i=0; $i<$num_pages; ++$i)
|
||||
{
|
||||
$link = ($i == $page ? $i+1 : "<a href='forum.php?page=$i'>".($i+1)."</a>");
|
||||
$links_str .= str_replace(array('%%LINK%%'),
|
||||
array($link),
|
||||
$browse_link);
|
||||
}
|
||||
$link_next = (($page == $num_pages-1 || $num_pages <= 1) ? "forum.php?page=".$page : "forum.php?page=".($page+1));
|
||||
|
||||
// replace in forum
|
||||
$inst_forum = str_replace(array('%%TOPICS%%', '%%FORUM_POST%%', '%%FORUM%%', '%%UCFORUM%%', '%%PREVIOUS%%', '%%LINKS%%', '%%NEXT%%'),
|
||||
array($inst_topic, $forum, nameToURL($forum), convert_forum_name($forum), $link_previous, $links_str, $link_next),
|
||||
$forum_main);
|
||||
|
||||
$pagename = $forum_dir.'forum'.($page==0 ? '' : '_'.$page).'.html';
|
||||
|
||||
$f = fopen($pagename, 'w');
|
||||
fwrite($f, $inst_forum);
|
||||
fclose($f);
|
||||
|
||||
++$page;
|
||||
|
||||
}
|
||||
while ($thread >= 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// rebuild user mail box pages
|
||||
// -------------------------------------
|
||||
function build_thread_page($forum, $thread, &$num_posts)
|
||||
{
|
||||
global $shard;
|
||||
$thread_dir = get_user_dir($forum, $shard);
|
||||
$thread_index = $thread_dir."thread_$thread.index";
|
||||
|
||||
// open thread index
|
||||
read_index($thread_index, $header, $posts);
|
||||
|
||||
$header = explode('%%', $header);
|
||||
|
||||
$thread_subject = $header[1];
|
||||
|
||||
$num_posts = count($posts);
|
||||
$num_per_page = 10;
|
||||
$num_pages = (int)(($num_posts+$num_per_page-1) / $num_per_page);
|
||||
|
||||
$post = 0;
|
||||
$page = 0;
|
||||
|
||||
$altern_color = array("#333333", "#666666");
|
||||
$altern_index = 0;
|
||||
|
||||
$links_str = '';
|
||||
|
||||
read_template('topic_main.html', $topic_main);
|
||||
read_template('topic_post.html', $topic_post);
|
||||
|
||||
read_template('browse_link.html', $browse_link);
|
||||
|
||||
do
|
||||
{
|
||||
$num_in_page = 0;
|
||||
$inst_post = '';
|
||||
|
||||
while ($num_in_page < 10 && $post < $num_posts)
|
||||
{
|
||||
$p = &$posts[$post];
|
||||
|
||||
$content = nl2br(displayable_content($p[1]));
|
||||
|
||||
$inst_post .= str_replace(array('%%FORUM%%', '%%UCFORUM%%', '%%SENDER%%', '%%UCSENDER%%', '%%DATE%%', '%%CONTENT%%', '%%POST%%', '%%COLOR%%'),
|
||||
array(nameToURL($forum), convert_forum_name($forum), $p[0], ucfirst($p[0]), $p[2], $content, $post, $altern_color[$altern_index]),
|
||||
$topic_post);
|
||||
|
||||
// step to next post
|
||||
++$num_in_page;
|
||||
++$post;
|
||||
$altern_index = 1-$altern_index;
|
||||
}
|
||||
|
||||
$links_str = '';
|
||||
$link_previous = ($page == 0 ? "thread.php?thread=$thread&page=".$page : "thread.php?thread=$thread&page=".($page-1));
|
||||
for ($i=0; $i<$num_pages; ++$i)
|
||||
{
|
||||
$link = ($i == $page ? $i+1 : "<a href='thread.php?thread=$thread&page=$i'>".($i+1)."</a>");
|
||||
$links_str .= str_replace(array('%%LINK%%'),
|
||||
array($link),
|
||||
$browse_link);
|
||||
}
|
||||
$link_next = (($page == $num_pages-1 || $num_pages <= 1) ? "thread.php?thread=$thread&page=".$page : "thread.php?thread=$thread&page=".($page+1));
|
||||
|
||||
$inst_topic = str_replace(array('%%POSTS%%', '%%FORUM_POST%%', '%%FORUM%%', '%%UCFORUM%%', '%%THREAD%%', '%%PREVIOUS%%', '%%LINKS%%', '%%NEXT%%', '%%SUBJECT%%'),
|
||||
array($inst_post, $forum, nameToURL($forum), convert_forum_name($forum), $thread, $link_previous, $links_str, $link_next, ucfirst($thread_subject)),
|
||||
$topic_main);
|
||||
|
||||
$pagename = $thread_dir."thread_$thread".($page==0 ? '' : '_'.$page).'.html';
|
||||
|
||||
$f = fopen($pagename, 'w');
|
||||
fwrite($f, $inst_topic);
|
||||
fclose($f);
|
||||
|
||||
++$page;
|
||||
}
|
||||
while ($post < $num_posts);
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
function getmicrotime()
|
||||
{
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
$__start = getmicrotime();
|
||||
|
||||
function display_time()
|
||||
{
|
||||
global $__start;
|
||||
$end = getmicrotime();
|
||||
echo (($end-$__start)*1000)." ms";
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,477 @@
|
||||
<?php
|
||||
|
||||
// Ryzom Core - MMORPG Framework <http://ryzom.dev/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (!isset($UTILS_PHP))
|
||||
{
|
||||
|
||||
// import HTTP_GET_VARS as _GET if _GET doesn't exist
|
||||
if (!isset($_GET) && isset($HTTP_GET_VARS))
|
||||
$_GET = &$HTTP_GET_VARS;
|
||||
|
||||
// import HTTP_POST_VARS as _GET if _POST doesn't exist
|
||||
if (!isset($_POST) && isset($HTTP_POST_VARS))
|
||||
$_POST = &$HTTP_POST_VARS;
|
||||
|
||||
$allowCookies = false;
|
||||
|
||||
// import HTTP_POST_VARS as _GET if _POST doesn't exist
|
||||
if ($allowCookies && !isset($_COOKIE) && isset($HTTP_COOKIE_VARS))
|
||||
$_COOKIE = &$HTTP_COOKIE_VARS;
|
||||
|
||||
// -------------------------------------
|
||||
// import HTTP param (from a GET or POST, or left if already set...)
|
||||
// -------------------------------------
|
||||
function importParam($var, $secureValue = true)
|
||||
{
|
||||
if (!$secureValue && isset($GLOBALS[$var]))
|
||||
return;
|
||||
|
||||
global $allowCookies, $_GET, $_POST, $_COOKIE;
|
||||
|
||||
if (isset($_GET[$var]))
|
||||
$GLOBALS[$var] = $_GET[$var];
|
||||
else if (isset($_POST[$var]))
|
||||
$GLOBALS[$var] = $_POST[$var];
|
||||
else if ($allowCookies && isset($_COOKIE[$var]))
|
||||
$GLOBALS[$var] = $_COOKIE[$var];
|
||||
else
|
||||
{
|
||||
//die("Missing arg '$var'");
|
||||
unset($GLOBALS[$var]);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// export HTTP param, as if user sent var in a POST
|
||||
// -------------------------------------
|
||||
function exportParam($var, $value)
|
||||
{
|
||||
global $_POST;
|
||||
$_POST[$var] = $value;
|
||||
}
|
||||
|
||||
|
||||
// always sent by client
|
||||
importParam('user_login');
|
||||
importParam('shard');
|
||||
importParam('session_cookie');
|
||||
|
||||
$user_login = trim($user_login);
|
||||
$session_cookie = stripslashes($session_cookie);
|
||||
|
||||
include_once('config.php');
|
||||
|
||||
$UTILS_PHP = 1;
|
||||
|
||||
// -------------------------------------
|
||||
// read an index
|
||||
// -------------------------------------
|
||||
function read_index($file, &$header, &$array)
|
||||
{
|
||||
if (!file_exists($file))
|
||||
{
|
||||
$header = '';
|
||||
$array = array();
|
||||
return;
|
||||
}
|
||||
|
||||
$f = fopen($file, 'r');
|
||||
|
||||
// read header
|
||||
$header = fgets($f, 512);
|
||||
|
||||
while (!feof($f))
|
||||
{
|
||||
// get a new line
|
||||
$line = trim(fgets($f, 10240));
|
||||
|
||||
// check line is not empty
|
||||
if ($line == "")
|
||||
continue;
|
||||
|
||||
// explode line
|
||||
$array[] = explode('%%', $line);
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// write an index
|
||||
// -------------------------------------
|
||||
function write_index($file, $header, &$array)
|
||||
{
|
||||
$f = fopen($file, 'w');
|
||||
|
||||
fwrite($f, str_pad(trim($header), 256));
|
||||
fwrite($f, "\n");
|
||||
|
||||
if (count($array) > 0)
|
||||
{
|
||||
foreach ($array as $l)
|
||||
{
|
||||
fwrite($f, trim(join('%%', $l)));
|
||||
fwrite($f, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// write an index
|
||||
// -------------------------------------
|
||||
function use_index($file)
|
||||
{
|
||||
if (!file_exists($file))
|
||||
{
|
||||
$f = fopen($file, 'w');
|
||||
update_next_index($f, 0);
|
||||
fclose($f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// write an index
|
||||
// -------------------------------------
|
||||
function read_next_index($f, &$index)
|
||||
{
|
||||
fseek($f, 0, SEEK_SET);
|
||||
$index = (int)fgets($f, 512);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// write an index
|
||||
// -------------------------------------
|
||||
function update_next_index($f, $index)
|
||||
{
|
||||
fseek($f, 0, SEEK_SET);
|
||||
|
||||
fwrite($f, str_pad($index, 256));
|
||||
fwrite($f, "\n");
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// write an index
|
||||
// -------------------------------------
|
||||
function append_to_index($f, $line)
|
||||
{
|
||||
fseek($f, 0, SEEK_END);
|
||||
|
||||
fwrite($f, $line, 8192);
|
||||
fwrite($f, "\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// write html prolog
|
||||
// -------------------------------------
|
||||
function write_prolog($f, $title)
|
||||
{
|
||||
fwrite($f, "<html><head><title>$title</title></head><body>\n");
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// write html epilog
|
||||
// -------------------------------------
|
||||
function write_epilog($f)
|
||||
{
|
||||
fwrite($f, "</body></html>\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// read template file
|
||||
// -------------------------------------
|
||||
function read_template($file, &$template)
|
||||
{
|
||||
global $TEMPLATE_DIR;
|
||||
$filename = $TEMPLATE_DIR.'/'.$file;
|
||||
$f = fopen($filename, 'r');
|
||||
$template = fread($f, filesize($filename));
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// redirect
|
||||
// -------------------------------------
|
||||
function redirect($url, $time=0)
|
||||
{
|
||||
echo "<html><head><title>Redirecting...</title>\n";
|
||||
echo "<meta http-equiv='refresh' content='$time; URL=$url'>\n";
|
||||
echo "</head>\n";
|
||||
echo "<body></body></html>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// convert to forum name
|
||||
// -------------------------------------
|
||||
function convert_forum_name($str)
|
||||
{
|
||||
return ucfirst(strtr($str, '_', ' '));
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// clean string
|
||||
// -------------------------------------
|
||||
function clean_string($str)
|
||||
{
|
||||
return strtr($str, array("\n" => '', '%' => '\%'));
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// clean content
|
||||
// -------------------------------------
|
||||
function clean_content($str)
|
||||
{
|
||||
return strtr($str, array("\n" => '\n', '%' => '\%'));
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// displayable string
|
||||
// -------------------------------------
|
||||
function displayable_string($str)
|
||||
{
|
||||
return nl2br(htmlspecialchars(stripslashes($str), ENT_QUOTES));
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// displayable string
|
||||
// -------------------------------------
|
||||
function displayable_content($str)
|
||||
{
|
||||
return htmlspecialchars(stripcslashes($str), ENT_QUOTES);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// displayable string
|
||||
// -------------------------------------
|
||||
function displayable_date()
|
||||
{
|
||||
return "<i>date#".date("y/m/d")."</i> ".date("H:i");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function matchParam($var, $param, &$value)
|
||||
{
|
||||
$plen = strlen($param);
|
||||
if (!strncmp($param, $var, $plen))
|
||||
{
|
||||
$value = trim(substr($var, $plen));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function nameToFile($name)
|
||||
{
|
||||
$r = '';
|
||||
for ($i=0; $i<strlen($name); ++$i)
|
||||
{
|
||||
if ($name[$i] == ' ')
|
||||
$r .= '_';
|
||||
else if ($name[$i] == '%' || $name[$i] <= chr(32) || $name[$i] >= chr(127))
|
||||
$r .= sprintf("%%%02x", ord($name[$i]));
|
||||
else
|
||||
$r .= $name[$i];
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function nameToURL($name)
|
||||
{
|
||||
$r = '';
|
||||
for ($i=0; $i<strlen($name); ++$i)
|
||||
{
|
||||
if ($name[$i] == ' ')
|
||||
$r .= '%20';
|
||||
else
|
||||
$r .= $name[$i];
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function nameFromURL($name)
|
||||
{
|
||||
return rawurldecode($name);
|
||||
}
|
||||
|
||||
function fileToName($file)
|
||||
{
|
||||
$n = '';
|
||||
for ($p=0; $p<strlen($file); ++$p)
|
||||
{
|
||||
if ($file[$p] == '%' && $file[$p+1] != '%')
|
||||
{
|
||||
$b = $file[++$p];
|
||||
$b .= $file[++$p];
|
||||
list($c) = sscanf($b, "%x");
|
||||
$n .= chr($c);
|
||||
}
|
||||
else if ($file[$p] == '_')
|
||||
{
|
||||
$n .= ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$n .= $file[$p];
|
||||
}
|
||||
}
|
||||
return $n;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// get user home directory
|
||||
// -------------------------------------
|
||||
function get_user_dir($user, $shard)
|
||||
{
|
||||
if ($user == "" || $shard == "")
|
||||
die("INTERNAL ERROR CODE 1");
|
||||
|
||||
global $USERS_DIR;
|
||||
|
||||
$user = nameToFile($user);
|
||||
|
||||
return $USERS_DIR.'/'.strtolower($shard).'/'.substr(strtolower($user), 0, 2).'/'.strtolower($user).'/';
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// build user home directory
|
||||
// -------------------------------------
|
||||
function build_user_dir($user, $shard)
|
||||
{
|
||||
$dir = get_user_dir($user, $shard);
|
||||
|
||||
$p = 0;
|
||||
while (!is_dir($dir))
|
||||
{
|
||||
$p = strpos($dir, '/', $p+1);
|
||||
if ($p == 0)
|
||||
{
|
||||
die("INTERNAL ERROR CODE 3");
|
||||
}
|
||||
else
|
||||
{
|
||||
$interm = substr($dir, 0, $p);
|
||||
if (!is_dir($interm))
|
||||
{
|
||||
if (!mkdir($interm, 0777))
|
||||
die("INTERNAL ERROR CODE 3");
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dir;
|
||||
}
|
||||
|
||||
include_once('login/config.php');
|
||||
|
||||
// -------------------------------------
|
||||
// connect to DB server and select ring DB
|
||||
// -------------------------------------
|
||||
function connect_to_ring_db()
|
||||
{
|
||||
global $DBHost, $RingDBUserName, $RingDBPassword, $RingDBName;
|
||||
$ringDb = mysql_connect($DBHost, $RingDBUserName, $RingDBPassword) or die("can't connect to ring db @'".$DBHost."' with user '".$RingDBUserName."'");
|
||||
mysql_select_db($RingDBName, $ringDb) or die("can't select ring db: '$RingDBName' Host=$DBHost User=$RingDBUserName (not enough privilege?)");
|
||||
return $ringDb;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// user_login=character_name => ring_live.characters[user_login].guild_id
|
||||
// test ring_live.guilds[guild_id].guild_name == $forum
|
||||
// -------------------------------------
|
||||
function check_character_belongs_to_guild($charName, $guildName)
|
||||
{
|
||||
connect_to_ring_db();
|
||||
$res = mysql_query(
|
||||
"SELECT guilds.guild_name FROM guilds
|
||||
JOIN characters ON characters.guild_id=guilds.guild_id
|
||||
WHERE char_name='$charName'")
|
||||
or die("Can't query guild for $charName in DB");
|
||||
if (false === ($row = mysql_fetch_row($res)))
|
||||
die("Guild not found for char $charName in DB");
|
||||
if ($row[0] != $guildName)
|
||||
die("ACCESS DENIED: $charName is not a member of $guildName");
|
||||
}
|
||||
|
||||
$remote_addr = $HTTP_SERVER_VARS['REMOTE_ADDR'];
|
||||
if ($remote_addr == "213.208.119.226" || $remote_addr == "38.117.236.132")
|
||||
{
|
||||
importParam('internal_check');
|
||||
if ($internal_check)
|
||||
{
|
||||
echo "INTERNAL CHECK\n";
|
||||
die("$internal_check:1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check user is valid
|
||||
*/
|
||||
if ($user_login == "support" && ($remote_addr == "192.168.1.153" || $remote_addr == "192.168.3.1") ||
|
||||
$remote_addr == "127.0.0.1" )
|
||||
{
|
||||
echo "SUPPORT MODE!";
|
||||
// do not check "support" email that come from rsweb
|
||||
//echo $HTTP_SERVER_VARS['REMOTE_ADDR'];
|
||||
//die();
|
||||
importParam('translate_user_login');
|
||||
if ($translate_user_login)
|
||||
$user_login = $translate_user_login;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strstr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'Ryzom'))
|
||||
die("ERROR: Bad parameters");
|
||||
$udir = get_user_dir($user_login, $shard);
|
||||
$ufile = $udir.'session';
|
||||
if (is_dir($udir) && file_exists($ufile))
|
||||
{
|
||||
$file = fopen($ufile, 'r');
|
||||
if (!$file)
|
||||
die("ERROR: Not logged");
|
||||
$server_cookie = trim(fgets($file, 1024));
|
||||
if ($server_cookie != $session_cookie)
|
||||
die("ERROR: Authentication failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
die("ERROR: Directory not found: ".$udir);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
After Width: | Height: | Size: 330 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 529 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 751 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 108 B |
After Width: | Height: | Size: 1017 B |
After Width: | Height: | Size: 110 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1017 B |
After Width: | Height: | Size: 731 B |
After Width: | Height: | Size: 1012 B |