mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-12 03:18:48 +00:00
jappixmini: include jappix source
This commit is contained in:
parent
61eb1f0d18
commit
302b2820d1
231 changed files with 96082 additions and 2 deletions
118
jappixmini/jappix/php/avatar-upload.php
Normal file
118
jappixmini/jappix/php/avatar-upload.php
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the avatar upload PHP script for Jappix
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 27/05/11
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed for a special node
|
||||
if(isStatic() || isUpload())
|
||||
exit;
|
||||
|
||||
// Set a special XML header
|
||||
header('Content-Type: text/xml; charset=utf-8');
|
||||
|
||||
// No file uploaded?
|
||||
if((!isset($_FILES['file']) || empty($_FILES['file'])) || (!isset($_POST['id']) || empty($_POST['id'])))
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:avatar:post\' id=\'0\'>
|
||||
<error>bad-request</error>
|
||||
</jappix>'
|
||||
);
|
||||
|
||||
// Get the POST vars
|
||||
$id = $_POST['id'];
|
||||
$tmp_filename = $_FILES['file']['tmp_name'];
|
||||
$old_filename = $_FILES['file']['name'];
|
||||
|
||||
// Get the file extension
|
||||
$ext = getFileExt($old_filename);
|
||||
|
||||
// Hash it!
|
||||
$filename = md5($old_filename.time()).$ext;
|
||||
|
||||
// Define some vars
|
||||
$path = JAPPIX_BASE.'/store/avatars/'.$filename;
|
||||
|
||||
// Define MIME type
|
||||
if($ext == 'jpg')
|
||||
$ext = 'jpeg';
|
||||
|
||||
$mime = 'image/'.$ext;
|
||||
|
||||
// Unsupported file extension?
|
||||
if(!preg_match('/^(jpeg|png|gif)$/i', $ext))
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:avatar:post\' id=\''.$id.'\'>
|
||||
<error>forbidden-type</error>
|
||||
</jappix>'
|
||||
);
|
||||
|
||||
// File upload error?
|
||||
if(!is_uploaded_file($tmp_filename) || !move_uploaded_file($tmp_filename, $path))
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\' id=\''.$id.'\'>
|
||||
<error>move-error</error>
|
||||
</jappix>'
|
||||
);
|
||||
|
||||
// Resize the image?
|
||||
if(!function_exists('gd_info') || resizeImage($path, $ext, 96, 96)) {
|
||||
try {
|
||||
// Encode the file
|
||||
$binval = base64_encode(file_get_contents($path));
|
||||
|
||||
// Remove the file
|
||||
unlink($path);
|
||||
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\' id=\''.$id.'\'>
|
||||
<type>'.$mime.'</type>
|
||||
<binval>'.$binval.'</binval>
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
|
||||
catch(Exception $e) {
|
||||
// Remove the file
|
||||
unlink($path);
|
||||
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\' id=\''.$id.'\'>
|
||||
<error>server-error</error>
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the file
|
||||
unlink($path);
|
||||
|
||||
// Something went wrong!
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\' id=\''.$id.'\'>
|
||||
<error>service-unavailable</error>
|
||||
</jappix>'
|
||||
);
|
||||
|
||||
?>
|
167
jappixmini/jappix/php/bosh.php
Normal file
167
jappixmini/jappix/php/bosh.php
Normal file
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the PHP BOSH proxy
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 15/01/12
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the configuration
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed?
|
||||
if(!BOSHProxy()) {
|
||||
header('Status: 403 Forbidden', true, 403);
|
||||
exit('HTTP/1.1 403 Forbidden');
|
||||
}
|
||||
|
||||
// OPTIONS method?
|
||||
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
||||
// CORS headers
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
header('Access-Control-Max-Age: 31536000');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Read POST content
|
||||
$data = file_get_contents('php://input');
|
||||
|
||||
// POST method?
|
||||
if($data) {
|
||||
// CORS headers
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
|
||||
$method = 'POST';
|
||||
}
|
||||
|
||||
// GET method?
|
||||
else if(isset($_GET['data']) && $_GET['data'] && isset($_GET['callback']) && $_GET['callback']) {
|
||||
$method = 'GET';
|
||||
$data = $_GET['data'];
|
||||
$callback = $_GET['callback'];
|
||||
}
|
||||
|
||||
// Invalid method?
|
||||
else {
|
||||
header('Status: 400 Bad Request', true, 400);
|
||||
exit('HTTP/1.1 400 Bad Request');
|
||||
}
|
||||
|
||||
// HTTP headers
|
||||
$headers = array('User-Agent: Jappix (BOSH PHP Proxy)', 'Connection: close', 'Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($data));
|
||||
|
||||
// CURL is better if available
|
||||
if(function_exists('curl_init'))
|
||||
$use_curl = true;
|
||||
else
|
||||
$use_curl = false;
|
||||
|
||||
// CURL stream functions
|
||||
if($use_curl) {
|
||||
// Initialize CURL
|
||||
$connection = curl_init(HOST_BOSH);
|
||||
|
||||
// Set the CURL settings
|
||||
curl_setopt($connection, CURLOPT_HEADER, 0);
|
||||
curl_setopt($connection, CURLOPT_POST, 1);
|
||||
curl_setopt($connection, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($connection, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($connection, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt($connection, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($connection, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// Get the CURL output
|
||||
$output = curl_exec($connection);
|
||||
}
|
||||
|
||||
// Built-in stream functions
|
||||
else {
|
||||
// HTTP parameters
|
||||
$parameters = array('http' => array(
|
||||
'method' => 'POST',
|
||||
'content' => $data
|
||||
)
|
||||
);
|
||||
|
||||
$parameters['http']['header'] = $headers;
|
||||
|
||||
// Change default timeout
|
||||
ini_set('default_socket_timeout', 30);
|
||||
|
||||
// Create the connection
|
||||
$stream = @stream_context_create($parameters);
|
||||
$connection = @fopen(HOST_BOSH, 'rb', false, $stream);
|
||||
|
||||
// Failed to connect!
|
||||
if($connection == false) {
|
||||
header('Status: 502 Proxy Error', true, 502);
|
||||
exit('HTTP/1.1 502 Proxy Error');
|
||||
}
|
||||
|
||||
// Allow stream blocking to handle incoming BOSH data
|
||||
@stream_set_blocking($connection, true);
|
||||
|
||||
// Get the output content
|
||||
$output = @stream_get_contents($connection);
|
||||
}
|
||||
|
||||
// Cache headers
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
|
||||
// POST output
|
||||
if($method == 'POST') {
|
||||
// XML header
|
||||
header('Content-Type: text/xml; charset=utf-8');
|
||||
|
||||
if(!$output)
|
||||
echo('<body xmlns=\'http://jabber.org/protocol/httpbind\' type=\'terminate\'/>');
|
||||
else
|
||||
echo($output);
|
||||
}
|
||||
|
||||
// GET output
|
||||
if($method == 'GET') {
|
||||
// JSON header
|
||||
header('Content-type: application/json');
|
||||
|
||||
// Encode output to JSON
|
||||
$json_output = json_encode($output);
|
||||
|
||||
if(($output == false) || ($output == '') || ($json_output == 'null'))
|
||||
echo($callback.'({"reply":"<body xmlns=\'http:\/\/jabber.org\/protocol\/httpbind\' type=\'terminate\'\/>"});');
|
||||
else
|
||||
echo($callback.'({"reply":'.$json_output.'});');
|
||||
}
|
||||
|
||||
// Close the connection
|
||||
if($use_curl)
|
||||
curl_close($connection);
|
||||
else
|
||||
@fclose($connection);
|
||||
|
||||
?>
|
181
jappixmini/jappix/php/desktop.php
Normal file
181
jappixmini/jappix/php/desktop.php
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix Desktop PHP/HTML code
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 16/01/12
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<?php htmlTag($locale); ?>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title><?php echo htmlspecialchars(SERVICE_NAME); ?> • <?php _e("An open social network"); ?></title>
|
||||
<link rel="shortcut icon" href="./favicon.ico" />
|
||||
|
||||
<?php echoGetFiles($hash, '', 'css', 'desktop.xml', ''); echo "\n"; ?>
|
||||
<!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
|
||||
|
||||
<?php echoGetFiles($hash, $locale, 'js', 'desktop.xml', ''); echo "\n";
|
||||
|
||||
if(anonymousMode()) {
|
||||
echo "\n\t";
|
||||
echoGetFiles($hash, '', 'css', 'anonymous.xml', '');
|
||||
echo "\n\t";
|
||||
echoGetFiles($hash, $locale, 'js', 'anonymous.xml', '');
|
||||
echo "\n";
|
||||
} ?>
|
||||
</head>
|
||||
|
||||
<body class="body-images">
|
||||
|
||||
<?php
|
||||
|
||||
// Homepage?
|
||||
if(!anonymousMode()) { ?>
|
||||
<!-- BEGIN HOMEPAGE -->
|
||||
<div id="home">
|
||||
<div class="home-images plane"></div>
|
||||
|
||||
<div class="main">
|
||||
<div class="left">
|
||||
<div class="home-images logo"></div>
|
||||
<p class="upper"><?php _e("Communicate with the entire world!"); ?></p>
|
||||
<p class="secondary"><?php _e("Jappix is a great social platform, that you can access wherever you are, whenever you want and communicate with whovever you want."); ?></p>
|
||||
<p class="secondary"><?php _e("It allows you to get in touch with the millions of users who currently use the XMPP network like you do with Jappix. Join the community and stay free!"); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<h1 class="top default"><?php _e("Hi there!"); ?></h1>
|
||||
|
||||
<div class="default homediv">
|
||||
<p><?php printf(T_("Welcome on %1s, “%2s”."), htmlspecialchars(SERVICE_NAME), htmlspecialchars(SERVICE_DESC)); ?></p>
|
||||
|
||||
<p><?php _e("Login to your existing XMPP account or create a new one for free!"); ?></p>
|
||||
|
||||
<button class="login buttons-images">
|
||||
<span class="home-images"></span>
|
||||
<span class="text"><?php _e("Login"); ?></span>
|
||||
</button>
|
||||
|
||||
<button class="register buttons-images">
|
||||
<span class="home-images"></span>
|
||||
<span class="text"><?php _e("Register"); ?></span>
|
||||
</button>
|
||||
|
||||
<p class="notice"><?php echo str_replace("PostPro", "<a href='http://www.post-pro.fr/'>PostPro</a>", T_("Jappix is an open-source project from PostPro, a non-profit organization which provides us a great help.")); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="navigation">
|
||||
<?php
|
||||
|
||||
// Keep get var
|
||||
$keep_get = keepGet('m', false);
|
||||
|
||||
?>
|
||||
<a class="home-images mobile" href="./?m=mobile<?php echo $keep_get; ?>"><?php _e("Mobile"); ?></a>
|
||||
<?php if(showManagerLink()) { ?>
|
||||
<a class="home-images manager" href="./?m=manager<?php echo $keep_get; ?>"><?php _e("Manager"); ?></a>
|
||||
<?php } ?>
|
||||
<a class="home-images project" href="https://project.jappix.com/"><?php _e("Project"); ?></a>
|
||||
<?php if(sslCheck() && !httpsForce()) echo sslLink(); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="home-images corporation">
|
||||
<div class="corp_network">
|
||||
<h2 class="nomargin">Jappix.com</h2>
|
||||
<div class="tabulate">
|
||||
<a href="https://www.jappix.com/">
|
||||
<span class="name">Jappix</span>
|
||||
<span class="desc"><?php _e("Social channel, chat and more."); ?></span>
|
||||
</a>
|
||||
<a href="https://me.jappix.com/">
|
||||
<span class="name">Jappix Me</span>
|
||||
<span class="desc"><?php _e("Create your public profile."); ?></span>
|
||||
</a>
|
||||
<a href="https://mini.jappix.com/">
|
||||
<span class="name">Jappix Mini</span>
|
||||
<span class="desc"><?php _e("A mini-chat for your website."); ?></span>
|
||||
</a>
|
||||
<a href="https://project.jappix.com/">
|
||||
<span class="name">Jappix Project</span>
|
||||
<span class="desc"><?php _e("Get Jappix, get support."); ?></span>
|
||||
</a>
|
||||
<a href="https://stats.jappix.com/">
|
||||
<span class="name">Jappix Stats</span>
|
||||
<span class="desc"><?php _e("Statistics around Jappix."); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h2>Jappix.org</h2>
|
||||
<div class="tabulate">
|
||||
<a href="http://jappix.org/">
|
||||
<span class="name">Jappix Download</span>
|
||||
<span class="desc"><?php _e("Download Jappix for free."); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h2>Jappix.net</h2>
|
||||
<div class="tabulate">
|
||||
<a href="http://jappix.net/">
|
||||
<span class="name">Jappix Network</span>
|
||||
<span class="desc"><?php _e("Find a public Jappix node."); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="locale" data-keepget="<?php echo(keepGet('l', false)); ?>">
|
||||
<div class="current">
|
||||
<div class="current_align"><?php echo(getLanguageName($locale)); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// Add the notice
|
||||
$conf_notice = readNotice();
|
||||
$type_notice = $conf_notice['type'];
|
||||
$text_notice = $conf_notice['notice'];
|
||||
|
||||
// Simple notice
|
||||
if(($type_notice == 'simple') || ($type_notice == 'advanced')) {
|
||||
// We must encode special HTML characters
|
||||
if($type_notice == 'simple')
|
||||
$text_notice = '<span class="title home-images">'.T_("Notice").'</span><span class="text">'.htmlentities($text_notice).'</span>';
|
||||
|
||||
// Echo the notice
|
||||
echo('<div class="notice '.$type_notice.'">'.$text_notice.'</div>');
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
<!-- END HOMEPAGE -->
|
||||
<?php } ?>
|
||||
|
||||
<!-- BEGIN BOARD -->
|
||||
<div id="board">
|
||||
<noscript class="one-board info visible"><?php _e("JavaScript is missing in your web browser, so that you will not be able to launch Jappix! Please fix this."); ?></noscript>
|
||||
</div>
|
||||
<!-- END BOARD -->
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<!-- Jappix <?php echo $version; ?> - An open social platform -->
|
53
jappixmini/jappix/php/download-chat.php
Normal file
53
jappixmini/jappix/php/download-chat.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the PHP script used to download a chat log
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 27/05/11
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed for a special node
|
||||
if(isStatic() || isUpload())
|
||||
exit;
|
||||
|
||||
// Send the HTML file to be downloaded
|
||||
if(isset($_GET['id']) && !empty($_GET['id']) && isSafe($_GET['id'])) {
|
||||
// We define the variables
|
||||
$filename = $_GET['id'];
|
||||
$content_dir = '../store/logs/';
|
||||
$filepath = $content_dir.$filename.'.html';
|
||||
|
||||
// We set special headers
|
||||
header("Content-disposition: attachment; filename=\"$filename.html\"");
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Transfer-Encoding: text/html\n");
|
||||
header("Content-Length: ".filesize($filepath));
|
||||
header("Pragma: no-cache");
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
|
||||
header("Expires: 0");
|
||||
readfile($filepath);
|
||||
|
||||
// We delete the stored log file
|
||||
unlink($filepath);
|
||||
}
|
||||
|
||||
?>
|
495
jappixmini/jappix/php/drawsvgchart.php
Normal file
495
jappixmini/jappix/php/drawsvgchart.php
Normal file
|
@ -0,0 +1,495 @@
|
|||
<?php
|
||||
|
||||
// Extracted from CodingTeam for the Jappix project.
|
||||
|
||||
// This file is a part of CodingTeam. Take a look at <http://codingteam.org>.
|
||||
// Copyright © 2007-2010 Erwan Briand <erwan@codingteam.net>
|
||||
//
|
||||
// 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, version 3 only.
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file contains the DrawSVGChart class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DrawSVGChart class
|
||||
*/
|
||||
class DrawSVGChart {
|
||||
private $datas, $legend, $link, $xml_object, $svg,
|
||||
$xml_elements, $evolution;
|
||||
public $has_errors;
|
||||
|
||||
function createChart($datas=array(), $legend=array(), $link,
|
||||
$evolution=FALSE, $type='others')
|
||||
{
|
||||
$this->has_errors = FALSE;
|
||||
$max = 0;
|
||||
|
||||
// One or two data arrays
|
||||
if (isset($datas[0]) && is_array($datas[0]))
|
||||
{
|
||||
$datas_number = count($datas[0]);
|
||||
|
||||
if ($datas_number >= 1)
|
||||
$max = max($datas[0]);
|
||||
else
|
||||
$this->has_errors = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$datas_number = count($datas);
|
||||
|
||||
if ($datas_number >= 1)
|
||||
$max = max($datas);
|
||||
else
|
||||
$this->has_errors = TRUE;
|
||||
}
|
||||
|
||||
// Set the width of the chart
|
||||
if ($datas_number * 55 > 400)
|
||||
$width = $datas_number * 55;
|
||||
else
|
||||
$width = 400;
|
||||
|
||||
$height = 250;
|
||||
$this->datas = $datas;
|
||||
$this->legend = $legend;
|
||||
$this->link = $link;
|
||||
$this->evolution = $evolution;
|
||||
$this->type = $type;
|
||||
$this->xml_elements = array();
|
||||
|
||||
// Scale
|
||||
if ($max <= 20)
|
||||
{
|
||||
$scale[4] = 20;
|
||||
$scale[3] = 15;
|
||||
$scale[2] = 10;
|
||||
$scale[1] = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
$scale[4] = ceil($max / 20) * 20;
|
||||
$scale[3] = $scale[4] * 3/4;
|
||||
$scale[2] = $scale[4] * 2/4;
|
||||
$scale[1] = $scale[4] * 1/4;
|
||||
}
|
||||
|
||||
if ($scale[4] == 0 || $max == 0)
|
||||
$this->has_errors = TRUE;
|
||||
|
||||
if ($this->has_errors)
|
||||
return TRUE;
|
||||
|
||||
$this->xml_object = new DOMDocument('1.0', 'utf-8');
|
||||
|
||||
// Process the static file host prefix
|
||||
$static_prefix = '.';
|
||||
|
||||
if(hasStatic())
|
||||
$static_prefix = HOST_STATIC.'/php';
|
||||
|
||||
// Add the stylesheet
|
||||
$style = $this->xml_object->createProcessingInstruction("xml-stylesheet",
|
||||
"type='text/css' href='".getFiles(genHash(getVersion()), '', 'css', '', 'stats-svg.css')."'");
|
||||
$this->xml_object->appendChild($style);
|
||||
|
||||
// Create the root SVG element
|
||||
$this->svg = $this->xml_object->createElement('svg');
|
||||
$this->svg->setAttribute('xmlns:svg', 'http://www.w3.org/2000/svg');
|
||||
$this->svg->setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
||||
$this->svg->setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$this->svg->setAttribute('version', '1.1');
|
||||
$this->svg->setAttribute('width', $width);
|
||||
$this->svg->setAttribute('height', $height);
|
||||
$this->svg->setAttribute('id', 'svg');
|
||||
$this->xml_object->appendChild($this->svg);
|
||||
|
||||
// Create a definition
|
||||
$this->xml_elements['basic_defs'] = $this->xml_object->createElement('defs');
|
||||
$path = $this->xml_object->createElement('path');
|
||||
$path->setAttribute('id', 'mark');
|
||||
$path->setAttribute('d', 'M 0,234 v 4 ');
|
||||
$path->setAttribute('stroke', '#596171');
|
||||
$path->setAttribute('stroke-width', '2px');
|
||||
$this->xml_elements['basic_defs']->appendChild($path);
|
||||
|
||||
// Create the static background
|
||||
$this->xml_elements['static_background'] = $this->xml_object->createElement('g');
|
||||
$this->xml_elements['static_background']->setAttribute('class', 'static-background');
|
||||
|
||||
// Draw the legend
|
||||
$this->drawLegend();
|
||||
|
||||
// Draw the table
|
||||
$this->drawTable($scale, $width);
|
||||
|
||||
// Draw the chart
|
||||
$this->drawChart($scale, $width);
|
||||
}
|
||||
|
||||
function drawLegend()
|
||||
{
|
||||
$pstart = 3;
|
||||
$tstart = 7;
|
||||
|
||||
foreach ($this->legend as $item)
|
||||
{
|
||||
$val_path = $pstart + 11;
|
||||
$val_text = $tstart + 10;
|
||||
|
||||
// Create the legend line
|
||||
$path = $this->xml_object->createElement('path');
|
||||
$path->setAttribute('d', 'M 40, '.$val_path.' L 55, '.$val_path);
|
||||
$path->setAttribute('id', 'legendline');
|
||||
$path->setAttribute('stroke', $item[0]);
|
||||
$path->setAttribute('stroke-width', '2px');
|
||||
|
||||
// Create the legend text
|
||||
$text = $this->xml_object->createElement('text', $item[1]);
|
||||
$text->setAttribute('x', 57);
|
||||
$text->setAttribute('y', $val_text);
|
||||
$text->setAttribute('text-anchor', 'start');
|
||||
$text->setAttribute('id', 'reftext');
|
||||
$text->setAttribute('fill', $item[0]);
|
||||
$text->setAttribute('font-size', '11px');
|
||||
$text->setAttribute('font-family', "'DejaVu sans', Verdana, sans-serif");
|
||||
|
||||
// Append elemets
|
||||
$this->xml_elements['static_background']->appendChild($path);
|
||||
$this->xml_elements['static_background']->appendChild($text);
|
||||
|
||||
$pstart = $val_path;
|
||||
$tstart = $val_text;
|
||||
}
|
||||
}
|
||||
|
||||
function drawTable($scale, $width)
|
||||
{
|
||||
// Create left scale
|
||||
$top = TRUE;
|
||||
$start = -17;
|
||||
|
||||
foreach ($scale as $level)
|
||||
{
|
||||
$type = $this->type;
|
||||
|
||||
if(($type == 'share') || ($type == 'others'))
|
||||
$level = formatBytes($level);
|
||||
|
||||
if ($top)
|
||||
$color = '#CED0D5';
|
||||
else
|
||||
$color = '#EAEAEA';
|
||||
|
||||
$m = $start + 50;
|
||||
|
||||
$path = $this->xml_object->createElement('path');
|
||||
$path->setAttribute('d', 'M 38, '.$m.' L '.$width.', '.$m);
|
||||
$path->setAttribute('stroke', $color);
|
||||
$path->setAttribute('stroke-width', '1px');
|
||||
|
||||
$text = $this->xml_object->createElement('text', $level);
|
||||
$text->setAttribute('x', 34);
|
||||
$text->setAttribute('y', ($m + 3));
|
||||
$text->setAttribute('text-anchor', 'end');
|
||||
$text->setAttribute('class', 'refleft');
|
||||
|
||||
$this->xml_elements['static_background']->appendChild($path);
|
||||
$this->xml_elements['static_background']->appendChild($text);
|
||||
|
||||
$top = FALSE;
|
||||
$start = $m;
|
||||
}
|
||||
|
||||
// Add zero
|
||||
$text = $this->xml_object->createElement('text', 0);
|
||||
$text->setAttribute('x', 34);
|
||||
$text->setAttribute('y', 236);
|
||||
$text->setAttribute('text-anchor', 'end');
|
||||
$text->setAttribute('class', 'refleft');
|
||||
|
||||
$this->xml_elements['static_background']->appendChild($text);
|
||||
}
|
||||
|
||||
function drawChart($scale, $width)
|
||||
{
|
||||
if (isset($this->datas[0]) && is_array($this->datas[0]))
|
||||
{
|
||||
$foreached_datas = $this->datas[0];
|
||||
$onlykeys_datas = array_keys($this->datas[0]);
|
||||
$secondary_datas = array_keys($this->datas[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$foreached_datas = $this->datas;
|
||||
$onlykeys_datas = array_keys($this->datas);
|
||||
$secondary_datas = FALSE;
|
||||
}
|
||||
|
||||
// Create graphics data
|
||||
$defs = $this->xml_object->createElement('defs');
|
||||
|
||||
$rect = $this->xml_object->createElement('rect');
|
||||
$rect->setAttribute('id', 'focusbar');
|
||||
$rect->setAttribute('width', 14);
|
||||
$rect->setAttribute('height', 211);
|
||||
$rect->setAttribute('x', -20);
|
||||
$rect->setAttribute('y', 34);
|
||||
$rect->setAttribute('style', 'fill: black; opacity: 0;');
|
||||
$defs->appendChild($rect);
|
||||
|
||||
$path = $this->xml_object->createElement('path');
|
||||
$path->setAttribute('id', 'bubble');
|
||||
|
||||
if ($this->evolution)
|
||||
$path->setAttribute('d', 'M 4.7871575,0.5 L 39.084404,0.5 C 41.459488,0.5 43.371561,2.73 43.371561,5.5 L 43.371561,25.49999 L 43.30,31.05 L 4.7871575,30.49999 C 2.412072,30.49999 0.5,28.26999 0.5,25.49999 L 0.5,5.5 C 0.5,2.73 2.412072,0.5 4.7871575,0.5 z');
|
||||
elseif ($secondary_datas)
|
||||
$path->setAttribute('d', 'M 1,0 v 8 l -6,-10 c -1.5,-2 -1.5,-2 -6,-2 h -36 c -3,0 -6,-3 -6,-6 v -28 c 0,-3 3,-6 6,-6 h 43 c 3,0 6,3 6,6 z');
|
||||
else
|
||||
$path->setAttribute('d', 'M 4.7871575,0.5 L 39.084404,0.5 C 41.459488,0.5 43.371561,2.73 43.371561,5.5 L 43.371561,25.49999 C 43.371561,27.07677 43.83887,41.00777 42.990767,40.95796 C 42.137828,40.90787 37.97451,30.49999 36.951406,30.49999 L 4.7871575,30.49999 C 2.412072,30.49999 0.5,28.26999 0.5,25.49999 L 0.5,5.5 C 0.5,2.73 2.412072,0.5 4.7871575,0.5 z');
|
||||
|
||||
$path->setAttribute('fill', 'none');
|
||||
$path->setAttribute('fill-opacity', '0.85');
|
||||
$path->setAttribute('pointer-events', 'none');
|
||||
$path->setAttribute('stroke-linejoin', 'round');
|
||||
$path->setAttribute('stroke', 'none');
|
||||
$path->setAttribute('stroke-opacity', '0.8');
|
||||
$path->setAttribute('stroke-width', '1px');
|
||||
$defs->appendChild($path);
|
||||
|
||||
$rect = $this->xml_object->createElement('rect');
|
||||
$rect->setAttribute('id', 'graphicbar');
|
||||
$rect->setAttribute('width', '12');
|
||||
$rect->setAttribute('height', '200');
|
||||
$rect->setAttribute('rx', '2');
|
||||
$rect->setAttribute('ry', '1');
|
||||
$rect->setAttribute('fill', '#6C84C0');
|
||||
$rect->setAttribute('fill-opacity', '0.6');
|
||||
$rect->setAttribute('stroke', '#5276A9');
|
||||
$rect->setAttribute('stroke-width', '1px');
|
||||
$defs->appendChild($rect);
|
||||
|
||||
$rect = $this->xml_object->createElement('rect');
|
||||
$rect->setAttribute('style', 'fill:#8B2323');
|
||||
$rect->setAttribute('id', 'rectpoint');
|
||||
$rect->setAttribute('width', 4);
|
||||
$rect->setAttribute('height', 4);
|
||||
$defs->appendChild($rect);
|
||||
|
||||
$this->xml_elements['chart_defs'] = $defs;
|
||||
$global_g = $this->xml_object->createElement('g');
|
||||
|
||||
// Calc
|
||||
$x_base = 35;
|
||||
$y_base = 20;
|
||||
$start = 18;
|
||||
$element = 0;
|
||||
|
||||
$chart_defs = '';
|
||||
$xprevious = 38;
|
||||
$tprevious = 233;
|
||||
|
||||
foreach ($foreached_datas as $key => $data)
|
||||
{
|
||||
$x = 27 + $x_base;
|
||||
$y = 107 + $y_base;
|
||||
|
||||
$top = 233 - ceil($data / ($scale[4] / 100) * 2);
|
||||
|
||||
if ($top <= 50)
|
||||
$bubble_top = 55;
|
||||
elseif (!$secondary_datas)
|
||||
$bubble_top = ($top - 42);
|
||||
elseif ($secondary_datas)
|
||||
$bubble_top = ($top - 10);
|
||||
|
||||
$type = $this->type;
|
||||
|
||||
if(($type == 'share') || ($type == 'others'))
|
||||
$value = formatBytes($data);
|
||||
else
|
||||
$value = $data;
|
||||
|
||||
// Create the chart with datas
|
||||
$g = $this->xml_object->createElement('g');
|
||||
$g->setAttribute('transform', 'translate('.$x.')');
|
||||
|
||||
$duse = $this->xml_object->createElement('use');
|
||||
$duse->setAttribute('xlink:href', '#mark');
|
||||
$duse->setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$g->appendChild($duse);
|
||||
|
||||
$data_g = $this->xml_object->createElement('g');
|
||||
$data_g->setAttribute('class', 'gbar');
|
||||
|
||||
if ($this->link)
|
||||
{
|
||||
$text = $this->xml_object->createElement('text');
|
||||
|
||||
$link = $this->xml_object->createElement('a', mb_substr(filterSpecialXML($onlykeys_datas[$element]), 0, 7));
|
||||
$link->setAttribute('xlink:href', str_replace('{data}', filterSpecialXML($onlykeys_datas[$element]), $this->link));
|
||||
$link->setAttribute('target', '_main');
|
||||
$text->appendChild($link);
|
||||
}
|
||||
else
|
||||
$text = $this->xml_object->createElement('text', mb_substr(filterSpecialXML($onlykeys_datas[$element]), 0, 7));
|
||||
|
||||
$text->setAttribute('class', 'reftext');
|
||||
$text->setAttribute('y', 248);
|
||||
$text->setAttribute('text-anchor', 'middle');
|
||||
|
||||
$data_g->appendChild($text);
|
||||
|
||||
$uselink = $this->xml_object->createElement('use');
|
||||
$uselink->setAttribute('xlink:href', '#focusbar');
|
||||
$uselink->setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$data_g->appendChild($uselink);
|
||||
|
||||
if (!$this->evolution)
|
||||
{
|
||||
$rect = $this->xml_object->createElement('rect');
|
||||
$rect->setAttribute('class', 'bluebar');
|
||||
$rect->setAttribute('height', (233 - $top));
|
||||
$rect->setAttribute('width', 13);
|
||||
$rect->setAttribute('x', -6);
|
||||
$rect->setAttribute('y', $top);
|
||||
$rect->setAttribute('fill', $this->legend[0][0]);
|
||||
$rect->setAttribute('fill-opacity', '0.6');
|
||||
$data_g->appendChild($rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
$use = $this->xml_object->createElement('use');
|
||||
$use->setAttribute('xlink:href', '#rectpoint');
|
||||
$use->setAttribute('y', ($top - 1));
|
||||
$use->setAttribute('x', -2);
|
||||
$data_g->appendChild($use);
|
||||
|
||||
if ($x != (35 + 27))
|
||||
$chart_defs .= 'L '.$x.' '.$top.' ';
|
||||
else
|
||||
$chart_defs .= 'M '.$xprevious.' '.$tprevious.' L '.$x.' '.$top.' ';
|
||||
|
||||
$xprevious = $x;
|
||||
$tprevious = $top;
|
||||
}
|
||||
|
||||
if ($secondary_datas && isset($secondary_datas[$element]))
|
||||
{
|
||||
$datalink = $secondary_datas[$element];
|
||||
$dataval = $this->datas[1][$datalink];
|
||||
$stop = 233 - ceil($dataval / ($scale[4] / 100) * 2);
|
||||
|
||||
$rect = $this->xml_object->createElement('rect');
|
||||
$rect->setAttribute('class', 'redbar');
|
||||
$rect->setAttribute('height', (233 - $stop));
|
||||
$rect->setAttribute('width', 13);
|
||||
$rect->setAttribute('x', -6);
|
||||
$rect->setAttribute('y', $stop);
|
||||
$rect->setAttribute('fill', $this->legend[1][0]);
|
||||
$rect->setAttribute('fill-opacity', '0.7');
|
||||
$data_g->appendChild($rect);
|
||||
}
|
||||
|
||||
if (!$this->evolution)
|
||||
{
|
||||
$path = $this->xml_object->createElement('path');
|
||||
$path->setAttribute('stroke', '#5276A9');
|
||||
$path->setAttribute('stroke-width', '2px');
|
||||
$path->setAttribute('fill', 'none');
|
||||
$path->setAttribute('d', 'M -7,233 v -'.(232 - $top).' c 0,-1 1,-1 1,-1 h 12 c 1,0 2,0 2,1 v '.(232 - $top).' z');
|
||||
$data_g->appendChild($path);
|
||||
}
|
||||
|
||||
$uselink = $this->xml_object->createElement('use');
|
||||
$uselink->setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$uselink->setAttribute('xlink:href', '#bubble');
|
||||
$uselink->setAttribute('y', $bubble_top);
|
||||
|
||||
if (!$secondary_datas)
|
||||
$uselink->setAttribute('x', -42);
|
||||
|
||||
$data_g->appendChild($uselink);
|
||||
|
||||
$text = $this->xml_object->createElement('text', $value);
|
||||
$text->setAttribute('class', 'bubbletextblue');
|
||||
$text->setAttribute('x', -10);
|
||||
|
||||
if (!$secondary_datas)
|
||||
$text->setAttribute('y', ($bubble_top + 20));
|
||||
else
|
||||
$text->setAttribute('y', ($bubble_top - 27));
|
||||
|
||||
$text->setAttribute('fill', 'none');
|
||||
$data_g->appendChild($text);
|
||||
|
||||
if ($secondary_datas && isset($secondary_datas[$element]))
|
||||
{
|
||||
$text = $this->xml_object->createElement('text', $dataval);
|
||||
$text->setAttribute('class', 'bubbletextred');
|
||||
$text->setAttribute('x', -10);
|
||||
$text->setAttribute('y', ($bubble_top - 11));
|
||||
$text->setAttribute('fill', 'none');
|
||||
$data_g->appendChild($text);
|
||||
}
|
||||
|
||||
$g->appendChild($data_g);
|
||||
$global_g->appendChild($g);
|
||||
|
||||
$x_base = $x_base + 50;
|
||||
$y_base = $y_base + 20;
|
||||
$element ++;
|
||||
}
|
||||
|
||||
if ($this->evolution)
|
||||
{
|
||||
$path = $this->xml_object->createElement('path');
|
||||
$path->setAttribute('d', $chart_defs);
|
||||
$path->setAttribute('stroke', $this->legend[0][0]);
|
||||
$path->setAttribute('stroke-width', '1px');
|
||||
$path->setAttribute('fill', 'none');
|
||||
$this->xml_elements['evolution_path'] = $path;
|
||||
}
|
||||
|
||||
$this->xml_elements['global_g'] = $global_g;
|
||||
|
||||
$path = $this->xml_object->createElement('path');
|
||||
$path->setAttribute('d', 'M 38,233 h '.$width);
|
||||
$path->setAttribute('stroke', '#2F4F77');
|
||||
$path->setAttribute('stroke-width', '2px');
|
||||
$path->setAttribute('pointer-events', 'none');
|
||||
$this->xml_elements['final_path'] = $path;
|
||||
}
|
||||
|
||||
function has_errors()
|
||||
{
|
||||
return $this->has_errors;
|
||||
}
|
||||
|
||||
function getXMLOutput()
|
||||
{
|
||||
if (isset($this->xml_object))
|
||||
{
|
||||
// Add SVG elements to the DOM object
|
||||
foreach($this->xml_elements as $element)
|
||||
$this->svg->appendChild($element);
|
||||
|
||||
// Return the XML
|
||||
$this->xml_object->formatOutput = true;
|
||||
return $this->xml_object->saveXML();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
122
jappixmini/jappix/php/file-share.php
Normal file
122
jappixmini/jappix/php/file-share.php
Normal file
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix microblog file attaching script
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 14/01/12
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed for a special node
|
||||
if(isStatic() || isUpload())
|
||||
exit;
|
||||
|
||||
// Set a special XML header
|
||||
header('Content-Type: text/xml; charset=utf-8');
|
||||
|
||||
// Everything is okay
|
||||
if((isset($_FILES['file']) && !empty($_FILES['file'])) && (isset($_POST['user']) && !empty($_POST['user'])) && (isset($_POST['location']) && !empty($_POST['location']))) {
|
||||
// Get the user name
|
||||
$user = $_POST['user'];
|
||||
|
||||
// Get the file name
|
||||
$tmp_filename = $_FILES['file']['tmp_name'];
|
||||
$filename = $_FILES['file']['name'];
|
||||
|
||||
// Get the location
|
||||
if(HOST_UPLOAD)
|
||||
$location = HOST_UPLOAD;
|
||||
else
|
||||
$location = $_POST['location'];
|
||||
|
||||
// Get the file new name
|
||||
$ext = getFileExt($filename);
|
||||
$new_name = preg_replace('/(^)(.+)(\.)(.+)($)/i', '$2', $filename);
|
||||
|
||||
// Define some vars
|
||||
$content_dir = JAPPIX_BASE.'/store/share/'.$user;
|
||||
$security_file = $content_dir.'/index.html';
|
||||
$name = sha1(time().$filename);
|
||||
$path = $content_dir.'/'.$name.'.'.$ext;
|
||||
$thumb_xml = '';
|
||||
|
||||
// Forbidden file?
|
||||
if(!isSafe($filename) || !isSafe($name.'.'.$ext)) {
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\'>
|
||||
<error>forbidden-type</error>
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
|
||||
// Create the user directory
|
||||
if(!is_dir($content_dir)) {
|
||||
mkdir($content_dir, 0777, true);
|
||||
chmod($content_dir, 0777);
|
||||
}
|
||||
|
||||
// Create (or re-create) the security file
|
||||
if(!file_exists($security_file))
|
||||
file_put_contents($security_file, securityHTML());
|
||||
|
||||
// File upload error?
|
||||
if(!is_uploaded_file($tmp_filename) || !move_uploaded_file($tmp_filename, $path)) {
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\'>
|
||||
<error>move-error</error>
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
|
||||
// Resize and compress if this is a JPEG file
|
||||
if(preg_match('/^(jpg|jpeg|png|gif)$/i', $ext)) {
|
||||
// Resize the image
|
||||
resizeImage($path, $ext, 1024, 1024);
|
||||
|
||||
// Copy the image
|
||||
$thumb = $content_dir.'/'.$name.'_thumb.'.$ext;
|
||||
copy($path, $thumb);
|
||||
|
||||
// Create the thumbnail
|
||||
if(resizeImage($thumb, $ext, 140, 105))
|
||||
$thumb_xml = '<thumb>'.htmlspecialchars($location.'store/share/'.$user.'/'.$name.'_thumb.'.$ext).'</thumb>';
|
||||
}
|
||||
|
||||
// Return the path to the file
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\'>
|
||||
<href>'.htmlspecialchars($location.'store/share/'.$user.'/'.$name.'.'.$ext).'</href>
|
||||
<title>'.htmlspecialchars($new_name).'</title>
|
||||
<type>'.htmlspecialchars(getFileMIME($path)).'</type>
|
||||
<length>'.htmlspecialchars(filesize($path)).'</length>
|
||||
'.$thumb_xml.'
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
|
||||
// Bad request error!
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:post\'>
|
||||
<error>bad-request</error>
|
||||
</jappix>'
|
||||
);
|
||||
|
||||
?>
|
49
jappixmini/jappix/php/form-hosts.php
Normal file
49
jappixmini/jappix/php/form-hosts.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the hosts configuration form (install & manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 11/06/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
?>
|
||||
<a class="info smallspace neutral" href="http://codingteam.net/project/jappix/doc/JappixApp#title-3" target="_blank"><?php _e("Need help? You'd better read our documentation page about how to fill this form!"); ?></a>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("General"); ?></legend>
|
||||
|
||||
<label for="host_main"><?php _e("Main host"); ?></label><input id="host_main" type="text" name="host_main" value="<?php echo $host_main; ?>" pattern="[^@/]+" />
|
||||
|
||||
<label for="host_muc"><?php _e("Groupchat host"); ?></label><input id="host_muc" type="text" name="host_muc" value="<?php echo $host_muc; ?>" pattern="[^@/]+" />
|
||||
|
||||
<label for="host_pubsub"><?php _e("Pubsub host"); ?></label><input id="host_pubsub" type="text" name="host_pubsub" value="<?php echo $host_pubsub; ?>" pattern="[^@/]+" />
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Advanced"); ?></legend>
|
||||
|
||||
<label for="host_anonymous"><?php _e("Anonymous host"); ?></label><input id="host_anonymous" type="text" name="host_anonymous" value="<?php echo $host_anonymous; ?>" pattern="[^@/]+" />
|
||||
|
||||
<label for="host_vjud"><?php _e("Directory host"); ?></label><input id="host_vjud" type="text" name="host_vjud" value="<?php echo $host_vjud; ?>" pattern="[^@/]+" />
|
||||
|
||||
<label for="host_bosh"><?php _e("BOSH host"); ?></label><input id="host_bosh" type="text" name="host_bosh" value="<?php echo $host_bosh; ?>" />
|
||||
|
||||
<input type="hidden" name="host_bosh_main" value="<?php echo $host_bosh_main; ?>" />
|
||||
|
||||
<input type="hidden" name="host_bosh_mini" value="<?php echo $host_bosh_mini; ?>" />
|
||||
|
||||
<input type="hidden" name="host_static" value="<?php echo $host_static; ?>" />
|
||||
|
||||
<input type="hidden" name="host_upload" value="<?php echo $host_upload; ?>" />
|
||||
</fieldset>
|
125
jappixmini/jappix/php/form-main.php
Normal file
125
jappixmini/jappix/php/form-main.php
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the main configuration form (install & manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Authors: Vanaryon, LinkMauve
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Checks the checkboxes which are set "on"
|
||||
$checked = ' checked=""';
|
||||
|
||||
// Host locking
|
||||
if($lock_host == 'on')
|
||||
$check_lock_host = $checked;
|
||||
else
|
||||
$check_lock_host = '';
|
||||
|
||||
// Anonymous mode
|
||||
if($anonymous_mode == 'on')
|
||||
$check_anonymous_mode = $checked;
|
||||
else
|
||||
$check_anonymous_mode = '';
|
||||
|
||||
// Registration
|
||||
if($registration == 'on')
|
||||
$check_registration = $checked;
|
||||
else
|
||||
$check_registration = '';
|
||||
|
||||
// BOSH proxy
|
||||
if($bosh_proxy == 'on')
|
||||
$check_bosh_proxy = $checked;
|
||||
else
|
||||
$check_bosh_proxy = '';
|
||||
|
||||
// Manager link
|
||||
if($manager_link == 'on')
|
||||
$check_manager_link = $checked;
|
||||
else
|
||||
$check_manager_link = '';
|
||||
|
||||
// Encryption
|
||||
if($encryption == 'on')
|
||||
$check_encryption = $checked;
|
||||
else
|
||||
$check_encryption = '';
|
||||
|
||||
// HTTPS storage
|
||||
if($https_storage == 'on')
|
||||
$check_https_storage = $checked;
|
||||
else
|
||||
$check_https_storage = '';
|
||||
|
||||
// Force HTTPS
|
||||
if($https_force == 'on')
|
||||
$check_https_force = $checked;
|
||||
else
|
||||
$check_https_force = '';
|
||||
|
||||
// Compression
|
||||
if($compression == 'on')
|
||||
$check_compression = $checked;
|
||||
else
|
||||
$check_compression = '';
|
||||
|
||||
?>
|
||||
|
||||
<a class="info smallspace neutral" href="http://codingteam.net/project/jappix/doc/JappixApp#title-2" target="_blank"><?php _e("Need help? You'd better read our documentation page about how to fill this form!"); ?></a>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Service"); ?></legend>
|
||||
|
||||
<label for="service_name"><?php _e("Service name"); ?></label><input id="service_name" type="text" name="service_name" value="<?php echo $service_name; ?>" maxlength="14" />
|
||||
|
||||
<label for="service_desc"><?php _e("Service description"); ?></label><input id="service_desc" type="text" name="service_desc" value="<?php echo $service_desc; ?>" maxlength="30" />
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Connection"); ?></legend>
|
||||
|
||||
<label for="jappix_resource"><?php _e("Resource"); ?></label><input id="jappix_resource" type="text" name="jappix_resource" value="<?php echo $jappix_resource; ?>" maxlength="1023" />
|
||||
|
||||
<label for="lock_host"><?php _e("Lock the host"); ?></label><input id="lock_host" type="checkbox" name="lock_host"<?php echo $check_lock_host; ?> />
|
||||
|
||||
<label for="anonymous_mode"><?php _e("Anonymous mode"); ?></label><input id="anonymous_mode" type="checkbox" name="anonymous_mode"<?php echo $check_anonymous_mode; ?> />
|
||||
|
||||
<label for="registration"><?php _e("Registration allowed"); ?></label><input id="registration" type="checkbox" name="registration"<?php echo $check_registration; ?> />
|
||||
|
||||
<label for="bosh_proxy"><?php _e("Use a proxy"); ?></label><input id="bosh_proxy" type="checkbox" name="bosh_proxy"<?php echo $check_bosh_proxy; ?> />
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Others"); ?></legend>
|
||||
|
||||
<label for="manager_link"><?php _e("Manager link"); ?></label><input id="manager_link" type="checkbox" name="manager_link"<?php echo $check_manager_link; ?> />
|
||||
|
||||
<label for="groupchats_join"><?php _e("Groupchats to join"); ?></label><input id="groupchats_join" type="text" name="groupchats_join" value="<?php echo $groupchats_join; ?>" placeholder="postpro@muc.jappix.com, mini@muc.jappix.com" />
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Advanced"); ?></legend>
|
||||
|
||||
<label for="encryption"><?php _e("Encryption"); ?></label><input id="encryption" type="checkbox" name="encryption"<?php echo $check_encryption; ?> />
|
||||
|
||||
<label for="https_storage"><?php _e("HTTPS storage"); ?></label><input id="https_storage" type="checkbox" name="https_storage"<?php echo $check_https_storage; ?> />
|
||||
|
||||
<label for="https_force"><?php _e("Force HTTPS"); ?></label><input id="https_force" type="checkbox" name="https_force"<?php echo $check_https_force; ?> />
|
||||
|
||||
<label for="compression"><?php _e("Compression"); ?></label><input id="compression" type="checkbox" name="compression"<?php echo $check_compression; ?> />
|
||||
|
||||
<input type="hidden" name="multi_files" value="<?php echo $multi_files; ?>" />
|
||||
|
||||
<input type="hidden" name="developer" value="<?php echo $developer; ?>" />
|
||||
</fieldset>
|
30
jappixmini/jappix/php/form-users.php
Normal file
30
jappixmini/jappix/php/form-users.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the user add form (install & manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 08/05/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("New"); ?></legend>
|
||||
|
||||
<label for="user_name"><?php _e("User"); ?></label><input id="user_name" class="icon <?php echo($form_parent); ?>-images" type="text" name="user_name" value="<?php echo(htmlspecialchars($user_name)); ?>" maxlength="30" />
|
||||
|
||||
<label for="user_password"><?php _e("Password"); ?></label><input id="user_password" class="icon <?php echo($form_parent); ?>-images" type="password" name="user_password" maxlength="40" />
|
||||
|
||||
<label for="user_repassword"><?php _e("Confirm"); ?></label><input id="user_repassword" class="icon <?php echo($form_parent); ?>-images" type="password" name="user_repassword" maxlength="40" />
|
||||
</fieldset>
|
280
jappixmini/jappix/php/functions-get.php
Normal file
280
jappixmini/jappix/php/functions-get.php
Normal file
|
@ -0,0 +1,280 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
These are the PHP functions for Jappix Get API
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Authors: Vanaryon, Mathieui, olivierm
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// The function to get the cached content
|
||||
function readCache($hash) {
|
||||
return file_get_contents(JAPPIX_BASE.'/store/cache/'.$hash.'.cache');
|
||||
}
|
||||
|
||||
// The function to generate a cached file
|
||||
function genCache($string, $mode, $cache) {
|
||||
if(!$mode) {
|
||||
$cache_dir = JAPPIX_BASE.'/store/cache';
|
||||
$file_put = $cache_dir.'/'.$cache.'.cache';
|
||||
|
||||
// Cache not yet wrote
|
||||
if(is_dir($cache_dir) && !file_exists($file_put))
|
||||
file_put_contents($file_put, $string);
|
||||
}
|
||||
}
|
||||
|
||||
// The function to remove the BOM from a string
|
||||
function rmBOM($string) {
|
||||
if(substr($string, 0, 3) == pack('CCC', 0xef, 0xbb, 0xbf))
|
||||
$string = substr($string, 3);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
// The function to compress the CSS
|
||||
function compressCSS($buffer) {
|
||||
// We remove the comments
|
||||
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
|
||||
|
||||
// We remove the useless spaces
|
||||
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
|
||||
|
||||
// We remove the last useless spaces
|
||||
$buffer = str_replace(array(' { ',' {','{ '), '{', $buffer);
|
||||
$buffer = str_replace(array(' } ',' }','} '), '}', $buffer);
|
||||
$buffer = str_replace(array(' : ',' :',': '), ':', $buffer);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
// The function to replace classical path to get.php paths
|
||||
function setPath($string, $hash, $host, $type, $locale) {
|
||||
// Initialize the static server path
|
||||
$static = '.';
|
||||
|
||||
// Replace the JS strings
|
||||
if($type == 'js') {
|
||||
// Static host defined
|
||||
if($host && ($host != '.'))
|
||||
$static = $host;
|
||||
|
||||
// Links to JS (must have a lang parameter)
|
||||
$string = preg_replace('/((\")|(\'))(\.\/)(js)(\/)(\S+)(js)((\")|(\'))/', '$1'.$static.'/php/get.php?h='.$hash.'&l='.$locale.'&t=$5&f=$7$8$9', $string);
|
||||
|
||||
// Other "normal" links (no lang parameter)
|
||||
$string = preg_replace('/((\")|(\'))(\.\/)(css|img|store|snd)(\/)(\S+)(css|png|jpg|jpeg|gif|bmp|ogg|oga)((\")|(\'))/', '$1'.$static.'/php/get.php?h='.$hash.'&t=$5&f=$7$8$9', $string);
|
||||
}
|
||||
|
||||
// Replace the CSS strings
|
||||
else if($type == 'css') {
|
||||
// Static host defined
|
||||
if($host && ($host != '.'))
|
||||
$static = $host.'/php';
|
||||
|
||||
$string = preg_replace('/(\(\.\.\/)(css|js|img|store|snd)(\/)(\S+)(css|js|png|jpg|jpeg|gif|bmp|ogg|oga)(\))/', '('.$static.'/get.php?h='.$hash.'&t=$2&f=$4$5)', $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
// The function to set the good translation to a JS file
|
||||
function setTranslation($string) {
|
||||
return preg_replace('/_e\("([^\"\"]+)"\)/e', "'_e(\"'.addslashes(T_gettext(stripslashes('$1'))).'\")'", $string);
|
||||
}
|
||||
|
||||
// The function to set the good locales
|
||||
function setLocales($string, $locale) {
|
||||
// Generate the two JS array list
|
||||
$available_list = availableLocales($locale);
|
||||
$available_id = '';
|
||||
$available_names = '';
|
||||
|
||||
// Add the values to the arrays
|
||||
foreach($available_list as $current_id => $current_name) {
|
||||
$available_id .= '\''.$current_id.'\', ';
|
||||
$available_names .= '\''.addslashes($current_name).'\', ';
|
||||
}
|
||||
|
||||
// Remove the last comma
|
||||
$regex = '/(.+), $/';
|
||||
$available_id = preg_replace($regex, '$1', $available_id);
|
||||
$available_names = preg_replace($regex, '$1', $available_names);
|
||||
|
||||
// Locales array
|
||||
$array = array(
|
||||
'LOCALES_AVAILABLE_ID' => $available_id,
|
||||
'LOCALES_AVAILABLE_NAMES' => $available_names
|
||||
);
|
||||
|
||||
// Apply it!
|
||||
foreach($array as $array_key => $array_value)
|
||||
$string = preg_replace('/(var '.$array_key.'(( )?=( )?)new Array\()(\);)/', '$1'.$array_value.'$5', $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
// The function to set the good configuration to a JS file
|
||||
function setConfiguration($string, $locale, $version, $max_upload) {
|
||||
// Special BOSH URL if BOSH proxy enabled
|
||||
if(BOSHProxy())
|
||||
$bosh_special = staticLocation().'php/bosh.php';
|
||||
else
|
||||
$bosh_special = HOST_BOSH;
|
||||
|
||||
// Configuration array
|
||||
$array = array(
|
||||
// xml:lang
|
||||
'XML_LANG' => $locale,
|
||||
|
||||
// Jappix parameters
|
||||
'JAPPIX_STATIC' => staticLocation(),
|
||||
'JAPPIX_VERSION' => $version,
|
||||
'JAPPIX_MAX_FILE_SIZE' => $max_upload,
|
||||
'JAPPIX_MAX_UPLOAD' => formatBytes($max_upload),
|
||||
|
||||
// Main configuration
|
||||
'SERVICE_NAME' => SERVICE_NAME,
|
||||
'SERVICE_DESC' => SERVICE_DESC,
|
||||
'JAPPIX_RESOURCE' => JAPPIX_RESOURCE,
|
||||
'LOCK_HOST' => LOCK_HOST,
|
||||
'ANONYMOUS' => ANONYMOUS,
|
||||
'REGISTRATION' => REGISTRATION,
|
||||
'BOSH_PROXY' => BOSH_PROXY,
|
||||
'MANAGER_LINK' => MANAGER_LINK,
|
||||
'GROUPCHATS_JOIN' => GROUPCHATS_JOIN,
|
||||
'ENCRYPTION' => ENCRYPTION,
|
||||
'HTTPS_STORAGE' => HTTPS_STORAGE,
|
||||
'HTTPS_FORCE' => HTTPS_FORCE,
|
||||
'COMPRESSION' => COMPRESSION,
|
||||
'MULTI_FILES' => MULTI_FILES,
|
||||
'DEVELOPER' => DEVELOPER,
|
||||
|
||||
// Hosts configuration
|
||||
'HOST_MAIN' => HOST_MAIN,
|
||||
'HOST_MUC' => HOST_MUC,
|
||||
'HOST_PUBSUB' => HOST_PUBSUB,
|
||||
'HOST_VJUD' => HOST_VJUD,
|
||||
'HOST_ANONYMOUS' => HOST_ANONYMOUS,
|
||||
'HOST_BOSH' => $bosh_special,
|
||||
'HOST_BOSH_MAIN' => HOST_BOSH_MAIN,
|
||||
'HOST_BOSH_MINI' => HOST_BOSH_MINI,
|
||||
'HOST_STATIC' => HOST_STATIC,
|
||||
'HOST_UPLOAD' => HOST_UPLOAD
|
||||
);
|
||||
|
||||
// Apply it!
|
||||
foreach($array as $array_key => $array_value)
|
||||
$string = preg_replace('/var '.$array_key.'(( )?=( )?)null;/', 'var '.$array_key.'$1\''.addslashes($array_value).'\';', $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
// The function to set the logos
|
||||
function setLogos($string, $files) {
|
||||
// Jappix Desktop home logo?
|
||||
if(in_array('home.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/desktop_home.png')) {
|
||||
$string .=
|
||||
'#home .left .logo {
|
||||
background-image: url(../store/logos/desktop_home.png) !important;
|
||||
background-position: center center !important;
|
||||
}';
|
||||
}
|
||||
|
||||
// Jappix Desktop app logo?
|
||||
if(in_array('tools.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/desktop_app.png')) {
|
||||
$string .=
|
||||
'#top-content .tools-logo {
|
||||
background-image: url(../store/logos/desktop_app.png) !important;
|
||||
background-position: center center !important;
|
||||
}';
|
||||
}
|
||||
|
||||
// Jappix Mobile logo?
|
||||
if(in_array('mobile.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/mobile.png')) {
|
||||
$string .=
|
||||
'.header div {
|
||||
background-image: url(../store/logos/mobile.png) !important;
|
||||
background-position: center center !important;
|
||||
}';
|
||||
}
|
||||
|
||||
// Jappix Mini logo?
|
||||
if(in_array('mini.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/mini.png')) {
|
||||
$string .=
|
||||
'#jappix_mini div.jm_actions a.jm_logo {
|
||||
background-image: url(../store/logos/mini.png) !important;
|
||||
background-position: center center !important;
|
||||
}';
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
// The function to set the background
|
||||
function setBackground($string) {
|
||||
// Get the default values
|
||||
$array = defaultBackground();
|
||||
|
||||
// Read the background configuration
|
||||
$xml = readXML('conf', 'background');
|
||||
|
||||
if($xml) {
|
||||
$read = new SimpleXMLElement($xml);
|
||||
|
||||
foreach($read->children() as $child) {
|
||||
// Any value?
|
||||
if($child)
|
||||
$array[$child->getName()] = $child;
|
||||
}
|
||||
}
|
||||
|
||||
$css = '';
|
||||
|
||||
// Generate the CSS code
|
||||
switch($array['type']) {
|
||||
// Image
|
||||
case 'image':
|
||||
$css .=
|
||||
"\n".' background-image: url(../store/backgrounds/'.urlencode($array['image_file']).');
|
||||
background-repeat: '.$array['image_repeat'].';
|
||||
background-position: '.$array['image_horizontal'].' '.$array['image_vertical'].';
|
||||
background-color: '.$array['image_color'].';'
|
||||
;
|
||||
|
||||
// Add CSS code to adapt the image?
|
||||
if($array['image_adapt'] == 'on')
|
||||
$css .=
|
||||
' background-attachment: fixed;
|
||||
background-size: cover;
|
||||
-moz-background-size: cover;
|
||||
-webkit-background-size: cover;';
|
||||
|
||||
$css .= "\n";
|
||||
|
||||
break;
|
||||
|
||||
// Color
|
||||
case 'color':
|
||||
$css .= "\n".' background-color: '.$array['color_color'].';'."\n";
|
||||
|
||||
break;
|
||||
|
||||
// Default: use the filtering regex
|
||||
default:
|
||||
$css .= '$3';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Apply the replacement!
|
||||
return preg_replace('/(\.body-images( )?\{)([^\{\}]+)(\})/i', '$1'.$css.'$4', $string);
|
||||
}
|
||||
|
||||
?>
|
769
jappixmini/jappix/php/functions-manager.php
Normal file
769
jappixmini/jappix/php/functions-manager.php
Normal file
|
@ -0,0 +1,769 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
These are the PHP functions for Jappix manager
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Authors: Vanaryon, Mathieui, olivierm, Vinilox
|
||||
Last revision: 15/01/12
|
||||
|
||||
*/
|
||||
|
||||
// The function to check an user is admin
|
||||
function isAdmin($user, $password) {
|
||||
// Read the users.xml file
|
||||
$array = getUsers();
|
||||
|
||||
// No data?
|
||||
if(empty($array))
|
||||
return false;
|
||||
|
||||
// Our user is set and valid?
|
||||
if(isset($array[$user]) && ($array[$user] == $password))
|
||||
return true;
|
||||
|
||||
// Not authorized
|
||||
return false;
|
||||
}
|
||||
|
||||
// Checks if a file is a valid image
|
||||
function isImage($file) {
|
||||
// This is an image
|
||||
if(preg_match('/^(.+)(\.)(png|jpg|jpeg|gif|bmp)$/i', $file))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Puts a marker on the current opened manager tab
|
||||
function currentTab($current, $page) {
|
||||
if($current == $page)
|
||||
echo ' class="tab-active"';
|
||||
}
|
||||
|
||||
// Checks all the storage folders are writable
|
||||
function storageWritable() {
|
||||
// Read the directory content
|
||||
$dir = JAPPIX_BASE.'/store/';
|
||||
$scan = scandir($dir);
|
||||
|
||||
// Writable marker
|
||||
$writable = true;
|
||||
|
||||
// Check that each folder is writable
|
||||
foreach($scan as $current) {
|
||||
// Current folder
|
||||
$folder = $dir.$current;
|
||||
|
||||
// A folder is not writable?
|
||||
if(!preg_match('/^\.(.+)/', $current) && !is_writable($folder)) {
|
||||
// Try to change the folder rights
|
||||
chmod($folder, 0777);
|
||||
|
||||
// Check it again!
|
||||
if(!is_writable($folder))
|
||||
$writable = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $writable;
|
||||
}
|
||||
|
||||
// Removes a given directory (with all sub-elements)
|
||||
function removeDir($dir) {
|
||||
// Can't open the dir
|
||||
if(!$dh = @opendir($dir))
|
||||
return;
|
||||
|
||||
// Loop the current dir to remove its content
|
||||
while(false !== ($obj = readdir($dh))) {
|
||||
// Not a "real" directory
|
||||
if(($obj == '.') || ($obj == '..'))
|
||||
continue;
|
||||
|
||||
// Not a file, remove this dir
|
||||
if(!@unlink($dir.'/'.$obj))
|
||||
removeDir($dir.'/'.$obj);
|
||||
}
|
||||
|
||||
// Close the dir and remove it!
|
||||
closedir($dh);
|
||||
@rmdir($dir);
|
||||
}
|
||||
|
||||
// Copies a given directory (with all sub-elements)
|
||||
function copyDir($source, $destination) {
|
||||
// This is a directory
|
||||
if(is_dir($source)) {
|
||||
// Create the target directory
|
||||
@mkdir($destination);
|
||||
$directory = dir($source);
|
||||
|
||||
// Append the source directory content into the target one
|
||||
while(FALSE !== ($readdirectory = $directory->read())) {
|
||||
if(($readdirectory == '.') || ($readdirectory == '..'))
|
||||
continue;
|
||||
|
||||
$PathDir = $source.'/'.$readdirectory;
|
||||
|
||||
// Recursive copy
|
||||
if(is_dir($PathDir)) {
|
||||
copyDir($PathDir, $destination.'/'.$readdirectory);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
copy($PathDir, $destination.'/'.$readdirectory);
|
||||
}
|
||||
|
||||
// Close the source directory
|
||||
$directory->close();
|
||||
}
|
||||
|
||||
// This is a file
|
||||
else
|
||||
copy($source, $destination);
|
||||
}
|
||||
|
||||
// Gets the total size of a directory
|
||||
function sizeDir($dir) {
|
||||
$size = 0;
|
||||
|
||||
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $file)
|
||||
$size += $file->getSize();
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
// Set the good unity for a size in bytes
|
||||
function numericToMonth($id) {
|
||||
$array = array(
|
||||
1 => T_("January"),
|
||||
2 => T_("February"),
|
||||
3 => T_("March"),
|
||||
4 => T_("April"),
|
||||
5 => T_("May"),
|
||||
6 => T_("June"),
|
||||
7 => T_("July"),
|
||||
8 => T_("August"),
|
||||
9 => T_("September"),
|
||||
10 => T_("October"),
|
||||
11 => T_("November"),
|
||||
12 =>T_( "December")
|
||||
);
|
||||
|
||||
return $array[$id];
|
||||
}
|
||||
|
||||
// Extracts the version number with a version ID
|
||||
function versionNumber($id) {
|
||||
// First, extract the number string from the [X]
|
||||
$extract = preg_replace('/^(.+)\[(\S+)\]$/', '$2', $id);
|
||||
$dev = false;
|
||||
|
||||
// Second extract: ~ (when this is a special version, like ~dev)
|
||||
if(strrpos($extract, '~') !== false) {
|
||||
$dev = true;
|
||||
$extract = preg_replace('/^([^~])~(.+)$/', '$1', $extract);
|
||||
}
|
||||
|
||||
// Convert [X.X.X] into a full number
|
||||
$extract = preg_replace('/[^0-9]/', '', $extract);
|
||||
|
||||
// Add missing items to [X.X.X]
|
||||
$missing = 3 - strlen($extract.'');
|
||||
if($missing > 0)
|
||||
$extract = $extract.(str_repeat('0', $missing));
|
||||
|
||||
// Allows updates for dev versions
|
||||
if($dev)
|
||||
$extract = $extract - 1;
|
||||
|
||||
return intval($extract);
|
||||
}
|
||||
|
||||
// Checks for new Jappix updates
|
||||
function newUpdates($force) {
|
||||
// No need to check if developer mode
|
||||
if(isDeveloper())
|
||||
return false;
|
||||
|
||||
$cache_path = JAPPIX_BASE.'/store/updates/version.xml';
|
||||
|
||||
// No cache, obsolete one or refresh forced
|
||||
if(!file_exists($cache_path) || (file_exists($cache_path) && (time() - (filemtime($cache_path)) >= 86400)) || $force) {
|
||||
// Get the content
|
||||
$last_version = read_url('http://codingteam.net/project/jappix/upload/briefcase/version.xml');
|
||||
|
||||
// Write the content
|
||||
file_put_contents($cache_path, $last_version);
|
||||
}
|
||||
|
||||
// Read from the cache
|
||||
else
|
||||
$last_version = file_get_contents($cache_path);
|
||||
|
||||
// Parse the XML
|
||||
$xml = @simplexml_load_string($last_version);
|
||||
|
||||
// No data?
|
||||
if($xml === FALSE)
|
||||
return false;
|
||||
|
||||
// Get the version numbers
|
||||
$current_version = getVersion();
|
||||
$last_version = $xml->id;
|
||||
|
||||
// Check if we have the latest version
|
||||
$current_version = versionNumber($current_version);
|
||||
$last_version = versionNumber($last_version);
|
||||
|
||||
if($current_version < $last_version)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gets the Jappix update informations
|
||||
function updateInformations() {
|
||||
// Get the XML file content
|
||||
$data = file_get_contents(JAPPIX_BASE.'/store/updates/version.xml');
|
||||
|
||||
// Transform the XML content into an array
|
||||
$array = array();
|
||||
|
||||
// No XML?
|
||||
if(!$data)
|
||||
return $array;
|
||||
|
||||
$xml = new SimpleXMLElement($data);
|
||||
|
||||
// Parse the XML to add it to the array
|
||||
foreach($xml->children() as $this_child) {
|
||||
// Get the node name
|
||||
$current_name = $this_child->getName();
|
||||
|
||||
// Push it to the array, with a basic HTML encoding
|
||||
$array[$current_name] = str_replace('\n', '<br />', $this_child);
|
||||
}
|
||||
|
||||
// Return this array
|
||||
return $array;
|
||||
}
|
||||
|
||||
// Processes the Jappix update from an external package
|
||||
function processUpdate($url) {
|
||||
// Archive path
|
||||
$name = md5($url).'.zip';
|
||||
$update_dir = $dir_base.'store/updates/';
|
||||
$path = JAPPIX_BASE.'/store/updates/'.$name;
|
||||
$extract_to = $update_dir.'jappix/';
|
||||
$store_tree = JAPPIX_BASE.'/php/store-tree.php';
|
||||
|
||||
// We must get the archive from the server
|
||||
if(!file_exists($path)) {
|
||||
echo('<p>» '.T_("Downloading package...").'</p>');
|
||||
|
||||
// Open the packages
|
||||
$local = fopen($path, 'w');
|
||||
$remote = fopen($url, 'r');
|
||||
|
||||
// Could not open a socket?!
|
||||
if(!$remote) {
|
||||
echo('<p>» '.T_("Aborted: socket error!").'</p>');
|
||||
|
||||
// Remove the broken local archive
|
||||
unlink($path);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the file
|
||||
while(!feof($remote)) {
|
||||
// Get the buffer
|
||||
$buffer = fread($remote, 1024);
|
||||
|
||||
// Any error?
|
||||
if($buffer == 'Error.') {
|
||||
echo('<p>» '.T_("Aborted: buffer error!").'</p>');
|
||||
|
||||
// Remove the broken local archive
|
||||
unlink($path);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write the buffer to the file
|
||||
fwrite($local, $buffer);
|
||||
|
||||
// Flush the current buffer
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
|
||||
// Close the files
|
||||
fclose($local);
|
||||
fclose($remote);
|
||||
}
|
||||
|
||||
// Then, we extract the archive
|
||||
echo('<p>» '.T_("Extracting package...").'</p>');
|
||||
|
||||
try {
|
||||
$zip = new ZipArchive;
|
||||
$zip_open = $zip->open($path);
|
||||
|
||||
if($zip_open === TRUE) {
|
||||
$zip->extractTo($update_dir);
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
else {
|
||||
echo('<p>» '.T_("Aborted: could not extract the package!").'</p>');
|
||||
|
||||
// Remove the broken source folder
|
||||
removeDir($to_remove);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// PHP does not provide Zip archives support
|
||||
catch(Exception $e) {
|
||||
echo('<p>» '.T_("Aborted: could not extract the package!").'</p>');
|
||||
|
||||
// Remove the broken source folder
|
||||
removeDir($to_remove);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove the ./store dir from the source directory
|
||||
removeDir($extract_to.'store/');
|
||||
|
||||
// Then, we remove the Jappix system files
|
||||
echo('<p>» '.T_("Removing current Jappix system files...").'</p>');
|
||||
|
||||
// Open the general directory
|
||||
$dir_base = JAPPIX_BASE.'/';
|
||||
$scan = scandir($dir_base);
|
||||
|
||||
// Filter the scan array
|
||||
$scan = array_diff($scan, array('.', '..', '.svn', 'store'));
|
||||
|
||||
// Check all the files are writable
|
||||
foreach($scan as $scanned) {
|
||||
// Element path
|
||||
$scanned_current = $dir_base.$scanned;
|
||||
|
||||
// Element not writable
|
||||
if(!is_writable($scanned_current)) {
|
||||
// Try to change the element rights
|
||||
chmod($scanned_current, 0777);
|
||||
|
||||
// Check it again!
|
||||
if(!is_writable($scanned_current)) {
|
||||
echo('<p>» '.T_("Aborted: everything is not writable!").'</p>');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process the files deletion
|
||||
foreach($scan as $current) {
|
||||
$to_remove = $dir_base.$current;
|
||||
|
||||
// Remove folders
|
||||
if(is_dir($to_remove))
|
||||
removeDir($to_remove);
|
||||
|
||||
// Remove files
|
||||
else
|
||||
unlink($to_remove);
|
||||
}
|
||||
|
||||
// Move the extracted files to the base
|
||||
copyDir($extract_to, $dir_base);
|
||||
|
||||
// Remove the source directory
|
||||
removeDir($extract_to);
|
||||
|
||||
// Regenerates the store tree
|
||||
if(file_exists($store_tree)) {
|
||||
echo('<p>» '.T_("Regenerating storage folder tree...").'</p>');
|
||||
|
||||
// Call the special regeneration script
|
||||
include($store_tree);
|
||||
}
|
||||
|
||||
// Remove the version package
|
||||
unlink($path);
|
||||
|
||||
// The new version is now installed!
|
||||
echo('<p>» '.T_("Jappix is now up to date!").'</p>');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns an array with the biggest share folders
|
||||
function shareStats() {
|
||||
// Define some stuffs
|
||||
$path = JAPPIX_BASE.'/store/share/';
|
||||
$array = array();
|
||||
|
||||
// Open the directory
|
||||
$scan = scandir($path);
|
||||
|
||||
// Loop the share files
|
||||
foreach($scan as $current) {
|
||||
if(is_dir($path.$current) && !preg_match('/^(\.(.+)?)$/i', $current))
|
||||
array_push($array, $current);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
// Returns the largest share folders
|
||||
function largestShare($array, $number) {
|
||||
// Define some stuffs
|
||||
$path = JAPPIX_BASE.'/store/share/';
|
||||
$size_array = array();
|
||||
|
||||
// Push the results in an array
|
||||
foreach($array as $current)
|
||||
$size_array[$current] = sizeDir($path.$current);
|
||||
|
||||
// Sort this array
|
||||
arsort($size_array);
|
||||
|
||||
// Select the first biggest values
|
||||
$size_array = array_slice($size_array, 0, $number);
|
||||
|
||||
return $size_array;
|
||||
}
|
||||
|
||||
// Returns the others statistics array
|
||||
function otherStats() {
|
||||
// Fill the array with the values
|
||||
$others_stats = array(
|
||||
T_("Backgrounds") => sizeDir(JAPPIX_BASE.'/store/backgrounds/'),
|
||||
T_("Cache") => sizeDir(JAPPIX_BASE.'/store/cache/'),
|
||||
T_("Logs") => sizeDir(JAPPIX_BASE.'/store/logs/'),
|
||||
T_("Music") => sizeDir(JAPPIX_BASE.'/store/music/'),
|
||||
T_("Share") => sizeDir(JAPPIX_BASE.'/store/share/'),
|
||||
T_("Send") => sizeDir(JAPPIX_BASE.'/store/send/'),
|
||||
T_("Updates") => sizeDir(JAPPIX_BASE.'/store/updates/')
|
||||
);
|
||||
|
||||
// Sort this array
|
||||
arsort($others_stats);
|
||||
|
||||
return $others_stats;
|
||||
}
|
||||
|
||||
// Gets the array of the visits stats
|
||||
function getVisits() {
|
||||
// New array
|
||||
$array = array(
|
||||
'total' => 0,
|
||||
'daily' => 0,
|
||||
'weekly' => 0,
|
||||
'monthly' => 0,
|
||||
'yearly' => 0
|
||||
);
|
||||
|
||||
// Read the data
|
||||
$data = readXML('access', 'total');
|
||||
|
||||
// Any data?
|
||||
if($data) {
|
||||
// Initialize the visits reading
|
||||
$xml = new SimpleXMLElement($data);
|
||||
|
||||
// Get the XML values
|
||||
$array['total'] = intval($xml->total);
|
||||
$array['stamp'] = intval($xml->stamp);
|
||||
|
||||
// Get the age of the stats
|
||||
$age = time() - $array['stamp'];
|
||||
|
||||
// Generate the time-dependant values
|
||||
$timed = array(
|
||||
'daily' => 86400,
|
||||
'weekly' => 604800,
|
||||
'monthly' => 2678400,
|
||||
'yearly' => 31536000
|
||||
);
|
||||
|
||||
foreach($timed as $timed_key => $timed_value) {
|
||||
if($age >= $timed_value)
|
||||
$array[$timed_key] = intval($array['total'] / ($age / $timed[$timed_key])).'';
|
||||
else
|
||||
$array[$timed_key] = $array['total'].'';
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
// Gets the array of the monthly visits
|
||||
function getMonthlyVisits() {
|
||||
// New array
|
||||
$array = array();
|
||||
|
||||
// Read the data
|
||||
$data = readXML('access', 'months');
|
||||
|
||||
// Get the XML file values
|
||||
if($data) {
|
||||
// Initialize the visits reading
|
||||
$xml = new SimpleXMLElement($data);
|
||||
|
||||
// Loop the visit elements
|
||||
foreach($xml->children() as $child) {
|
||||
// Get the current month ID
|
||||
$current_id = intval(preg_replace('/month_([0-9]+)/i', '$1', $child->getName()));
|
||||
|
||||
// Get the current month name
|
||||
$current_name = numericToMonth($current_id);
|
||||
|
||||
// Push it!
|
||||
$array[$current_name] = intval($child);
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
// Purges the target folder content
|
||||
function purgeFolder($folder) {
|
||||
// Array of the folders to purge
|
||||
$array = array();
|
||||
|
||||
// We must purge all the folders?
|
||||
if($folder == 'everything')
|
||||
array_push($array, 'cache', 'logs', 'send', 'updates');
|
||||
else
|
||||
array_push($array, $folder);
|
||||
|
||||
// All right, now we can empty it!
|
||||
foreach($array as $current_folder) {
|
||||
// Scan the current directory
|
||||
$directory = JAPPIX_BASE.'/store/'.$current_folder.'/';
|
||||
$scan = scandir($directory);
|
||||
$scan = array_diff($scan, array('.', '..', '.svn', 'index.html'));
|
||||
|
||||
// Process the files deletion
|
||||
foreach($scan as $current) {
|
||||
$remove_this = $directory.$current;
|
||||
|
||||
// Remove folders
|
||||
if(is_dir($remove_this))
|
||||
removeDir($remove_this);
|
||||
|
||||
// Remove files
|
||||
else
|
||||
unlink($remove_this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns folder browsing informations
|
||||
function browseFolder($folder, $mode) {
|
||||
// Scan the target directory
|
||||
$directory = JAPPIX_BASE.'/store/'.$folder;
|
||||
$scan = scandir($directory);
|
||||
$scan = array_diff($scan, array('.', '..', '.svn', 'index.html'));
|
||||
$keep_get = keepGet('(s|b|k)', false);
|
||||
|
||||
// Odd/even marker
|
||||
$marker = 'odd';
|
||||
|
||||
// Not in the root folder: show previous link
|
||||
if(strpos($folder, '/') != false) {
|
||||
// Filter the folder name
|
||||
$previous_folder = substr($folder, 0, strrpos($folder, '/'));
|
||||
|
||||
echo('<div class="one-browse previous manager-images"><a href="./?b='.$mode.'&s='.urlencode($previous_folder).$keep_get.'">'.T_("Previous").'</a></div>');
|
||||
}
|
||||
|
||||
// Empty or non-existing directory?
|
||||
if(!count($scan) || !is_dir($directory)) {
|
||||
echo('<div class="one-browse '.$marker.' alert manager-images">'.T_("The folder is empty.").'</div>');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Echo the browsing HTML code
|
||||
foreach($scan as $current) {
|
||||
// Generate the item path$directory
|
||||
$path = $directory.'/'.$current;
|
||||
$file = $folder.'/'.$current;
|
||||
|
||||
// Directory?
|
||||
if(is_dir($path)) {
|
||||
$type = 'folder';
|
||||
$href = './?b='.$mode.'&s='.urlencode($file).$keep_get;
|
||||
$target = '';
|
||||
}
|
||||
|
||||
// File?
|
||||
else {
|
||||
$type = getFileType(getFileExt($path));
|
||||
$href = $path;
|
||||
$target = ' target="_blank"';
|
||||
}
|
||||
|
||||
echo('<div class="one-browse '.$marker.' '.$type.' manager-images"><a href="'.$href.'"'.$target.'>'.htmlspecialchars($current).'</a><input type="checkbox" name="element_'.md5($file).'" value="'.htmlspecialchars($file).'" /></div>');
|
||||
|
||||
// Change the marker
|
||||
if($marker == 'odd')
|
||||
$marker = 'even';
|
||||
else
|
||||
$marker = 'odd';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Removes selected elements (files/folders)
|
||||
function removeElements() {
|
||||
// Initialize the match
|
||||
$elements_removed = false;
|
||||
$elements_remove = array();
|
||||
|
||||
// Try to get the elements to remove
|
||||
foreach($_POST as $post_key => $post_value) {
|
||||
// Is a safe file?
|
||||
if(preg_match('/^element_(.+)$/i', $post_key) && isSafe($post_value)) {
|
||||
// Update the marker
|
||||
$elements_removed = true;
|
||||
|
||||
// Get the real path
|
||||
$post_element = JAPPIX_BASE.'/store/'.$post_value;
|
||||
|
||||
// Remove the current element
|
||||
if(is_dir($post_element))
|
||||
removeDir($post_element);
|
||||
else if(file_exists($post_element))
|
||||
unlink($post_element);
|
||||
}
|
||||
}
|
||||
|
||||
// Show a notification message
|
||||
if($elements_removed)
|
||||
echo('<p class="info smallspace success">'.T_("The selected elements have been removed.").'</p>');
|
||||
else
|
||||
echo('<p class="info smallspace fail">'.T_("You must select elements to remove!").'</p>');
|
||||
}
|
||||
|
||||
// Returns users browsing informations
|
||||
function browseUsers() {
|
||||
// Get the users
|
||||
$array = getUsers();
|
||||
|
||||
// Odd/even marker
|
||||
$marker = 'odd';
|
||||
|
||||
// Echo the browsing HTML code
|
||||
foreach($array as $user => $password) {
|
||||
// Filter the username
|
||||
$user = htmlspecialchars($user);
|
||||
|
||||
// Output the code
|
||||
echo('<div class="one-browse '.$marker.' user manager-images"><span>'.$user.'</span><input type="checkbox" name="admin_'.md5($user).'" value="'.$user.'" /><div class="clear"></div></div>');
|
||||
|
||||
// Change the marker
|
||||
if($marker == 'odd')
|
||||
$marker = 'even';
|
||||
else
|
||||
$marker = 'odd';
|
||||
}
|
||||
}
|
||||
|
||||
// Generates the logo form field
|
||||
function logoFormField($id, $name) {
|
||||
if(file_exists(JAPPIX_BASE.'/store/logos/'.$name.'.png'))
|
||||
echo '<span class="logo_links"><a class="remove manager-images" href="./?k='.urlencode($name).keepGet('k', false).'" title="'.T_("Remove this logo").'"></a><a class="view manager-images" href="./store/logos/'.$name.'.png" target="_blank" title="'.T_("View this logo").'"></a></span>';
|
||||
else
|
||||
echo '<input id="logo_own_'.$id.'_location" type="file" name="logo_own_'.$id.'_location" accept="image/*" />';
|
||||
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
// Reads the background configuration
|
||||
function readBackground() {
|
||||
// Read the background configuration XML
|
||||
$background_data = readXML('conf', 'background');
|
||||
|
||||
// Get the default values
|
||||
$background_default = defaultBackground();
|
||||
|
||||
// Stored data array
|
||||
$background_conf = array();
|
||||
|
||||
// Read the stored values
|
||||
if($background_data) {
|
||||
// Initialize the background configuration XML data
|
||||
$background_xml = new SimpleXMLElement($background_data);
|
||||
|
||||
// Loop the notice configuration elements
|
||||
foreach($background_xml->children() as $background_child)
|
||||
$background_conf[$background_child->getName()] = $background_child;
|
||||
}
|
||||
|
||||
// Checks no value is missing in the stored configuration
|
||||
foreach($background_default as $background_name => $background_value) {
|
||||
if(!isset($background_conf[$background_name]) || empty($background_conf[$background_name]))
|
||||
$background_conf[$background_name] = $background_default[$background_name];
|
||||
}
|
||||
|
||||
return $background_conf;
|
||||
}
|
||||
|
||||
// Writes the background configuration
|
||||
function writeBackground($array) {
|
||||
// Generate the XML data
|
||||
$xml = '';
|
||||
|
||||
foreach($array as $key => $value)
|
||||
$xml .= "\n".' <'.$key.'>'.stripslashes(htmlspecialchars($value)).'</'.$key.'>';
|
||||
|
||||
// Write this data
|
||||
writeXML('conf', 'background', $xml);
|
||||
}
|
||||
|
||||
// Generates a list of the available background images
|
||||
function getBackgrounds() {
|
||||
// Initialize the result array
|
||||
$array = array();
|
||||
|
||||
// Scan the background directory
|
||||
$scan = scandir(JAPPIX_BASE.'/store/backgrounds/');
|
||||
|
||||
foreach($scan as $current) {
|
||||
if(isImage($current))
|
||||
array_push($array, $current);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
// Writes the notice configuration
|
||||
function writeNotice($type, $simple) {
|
||||
// Generate the XML data
|
||||
$xml =
|
||||
'<type>'.$type.'</type>
|
||||
<notice>'.stripslashes(htmlspecialchars($simple)).'</notice>'
|
||||
;
|
||||
|
||||
// Write this data
|
||||
writeXML('conf', 'notice', $xml);
|
||||
}
|
||||
|
||||
?>
|
1427
jappixmini/jappix/php/functions.php
Normal file
1427
jappixmini/jappix/php/functions.php
Normal file
File diff suppressed because it is too large
Load diff
235
jappixmini/jappix/php/generate-chat.php
Normal file
235
jappixmini/jappix/php/generate-chat.php
Normal file
|
@ -0,0 +1,235 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the PHP script used to generate a chat log
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed for a special node
|
||||
if(isStatic() || isUpload())
|
||||
exit;
|
||||
|
||||
// Create the HTML file to be downloaded
|
||||
if(isset($_POST['content']) && isset($_POST['xid']) && !empty($_POST['xid']) && isset($_POST['nick']) && !empty($_POST['nick']) && isset($_POST['avatar']) && !empty($_POST['avatar']) && isset($_POST['date']) && !empty($_POST['date']) && isset($_POST['type']) && !empty($_POST['type'])) {
|
||||
// Get the POST vars
|
||||
$original = $_POST['content'];
|
||||
$xid = $_POST['xid'];
|
||||
$nick = $_POST['nick'];
|
||||
$avatar = $_POST['avatar'];
|
||||
$date = $_POST['date'];
|
||||
$type = $_POST['type'];
|
||||
|
||||
// Generate the XID link
|
||||
$xid_link = 'xmpp:'.$xid;
|
||||
|
||||
if($type == 'groupchat')
|
||||
$xid_link .= '?join';
|
||||
|
||||
// Generates the avatar code
|
||||
if($avatar != 'none')
|
||||
$avatar = '<div class="avatar-container">'.$avatar.'</div>';
|
||||
else
|
||||
$avatar = '';
|
||||
|
||||
// Generates an human-readable date
|
||||
$date = explode('T', $date);
|
||||
$date = explode('-', $date[0]);
|
||||
$date = $date[2].'/'.$date[1].'/'.$date[0];
|
||||
|
||||
// Generate some values
|
||||
$content_dir = '../store/logs/';
|
||||
$filename = 'chat_log-'.md5($xid.time());
|
||||
$filepath = $content_dir.$filename.'.html';
|
||||
|
||||
// Generate Jappix logo Base64 code
|
||||
$logo = base64_encode(file_get_contents(JAPPIX_BASE.'/img/sprites/logs.png'));
|
||||
|
||||
// Create the HTML code
|
||||
$new_text_inter =
|
||||
'<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>'.$nick.' ('.$xid.')</title>
|
||||
<style type="text/css">
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #424242;
|
||||
font-family : Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 0.8em;
|
||||
text-shadow: 0 0 5px white;
|
||||
color: white;
|
||||
margin: 8px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#head {
|
||||
|
||||
}
|
||||
|
||||
#head .avatar-container {
|
||||
text-align: center;
|
||||
float: left;
|
||||
height: 70px;
|
||||
width: 70px;
|
||||
margin-right: 18px;
|
||||
}
|
||||
|
||||
#head .avatar {
|
||||
max-height: 70px;
|
||||
max-width: 70px;
|
||||
}
|
||||
|
||||
#head h1 {
|
||||
font-size: 2.2em;
|
||||
margin: 0;
|
||||
text-shadow: 1px 1px 1px black;
|
||||
}
|
||||
|
||||
#head h3 {
|
||||
font-size: 0.95em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#head h5 {
|
||||
font-size: 0.9em;
|
||||
margin: 8px 0 16px 0;
|
||||
}
|
||||
|
||||
#head h3,
|
||||
#head h5 {
|
||||
text-shadow: 0 0 1px black;
|
||||
}
|
||||
|
||||
#head a.logo {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
#content {
|
||||
background-color: #e8f1f3;
|
||||
color: black;
|
||||
padding: 14px 18px;
|
||||
border-radius: 4px;
|
||||
clear: both;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
box-shadow: 0 0 20px #202020;
|
||||
-moz-box-shadow: 0 0 20px #202020;
|
||||
-webkit-box-shadow: 0 0 20px #202020;
|
||||
}
|
||||
|
||||
#content a {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#content .one-group {
|
||||
border-bottom: 1px dotted #d0d0d0;
|
||||
padding-bottom: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#content .one-group b.name {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
#content .one-group b.name.me {
|
||||
color: #123a5c;
|
||||
}
|
||||
|
||||
#content .one-group b.name.him {
|
||||
color: #801e1e;
|
||||
}
|
||||
|
||||
#content .one-group span.date {
|
||||
float: right;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#content .user-message {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
#content .system-message {
|
||||
color: #053805;
|
||||
margin-bottom: 3px;
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
|
||||
#content .system-message a {
|
||||
color: #053805;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="head">
|
||||
'.$avatar.'
|
||||
|
||||
<h1>'.$nick.'</h1>
|
||||
<h3><a href="'.$xid_link.'">'.$xid.'</a></h3>
|
||||
<h5>'.$date.'</h5>
|
||||
|
||||
<a class="logo" href="https://project.jappix.com/" target="_blank">
|
||||
<img src="data:image/png;base64,'.$logo.'" alt="" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
'.$original.'
|
||||
</div>
|
||||
</body>
|
||||
</html>'
|
||||
;
|
||||
|
||||
$new_text = stripslashes($new_text_inter);
|
||||
|
||||
// Write the code into a file
|
||||
file_put_contents($filepath, $new_text);
|
||||
|
||||
// Security: remove the file and stop the script if too bit (+6MiB)
|
||||
if(filesize($filepath) > 6000000) {
|
||||
unlink($filepath);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return to the user the generated file ID
|
||||
exit($filename);
|
||||
}
|
||||
|
||||
?>
|
43
jappixmini/jappix/php/geolocation.php
Normal file
43
jappixmini/jappix/php/geolocation.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix geolocation script
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 15/01/12
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed for a special node
|
||||
if(isStatic() || isUpload())
|
||||
exit;
|
||||
|
||||
// If valid data was sent
|
||||
if((isset($_GET['latitude']) && !empty($_GET['latitude'])) && (isset($_GET['longitude']) && !empty($_GET['longitude'])) && (isset($_GET['language']) && !empty($_GET['language']))) {
|
||||
// Set a XML header
|
||||
header('Content-Type: text/xml; charset=utf-8');
|
||||
|
||||
// Get the XML content
|
||||
$xml = read_url('http://maps.googleapis.com/maps/api/geocode/xml?latlng='.urlencode($_GET['latitude']).','.urlencode($_GET['longitude']).'&language='.urlencode($_GET['language']).'&sensor=true');
|
||||
|
||||
exit($xml);
|
||||
}
|
||||
|
||||
?>
|
37
jappixmini/jappix/php/get-store.php
Normal file
37
jappixmini/jappix/php/get-store.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the store configuration GET handler (manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Purge requested
|
||||
if(isset($_GET['p']) && preg_match('/^((everything)|(cache)|(logs)|(send)|(updates))$/', $_GET['p'])) {
|
||||
purgeFolder($_GET['p']);
|
||||
?>
|
||||
|
||||
<p class="info smallspace success"><?php _e("The storage folder you wanted to clean is now empty!"); ?></p>
|
||||
|
||||
<?php }
|
||||
|
||||
// Folder view?
|
||||
if(isset($_GET['b']) && isset($_GET['s'])) {
|
||||
if($_GET['b'] == 'share')
|
||||
$share_folder = urldecode($_GET['s']);
|
||||
else if($_GET['b'] == 'music')
|
||||
$music_folder = urldecode($_GET['s']);
|
||||
}
|
||||
|
||||
?>
|
340
jappixmini/jappix/php/get.php
Normal file
340
jappixmini/jappix/php/get.php
Normal file
|
@ -0,0 +1,340 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the file get script
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 03/12/11
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// We get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./functions-get.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Hide PHP errors
|
||||
hideErrors();
|
||||
|
||||
// Get some parameters
|
||||
$is_developer = isDeveloper();
|
||||
$has_compression = hasCompression();
|
||||
|
||||
if($is_developer) {
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
}
|
||||
|
||||
// Else, we put a far away cache date (1 year)
|
||||
else {
|
||||
$expires = 31536000;
|
||||
header('Pragma: public');
|
||||
header('Cache-Control: maxage='.$expires);
|
||||
header('Expires: '.gmdate('D, d M Y H:i:s', (time() + $expires)).' GMT');
|
||||
}
|
||||
|
||||
// Initialize the vars
|
||||
$type = '';
|
||||
$file = '';
|
||||
|
||||
// Read the type var
|
||||
if(isset($_GET['t']) && !empty($_GET['t']) && preg_match('/^(css|js|img|snd|store)$/', $_GET['t']))
|
||||
$type = $_GET['t'];
|
||||
|
||||
// Read the files var
|
||||
if(isset($_GET['f']) && !empty($_GET['f']) && isSafe($_GET['f']))
|
||||
$file = $_GET['f'];
|
||||
|
||||
// Read the group var (only for text files)
|
||||
if(isset($_GET['g']) && !empty($_GET['g']) && preg_match('/^(\S+)\.xml$/', $_GET['g']) && preg_match('/^(css|js)$/', $type) && isSafe($_GET['g']) && file_exists('../xml/'.$_GET['g'])) {
|
||||
$xml_data = file_get_contents('../xml/'.$_GET['g']);
|
||||
|
||||
// Any data?
|
||||
if($xml_data) {
|
||||
$xml_read = new SimpleXMLElement($xml_data);
|
||||
$xml_parse = $xml_read->$type;
|
||||
|
||||
// Files were added to the list before (with file var)?
|
||||
if($file)
|
||||
$file .= '~'.$xml_parse;
|
||||
else
|
||||
$file = $xml_parse;
|
||||
}
|
||||
}
|
||||
|
||||
// We check if the data was submitted
|
||||
if($file && $type) {
|
||||
// We define some stuffs
|
||||
$dir = '../'.$type.'/';
|
||||
$path = $dir.$file;
|
||||
|
||||
// Define the real type if this is a "store" file
|
||||
if($type == 'store') {
|
||||
// Extract the file extension
|
||||
switch(getFileExt($file)) {
|
||||
// CSS file
|
||||
case 'css':
|
||||
$type = 'css';
|
||||
|
||||
break;
|
||||
|
||||
// JS file
|
||||
case 'js':
|
||||
$type = 'js';
|
||||
|
||||
break;
|
||||
|
||||
// Audio file
|
||||
case 'ogg':
|
||||
case 'oga':
|
||||
$type = 'snd';
|
||||
|
||||
break;
|
||||
|
||||
// Image file
|
||||
case 'png':
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'gif':
|
||||
case 'bmp':
|
||||
$type = 'img';
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// JS and CSS special stuffs
|
||||
if(($type == 'css') || ($type == 'js')) {
|
||||
// Compression var
|
||||
if($has_compression)
|
||||
$cache_encoding = 'deflate';
|
||||
else
|
||||
$cache_encoding = 'plain';
|
||||
|
||||
// Get the vars
|
||||
$version = getVersion();
|
||||
$hash = genHash($version);
|
||||
$cache_hash = md5($path.$hash.staticLocation()).'_'.$cache_encoding;
|
||||
|
||||
// Check if the browser supports DEFLATE
|
||||
$deflate_support = false;
|
||||
|
||||
if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && hasCompression() && !$is_developer)
|
||||
$deflate_support = true;
|
||||
|
||||
// Internationalization
|
||||
if($type == 'js') {
|
||||
if(isset($_GET['l']) && !empty($_GET['l']) && !preg_match('/\.\.\//', $_GET['l']) && is_dir('../lang/'.$_GET['l']))
|
||||
$locale = $_GET['l'];
|
||||
else
|
||||
$locale = 'en';
|
||||
}
|
||||
|
||||
else
|
||||
$locale = '';
|
||||
|
||||
// Define the cache lang name
|
||||
if($locale)
|
||||
$cache_lang = $cache_hash.'_'.$locale;
|
||||
else
|
||||
$cache_lang = $cache_hash;
|
||||
}
|
||||
|
||||
// Explode the file string
|
||||
if(strpos($file, '~') != false)
|
||||
$array = explode('~', $file);
|
||||
else
|
||||
$array = array($file);
|
||||
|
||||
// Define the reading vars
|
||||
$continue = true;
|
||||
$loop_files = true;
|
||||
|
||||
// Check the cache exists for text files (avoid the heavy file_exists loop!)
|
||||
if(!$is_developer && (($type == 'css') || ($type == 'js')) && hasCache($cache_lang))
|
||||
$loop_files = false;
|
||||
|
||||
// Check if the all the file(s) exist(s)
|
||||
if($loop_files) {
|
||||
foreach($array as $current) {
|
||||
// Stop the loop if a file is missing
|
||||
if(!file_exists($dir.$current)) {
|
||||
$continue = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We can read the file(s)
|
||||
if($continue) {
|
||||
// We get the file MIME type
|
||||
$mime = strtolower(preg_replace('/(^)(.+)(\.)(.+)($)/i', '$4', $file));
|
||||
|
||||
// We set up a known MIME type (and some other headers)
|
||||
if(($type == 'css') || ($type == 'js')) {
|
||||
// DEFLATE header
|
||||
if($deflate_support)
|
||||
header('Content-Encoding: deflate');
|
||||
|
||||
// MIME header
|
||||
if($type == 'css')
|
||||
header('Content-Type: text/css; charset=utf-8');
|
||||
else if($type == 'js')
|
||||
header('Content-Type: application/javascript; charset=utf-8');
|
||||
}
|
||||
|
||||
else if($mime == 'png')
|
||||
header('Content-Type: image/png');
|
||||
else if($mime == 'gif')
|
||||
header('Content-Type: image/gif');
|
||||
else if(($mime == 'jpg') || ($mime == 'jpeg'))
|
||||
header('Content-Type: image/jpeg');
|
||||
else if($mime == 'bmp')
|
||||
header('Content-Type: image/bmp');
|
||||
else if(($mime == 'oga') || ($mime == 'ogg'))
|
||||
header('Content-Type: audio/ogg');
|
||||
|
||||
// Catch the file MIME type
|
||||
else
|
||||
header('Content-Type: '.getFileMIME($path));
|
||||
|
||||
// Read the text file(s) (CSS & JS)
|
||||
if(($type == 'css') || ($type == 'js')) {
|
||||
// If there's a cache file, read it
|
||||
if(hasCache($cache_lang) && !$is_developer) {
|
||||
$cache_read = readCache($cache_lang);
|
||||
|
||||
if($deflate_support || !$has_compression)
|
||||
echo $cache_read;
|
||||
else
|
||||
echo gzinflate($cache_read);
|
||||
}
|
||||
|
||||
// Else, we generate the cache
|
||||
else {
|
||||
// First try to read the cache reference
|
||||
if(hasCache($cache_hash) && !$is_developer) {
|
||||
// Read the reference
|
||||
$cache_reference = readCache($cache_hash);
|
||||
|
||||
// Filter the cache reference
|
||||
if($has_compression)
|
||||
$output = gzinflate($cache_reference);
|
||||
else
|
||||
$output = $cache_reference;
|
||||
}
|
||||
|
||||
// No cache reference, we should generate it
|
||||
else {
|
||||
// Initialize the loop
|
||||
$looped = '';
|
||||
|
||||
// Add the content of the current file
|
||||
foreach($array as $current)
|
||||
$looped .= rmBOM(file_get_contents($dir.$current))."\n";
|
||||
|
||||
// Filter the CSS
|
||||
if($type == 'css') {
|
||||
// Apply the CSS logos
|
||||
$looped = setLogos($looped, $array);
|
||||
|
||||
// Apply the CSS background
|
||||
$looped = setBackground($looped);
|
||||
|
||||
// Set the Get API paths
|
||||
$looped = setPath($looped, $hash, HOST_STATIC, $type, '');
|
||||
}
|
||||
|
||||
// Optimize the code rendering
|
||||
if($type == 'css') {
|
||||
// Can minify the CSS
|
||||
if($has_compression && !$is_developer)
|
||||
$output = compressCSS($looped);
|
||||
else
|
||||
$output = $looped;
|
||||
}
|
||||
|
||||
else {
|
||||
// Can minify the JS (sloooooow!)
|
||||
if($has_compression && !$is_developer) {
|
||||
require_once('./jsmin.php');
|
||||
$output = JSMin::minify($looped);
|
||||
}
|
||||
|
||||
else
|
||||
$output = $looped;
|
||||
}
|
||||
|
||||
// Generate the reference cache
|
||||
if($has_compression)
|
||||
$final = gzdeflate($output, 9);
|
||||
else
|
||||
$final = $output;
|
||||
|
||||
// Write it!
|
||||
genCache($final, $is_developer, $cache_hash);
|
||||
}
|
||||
|
||||
// Filter the JS
|
||||
if($type == 'js') {
|
||||
// Set the JS locales
|
||||
$output = setLocales($output, $locale);
|
||||
|
||||
// Set the JS configuration
|
||||
$output = setConfiguration($output, $locale, $version, uploadMaxSize());
|
||||
|
||||
// Set the Get API paths
|
||||
$output = setPath($output, $hash, HOST_STATIC, $type, $locale);
|
||||
|
||||
// Translate the JS script
|
||||
require_once('./gettext.php');
|
||||
includeTranslation($locale, 'main');
|
||||
$output = setTranslation($output);
|
||||
|
||||
// Generate the cache
|
||||
if($has_compression)
|
||||
$final = gzdeflate($output, 9);
|
||||
else
|
||||
$final = $output;
|
||||
|
||||
// Write it!
|
||||
genCache($final, $is_developer, $cache_lang);
|
||||
}
|
||||
|
||||
// Output a well-encoded string
|
||||
if($deflate_support || !$has_compression)
|
||||
echo $final;
|
||||
else
|
||||
echo gzinflate($final);
|
||||
}
|
||||
}
|
||||
|
||||
// Read the binary file (PNG, OGA and others)
|
||||
else
|
||||
readfile($path);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// The file was not found
|
||||
header('Status: 404 Not Found', true, 404);
|
||||
exit('HTTP/1.1 404 Not Found');
|
||||
}
|
||||
|
||||
// The request is not correct
|
||||
header('Status: 400 Bad Request', true, 400);
|
||||
exit('HTTP/1.1 400 Bad Request');
|
||||
|
||||
?>
|
949
jappixmini/jappix/php/gettext.php
Normal file
949
jappixmini/jappix/php/gettext.php
Normal file
|
@ -0,0 +1,949 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
|
||||
|
||||
This file is part of PHP-gettext.
|
||||
|
||||
PHP-gettext is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
PHP-gettext 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with PHP-gettext; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* MODIFIED FOR THE JAPPIX PROJECT
|
||||
* Last revision: 10/11/10
|
||||
*/
|
||||
|
||||
// Simple class to wrap file streams, string streams, etc.
|
||||
// seek is essential, and it should be byte stream
|
||||
class StreamReader {
|
||||
// should return a string [FIXME: perhaps return array of bytes?]
|
||||
function read($bytes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// should return new position
|
||||
function seekto($position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns current position
|
||||
function currentpos() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns length of entire stream (limit for seekto()s)
|
||||
function length() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class StringReader {
|
||||
var $_pos;
|
||||
var $_str;
|
||||
|
||||
function StringReader($str='') {
|
||||
$this->_str = $str;
|
||||
$this->_pos = 0;
|
||||
}
|
||||
|
||||
function read($bytes) {
|
||||
$data = substr($this->_str, $this->_pos, $bytes);
|
||||
$this->_pos += $bytes;
|
||||
if (strlen($this->_str)<$this->_pos)
|
||||
$this->_pos = strlen($this->_str);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function seekto($pos) {
|
||||
$this->_pos = $pos;
|
||||
if (strlen($this->_str)<$this->_pos)
|
||||
$this->_pos = strlen($this->_str);
|
||||
return $this->_pos;
|
||||
}
|
||||
|
||||
function currentpos() {
|
||||
return $this->_pos;
|
||||
}
|
||||
|
||||
function length() {
|
||||
return strlen($this->_str);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class FileReader {
|
||||
var $_pos;
|
||||
var $_fd;
|
||||
var $_length;
|
||||
|
||||
function FileReader($filename) {
|
||||
if (file_exists($filename)) {
|
||||
|
||||
$this->_length=filesize($filename);
|
||||
$this->_pos = 0;
|
||||
$this->_fd = fopen($filename,'rb');
|
||||
if (!$this->_fd) {
|
||||
$this->error = 3; // Cannot read file, probably permissions
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->error = 2; // File doesn't exist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function read($bytes) {
|
||||
if ($bytes) {
|
||||
fseek($this->_fd, $this->_pos);
|
||||
|
||||
// PHP 5.1.1 does not read more than 8192 bytes in one fread()
|
||||
// the discussions at PHP Bugs suggest it's the intended behaviour
|
||||
$data = '';
|
||||
while ($bytes > 0) {
|
||||
$chunk = fread($this->_fd, $bytes);
|
||||
$data .= $chunk;
|
||||
$bytes -= strlen($chunk);
|
||||
}
|
||||
$this->_pos = ftell($this->_fd);
|
||||
|
||||
return $data;
|
||||
} else return '';
|
||||
}
|
||||
|
||||
function seekto($pos) {
|
||||
fseek($this->_fd, $pos);
|
||||
$this->_pos = ftell($this->_fd);
|
||||
return $this->_pos;
|
||||
}
|
||||
|
||||
function currentpos() {
|
||||
return $this->_pos;
|
||||
}
|
||||
|
||||
function length() {
|
||||
return $this->_length;
|
||||
}
|
||||
|
||||
function close() {
|
||||
fclose($this->_fd);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Preloads entire file in memory first, then creates a StringReader
|
||||
// over it (it assumes knowledge of StringReader internals)
|
||||
class CachedFileReader extends StringReader {
|
||||
function CachedFileReader($filename) {
|
||||
if (file_exists($filename)) {
|
||||
|
||||
$length=filesize($filename);
|
||||
$fd = fopen($filename,'rb');
|
||||
|
||||
if (!$fd) {
|
||||
$this->error = 3; // Cannot read file, probably permissions
|
||||
return false;
|
||||
}
|
||||
$this->_str = fread($fd, $length);
|
||||
fclose($fd);
|
||||
|
||||
} else {
|
||||
$this->error = 2; // File doesn't exist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Copyright (c) 2003, 2009 Danilo Segan <danilo@kvota.net>.
|
||||
Copyright (c) 2005 Nico Kaiser <nico@siriux.net>
|
||||
|
||||
This file is part of PHP-gettext.
|
||||
|
||||
PHP-gettext is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
PHP-gettext 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with PHP-gettext; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides a simple gettext replacement that works independently from
|
||||
* the system's gettext abilities.
|
||||
* It can read MO files and use them for translating strings.
|
||||
* The files are passed to gettext_reader as a Stream (see streams.php)
|
||||
*
|
||||
* This version has the ability to cache all strings and translations to
|
||||
* speed up the string lookup.
|
||||
* While the cache is enabled by default, it can be switched off with the
|
||||
* second parameter in the constructor (e.g. whenusing very large MO files
|
||||
* that you don't want to keep in memory)
|
||||
*/
|
||||
class gettext_reader {
|
||||
//public:
|
||||
var $error = 0; // public variable that holds error code (0 if no error)
|
||||
|
||||
//private:
|
||||
var $BYTEORDER = 0; // 0: low endian, 1: big endian
|
||||
var $STREAM = NULL;
|
||||
var $short_circuit = false;
|
||||
var $enable_cache = false;
|
||||
var $originals = NULL; // offset of original table
|
||||
var $translations = NULL; // offset of translation table
|
||||
var $pluralheader = NULL; // cache header field for plural forms
|
||||
var $total = 0; // total string count
|
||||
var $table_originals = NULL; // table for original strings (offsets)
|
||||
var $table_translations = NULL; // table for translated strings (offsets)
|
||||
var $cache_translations = NULL; // original -> translation mapping
|
||||
|
||||
|
||||
/* Methods */
|
||||
|
||||
|
||||
/**
|
||||
* Reads a 32bit Integer from the Stream
|
||||
*
|
||||
* @access private
|
||||
* @return Integer from the Stream
|
||||
*/
|
||||
function readint() {
|
||||
if ($this->BYTEORDER == 0) {
|
||||
// low endian
|
||||
$input=unpack('V', $this->STREAM->read(4));
|
||||
return array_shift($input);
|
||||
} else {
|
||||
// big endian
|
||||
$input=unpack('N', $this->STREAM->read(4));
|
||||
return array_shift($input);
|
||||
}
|
||||
}
|
||||
|
||||
function read($bytes) {
|
||||
return $this->STREAM->read($bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an array of Integers from the Stream
|
||||
*
|
||||
* @param int count How many elements should be read
|
||||
* @return Array of Integers
|
||||
*/
|
||||
function readintarray($count) {
|
||||
if ($this->BYTEORDER == 0) {
|
||||
// low endian
|
||||
return unpack('V'.$count, $this->STREAM->read(4 * $count));
|
||||
} else {
|
||||
// big endian
|
||||
return unpack('N'.$count, $this->STREAM->read(4 * $count));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object Reader the StreamReader object
|
||||
* @param boolean enable_cache Enable or disable caching of strings (default on)
|
||||
*/
|
||||
function gettext_reader($Reader, $enable_cache = true) {
|
||||
// If there isn't a StreamReader, turn on short circuit mode.
|
||||
if (! $Reader || isset($Reader->error) ) {
|
||||
$this->short_circuit = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Caching can be turned off
|
||||
$this->enable_cache = $enable_cache;
|
||||
|
||||
$MAGIC1 = "\x95\x04\x12\xde";
|
||||
$MAGIC2 = "\xde\x12\x04\x95";
|
||||
|
||||
$this->STREAM = $Reader;
|
||||
$magic = $this->read(4);
|
||||
if ($magic == $MAGIC1) {
|
||||
$this->BYTEORDER = 1;
|
||||
} elseif ($magic == $MAGIC2) {
|
||||
$this->BYTEORDER = 0;
|
||||
} else {
|
||||
$this->error = 1; // not MO file
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Do we care about revision? We should.
|
||||
$revision = $this->readint();
|
||||
|
||||
$this->total = $this->readint();
|
||||
$this->originals = $this->readint();
|
||||
$this->translations = $this->readint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the translation tables from the MO file into the cache
|
||||
* If caching is enabled, also loads all strings into a cache
|
||||
* to speed up translation lookups
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function load_tables() {
|
||||
if (is_array($this->cache_translations) &&
|
||||
is_array($this->table_originals) &&
|
||||
is_array($this->table_translations))
|
||||
return;
|
||||
|
||||
/* get original and translations tables */
|
||||
$this->STREAM->seekto($this->originals);
|
||||
$this->table_originals = $this->readintarray($this->total * 2);
|
||||
$this->STREAM->seekto($this->translations);
|
||||
$this->table_translations = $this->readintarray($this->total * 2);
|
||||
|
||||
if ($this->enable_cache) {
|
||||
$this->cache_translations = array ();
|
||||
/* read all strings in the cache */
|
||||
for ($i = 0; $i < $this->total; $i++) {
|
||||
$this->STREAM->seekto($this->table_originals[$i * 2 + 2]);
|
||||
$original = $this->STREAM->read($this->table_originals[$i * 2 + 1]);
|
||||
$this->STREAM->seekto($this->table_translations[$i * 2 + 2]);
|
||||
$translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]);
|
||||
$this->cache_translations[$original] = $translation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string from the "originals" table
|
||||
*
|
||||
* @access private
|
||||
* @param int num Offset number of original string
|
||||
* @return string Requested string if found, otherwise ''
|
||||
*/
|
||||
function get_original_string($num) {
|
||||
$length = $this->table_originals[$num * 2 + 1];
|
||||
$offset = $this->table_originals[$num * 2 + 2];
|
||||
if (! $length)
|
||||
return '';
|
||||
$this->STREAM->seekto($offset);
|
||||
$data = $this->STREAM->read($length);
|
||||
return (string)$data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string from the "translations" table
|
||||
*
|
||||
* @access private
|
||||
* @param int num Offset number of original string
|
||||
* @return string Requested string if found, otherwise ''
|
||||
*/
|
||||
function get_translation_string($num) {
|
||||
$length = $this->table_translations[$num * 2 + 1];
|
||||
$offset = $this->table_translations[$num * 2 + 2];
|
||||
if (! $length)
|
||||
return '';
|
||||
$this->STREAM->seekto($offset);
|
||||
$data = $this->STREAM->read($length);
|
||||
return (string)$data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binary search for string
|
||||
*
|
||||
* @access private
|
||||
* @param string string
|
||||
* @param int start (internally used in recursive function)
|
||||
* @param int end (internally used in recursive function)
|
||||
* @return int string number (offset in originals table)
|
||||
*/
|
||||
function find_string($string, $start = -1, $end = -1) {
|
||||
if (($start == -1) or ($end == -1)) {
|
||||
// find_string is called with only one parameter, set start end end
|
||||
$start = 0;
|
||||
$end = $this->total;
|
||||
}
|
||||
if (abs($start - $end) <= 1) {
|
||||
// We're done, now we either found the string, or it doesn't exist
|
||||
$txt = $this->get_original_string($start);
|
||||
if ($string == $txt)
|
||||
return $start;
|
||||
else
|
||||
return -1;
|
||||
} else if ($start > $end) {
|
||||
// start > end -> turn around and start over
|
||||
return $this->find_string($string, $end, $start);
|
||||
} else {
|
||||
// Divide table in two parts
|
||||
$half = (int)(($start + $end) / 2);
|
||||
$cmp = strcmp($string, $this->get_original_string($half));
|
||||
if ($cmp == 0)
|
||||
// string is exactly in the middle => return it
|
||||
return $half;
|
||||
else if ($cmp < 0)
|
||||
// The string is in the upper half
|
||||
return $this->find_string($string, $start, $half);
|
||||
else
|
||||
// The string is in the lower half
|
||||
return $this->find_string($string, $half, $end);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a string
|
||||
*
|
||||
* @access public
|
||||
* @param string string to be translated
|
||||
* @return string translated string (or original, if not found)
|
||||
*/
|
||||
function translate($string) {
|
||||
if ($this->short_circuit)
|
||||
return $string;
|
||||
$this->load_tables();
|
||||
|
||||
if ($this->enable_cache) {
|
||||
// Caching enabled, get translated string from cache
|
||||
if (array_key_exists($string, $this->cache_translations))
|
||||
return $this->cache_translations[$string];
|
||||
else
|
||||
return $string;
|
||||
} else {
|
||||
// Caching not enabled, try to find string
|
||||
$num = $this->find_string($string);
|
||||
if ($num == -1)
|
||||
return $string;
|
||||
else
|
||||
return $this->get_translation_string($num);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize plural form expression for use in PHP eval call.
|
||||
*
|
||||
* @access private
|
||||
* @return string sanitized plural form expression
|
||||
*/
|
||||
function sanitize_plural_expression($expr) {
|
||||
// Get rid of disallowed characters.
|
||||
$expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
|
||||
|
||||
// Add parenthesis for tertiary '?' operator.
|
||||
$expr .= ';';
|
||||
$res = '';
|
||||
$p = 0;
|
||||
for ($i = 0; $i < strlen($expr); $i++) {
|
||||
$ch = $expr[$i];
|
||||
switch ($ch) {
|
||||
case '?':
|
||||
$res .= ' ? (';
|
||||
$p++;
|
||||
break;
|
||||
case ':':
|
||||
$res .= ') : (';
|
||||
break;
|
||||
case ';':
|
||||
$res .= str_repeat( ')', $p) . ';';
|
||||
$p = 0;
|
||||
break;
|
||||
default:
|
||||
$res .= $ch;
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get possible plural forms from MO header
|
||||
*
|
||||
* @access private
|
||||
* @return string plural form header
|
||||
*/
|
||||
function get_plural_forms() {
|
||||
// lets assume message number 0 is header
|
||||
// this is true, right?
|
||||
$this->load_tables();
|
||||
|
||||
// cache header field for plural forms
|
||||
if (! is_string($this->pluralheader)) {
|
||||
if ($this->enable_cache) {
|
||||
$header = $this->cache_translations[""];
|
||||
} else {
|
||||
$header = $this->get_translation_string(0);
|
||||
}
|
||||
if (eregi("plural-forms: ([^\n]*)\n", $header, $regs))
|
||||
$expr = $regs[1];
|
||||
else
|
||||
$expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
|
||||
|
||||
$this->pluralheader = $this->sanitize_plural_expression($expr);
|
||||
}
|
||||
return $this->pluralheader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects which plural form to take
|
||||
*
|
||||
* @access private
|
||||
* @param n count
|
||||
* @return int array index of the right plural form
|
||||
*/
|
||||
function select_string($n) {
|
||||
$string = $this->get_plural_forms();
|
||||
$string = str_replace('nplurals',"\$total",$string);
|
||||
$string = str_replace("n",$n,$string);
|
||||
$string = str_replace('plural',"\$plural",$string);
|
||||
|
||||
$total = 0;
|
||||
$plural = 0;
|
||||
|
||||
eval("$string");
|
||||
if ($plural >= $total) $plural = $total - 1;
|
||||
return $plural;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plural version of gettext
|
||||
*
|
||||
* @access public
|
||||
* @param string single
|
||||
* @param string plural
|
||||
* @param string number
|
||||
* @return translated plural form
|
||||
*/
|
||||
function ngettext($single, $plural, $number) {
|
||||
if ($this->short_circuit) {
|
||||
if ($number != 1)
|
||||
return $plural;
|
||||
else
|
||||
return $single;
|
||||
}
|
||||
|
||||
// find out the appropriate form
|
||||
$select = $this->select_string($number);
|
||||
|
||||
// this should contains all strings separated by NULLs
|
||||
$key = $single.chr(0).$plural;
|
||||
|
||||
|
||||
if ($this->enable_cache) {
|
||||
if (! array_key_exists($key, $this->cache_translations)) {
|
||||
return ($number != 1) ? $plural : $single;
|
||||
} else {
|
||||
$result = $this->cache_translations[$key];
|
||||
$list = explode(chr(0), $result);
|
||||
return $list[$select];
|
||||
}
|
||||
} else {
|
||||
$num = $this->find_string($key);
|
||||
if ($num == -1) {
|
||||
return ($number != 1) ? $plural : $single;
|
||||
} else {
|
||||
$result = $this->get_translation_string($num);
|
||||
$list = explode(chr(0), $result);
|
||||
return $list[$select];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Copyright (c) 2005 Steven Armstrong <sa at c-area dot ch>
|
||||
Copyright (c) 2009 Danilo Segan <danilo@kvota.net>
|
||||
|
||||
Drop in replacement for native gettext.
|
||||
|
||||
This file is part of PHP-gettext.
|
||||
|
||||
PHP-gettext is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
PHP-gettext 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with PHP-gettext; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
/*
|
||||
LC_CTYPE 0
|
||||
LC_NUMERIC 1
|
||||
LC_TIME 2
|
||||
LC_COLLATE 3
|
||||
LC_MONETARY 4
|
||||
LC_MESSAGES 5
|
||||
LC_ALL 6
|
||||
*/
|
||||
|
||||
|
||||
// LC_MESSAGES is not available if php-gettext is not loaded
|
||||
// while the other constants are already available from session extension.
|
||||
if (!defined('LC_MESSAGES')) {
|
||||
define('LC_MESSAGES', 5);
|
||||
}
|
||||
|
||||
// Variables
|
||||
|
||||
global $text_domains, $default_domain, $LC_CATEGORIES, $EMULATEGETTEXT, $CURRENTLOCALE;
|
||||
$text_domains = array();
|
||||
$default_domain = 'messages';
|
||||
$LC_CATEGORIES = array('LC_CTYPE', 'LC_NUMERIC', 'LC_TIME', 'LC_COLLATE', 'LC_MONETARY', 'LC_MESSAGES', 'LC_ALL');
|
||||
$EMULATEGETTEXT = 0;
|
||||
$CURRENTLOCALE = '';
|
||||
|
||||
/* Class to hold a single domain included in $text_domains. */
|
||||
class domain {
|
||||
var $l10n;
|
||||
var $path;
|
||||
var $codeset;
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
|
||||
/**
|
||||
* Utility function to get a StreamReader for the given text domain.
|
||||
*/
|
||||
function _get_reader($domain=null, $category=5, $enable_cache=true) {
|
||||
global $text_domains, $default_domain, $LC_CATEGORIES;
|
||||
if (!isset($domain)) $domain = $default_domain;
|
||||
if (!isset($text_domains[$domain]->l10n)) {
|
||||
// get the current locale
|
||||
$locale = _setlocale(LC_MESSAGES, 0);
|
||||
$bound_path = isset($text_domains[$domain]->path) ?
|
||||
$text_domains[$domain]->path : './';
|
||||
$subpath = $LC_CATEGORIES[$category] ."/$domain.mo";
|
||||
/* Figure out all possible locale names and start with the most
|
||||
specific ones. I.e. for sr_CS.UTF-8@latin, look through all of
|
||||
sr_CS.UTF-8@latin, sr_CS@latin, sr@latin, sr_CS.UTF-8, sr_CS, sr.
|
||||
*/
|
||||
$locale_names = array();
|
||||
if (preg_match("/([a-z]{2,3})" // language code
|
||||
."(_([A-Z]{2}))?" // country code
|
||||
."(\.([-A-Za-z0-9_]))?" // charset
|
||||
."(@([-A-Za-z0-9_]+))?/", // @ modifier
|
||||
$locale, $matches)) {
|
||||
|
||||
$lang = '';
|
||||
$country = '';
|
||||
$charset = '';
|
||||
$modifier = '';
|
||||
|
||||
if(isset($matches[1]))
|
||||
$lang = $matches[1];
|
||||
if(isset($matches[3]))
|
||||
$country = $matches[3];
|
||||
if(isset($matches[5]))
|
||||
$charset = $matches[5];
|
||||
if(isset($matches[7]))
|
||||
$modifier = $matches[7];
|
||||
|
||||
if ($modifier) {
|
||||
$locale_names = array("${lang}_$country.$charset@$modifier",
|
||||
"${lang}_$country@$modifier",
|
||||
"$lang@$modifier");
|
||||
}
|
||||
array_push($locale_names,
|
||||
"${lang}_$country.$charset", "${lang}_$country", "$lang");
|
||||
}
|
||||
array_push($locale_names, $locale);
|
||||
|
||||
$input = null;
|
||||
foreach ($locale_names as $locale) {
|
||||
$full_path = $bound_path . $locale . "/" . $subpath;
|
||||
if (file_exists($full_path)) {
|
||||
$input = new FileReader($full_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!array_key_exists($domain, $text_domains)) {
|
||||
// Initialize an empty domain object.
|
||||
$text_domains[$domain] = new domain();
|
||||
}
|
||||
$text_domains[$domain]->l10n = new gettext_reader($input,
|
||||
$enable_cache);
|
||||
}
|
||||
return $text_domains[$domain]->l10n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we are using our emulated gettext API or PHP built-in one.
|
||||
*/
|
||||
function locale_emulation() {
|
||||
global $EMULATEGETTEXT;
|
||||
return $EMULATEGETTEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current locale is supported on this system.
|
||||
*/
|
||||
function _check_locale() {
|
||||
global $EMULATEGETTEXT;
|
||||
return !$EMULATEGETTEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the codeset for the given domain.
|
||||
*/
|
||||
function _get_codeset($domain=null) {
|
||||
global $text_domains, $default_domain, $LC_CATEGORIES;
|
||||
if (!isset($domain)) $domain = $default_domain;
|
||||
return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given string to the encoding set by bind_textdomain_codeset.
|
||||
*/
|
||||
function _encode($text) {
|
||||
$source_encoding = mb_detect_encoding($text);
|
||||
$target_encoding = _get_codeset();
|
||||
if ($source_encoding != $target_encoding) {
|
||||
return mb_convert_encoding($text, $target_encoding, $source_encoding);
|
||||
}
|
||||
else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Custom implementation of the standard gettext related functions
|
||||
|
||||
/**
|
||||
* Sets a requested locale, if needed emulates it.
|
||||
*/
|
||||
function _setlocale($category, $locale) {
|
||||
global $CURRENTLOCALE, $EMULATEGETTEXT;
|
||||
if ($locale === 0) { // use === to differentiate between string "0"
|
||||
if ($CURRENTLOCALE != '')
|
||||
return $CURRENTLOCALE;
|
||||
else
|
||||
// obey LANG variable, maybe extend to support all of LC_* vars
|
||||
// even if we tried to read locale without setting it first
|
||||
return _setlocale($category, $CURRENTLOCALE);
|
||||
} else {
|
||||
$ret = 0;
|
||||
if (function_exists('setlocale')) // I don't know if this ever happens ;)
|
||||
$ret = setlocale($category, $locale);
|
||||
if (($ret and $locale == '') or ($ret == $locale)) {
|
||||
$EMULATEGETTEXT = 0;
|
||||
$CURRENTLOCALE = $ret;
|
||||
} else {
|
||||
if ($locale == '') // emulate variable support
|
||||
$CURRENTLOCALE = getenv('LANG');
|
||||
else
|
||||
$CURRENTLOCALE = $locale;
|
||||
$EMULATEGETTEXT = 1;
|
||||
}
|
||||
// Allow locale to be changed on the go for one translation domain.
|
||||
global $text_domains, $default_domain;
|
||||
unset($text_domains[$default_domain]->l10n);
|
||||
return $CURRENTLOCALE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path for a domain.
|
||||
*/
|
||||
function _bindtextdomain($domain, $path) {
|
||||
global $text_domains;
|
||||
// ensure $path ends with a slash ('/' should work for both, but lets still play nice)
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/')
|
||||
$path .= '\\';
|
||||
} else {
|
||||
if ($path[strlen($path)-1] != '/')
|
||||
$path .= '/';
|
||||
}
|
||||
if (!array_key_exists($domain, $text_domains)) {
|
||||
// Initialize an empty domain object.
|
||||
$text_domains[$domain] = new domain();
|
||||
}
|
||||
$text_domains[$domain]->path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the character encoding in which the messages from the DOMAIN message catalog will be returned.
|
||||
*/
|
||||
function _bind_textdomain_codeset($domain, $codeset) {
|
||||
global $text_domains;
|
||||
$text_domains[$domain]->codeset = $codeset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default domain.
|
||||
*/
|
||||
function _textdomain($domain) {
|
||||
global $default_domain;
|
||||
$default_domain = $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup a message in the current domain.
|
||||
*/
|
||||
function _gettext($msgid) {
|
||||
$l10n = _get_reader();
|
||||
//return $l10n->translate($msgid);
|
||||
return _encode($l10n->translate($msgid));
|
||||
}
|
||||
/**
|
||||
* Alias for gettext.
|
||||
*/
|
||||
function __($msgid) {
|
||||
return _gettext($msgid);
|
||||
}
|
||||
/**
|
||||
* Plural version of gettext.
|
||||
*/
|
||||
function _ngettext($single, $plural, $number) {
|
||||
$l10n = _get_reader();
|
||||
//return $l10n->ngettext($single, $plural, $number);
|
||||
return _encode($l10n->ngettext($single, $plural, $number));
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the current domain.
|
||||
*/
|
||||
function _dgettext($domain, $msgid) {
|
||||
$l10n = _get_reader($domain);
|
||||
//return $l10n->translate($msgid);
|
||||
return _encode($l10n->translate($msgid));
|
||||
}
|
||||
/**
|
||||
* Plural version of dgettext.
|
||||
*/
|
||||
function _dngettext($domain, $single, $plural, $number) {
|
||||
$l10n = _get_reader($domain);
|
||||
//return $l10n->ngettext($single, $plural, $number);
|
||||
return _encode($l10n->ngettext($single, $plural, $number));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the domain and category for a single lookup.
|
||||
*/
|
||||
function _dcgettext($domain, $msgid, $category) {
|
||||
$l10n = _get_reader($domain, $category);
|
||||
//return $l10n->translate($msgid);
|
||||
return _encode($l10n->translate($msgid));
|
||||
}
|
||||
/**
|
||||
* Plural version of dcgettext.
|
||||
*/
|
||||
function _dcngettext($domain, $single, $plural, $number, $category) {
|
||||
$l10n = _get_reader($domain, $category);
|
||||
//return $l10n->ngettext($single, $plural, $number);
|
||||
return _encode($l10n->ngettext($single, $plural, $number));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Wrappers to use if the standard gettext functions are available, but the current locale is not supported by the system.
|
||||
// Use the standard impl if the current locale is supported, use the custom impl otherwise.
|
||||
|
||||
function T_setlocale($category, $locale) {
|
||||
return _setlocale($category, $locale);
|
||||
}
|
||||
|
||||
function T_bindtextdomain($domain, $path) {
|
||||
if (_check_locale()) return bindtextdomain($domain, $path);
|
||||
else return _bindtextdomain($domain, $path);
|
||||
}
|
||||
function T_bind_textdomain_codeset($domain, $codeset) {
|
||||
// bind_textdomain_codeset is available only in PHP 4.2.0+
|
||||
if (_check_locale() and function_exists('bind_textdomain_codeset')) return bind_textdomain_codeset($domain, $codeset);
|
||||
else return _bind_textdomain_codeset($domain, $codeset);
|
||||
}
|
||||
function T_textdomain($domain) {
|
||||
if (_check_locale()) return textdomain($domain);
|
||||
else return _textdomain($domain);
|
||||
}
|
||||
function T_gettext($msgid) {
|
||||
if (_check_locale()) return gettext($msgid);
|
||||
else return _gettext($msgid);
|
||||
}
|
||||
function T_($msgid) {
|
||||
if (_check_locale()) return _($msgid);
|
||||
return __($msgid);
|
||||
}
|
||||
function T_ngettext($single, $plural, $number) {
|
||||
if (_check_locale()) return ngettext($single, $plural, $number);
|
||||
else return _ngettext($single, $plural, $number);
|
||||
}
|
||||
function T_dgettext($domain, $msgid) {
|
||||
if (_check_locale()) return dgettext($domain, $msgid);
|
||||
else return _dgettext($domain, $msgid);
|
||||
}
|
||||
function T_dngettext($domain, $single, $plural, $number) {
|
||||
if (_check_locale()) return dngettext($domain, $single, $plural, $number);
|
||||
else return _dngettext($domain, $single, $plural, $number);
|
||||
}
|
||||
function T_dcgettext($domain, $msgid, $category) {
|
||||
if (_check_locale()) return dcgettext($domain, $msgid, $category);
|
||||
else return _dcgettext($domain, $msgid, $category);
|
||||
}
|
||||
function T_dcngettext($domain, $single, $plural, $number, $category) {
|
||||
if (_check_locale()) return dcngettext($domain, $single, $plural, $number, $category);
|
||||
else return _dcngettext($domain, $single, $plural, $number, $category);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Wrappers used as a drop in replacement for the standard gettext functions
|
||||
|
||||
if (!function_exists('gettext')) {
|
||||
function bindtextdomain($domain, $path) {
|
||||
return _bindtextdomain($domain, $path);
|
||||
}
|
||||
function bind_textdomain_codeset($domain, $codeset) {
|
||||
return _bind_textdomain_codeset($domain, $codeset);
|
||||
}
|
||||
function textdomain($domain) {
|
||||
return _textdomain($domain);
|
||||
}
|
||||
function gettext($msgid) {
|
||||
return _gettext($msgid);
|
||||
}
|
||||
function _($msgid) {
|
||||
return __($msgid);
|
||||
}
|
||||
function ngettext($single, $plural, $number) {
|
||||
return _ngettext($single, $plural, $number);
|
||||
}
|
||||
function dgettext($domain, $msgid) {
|
||||
return _dgettext($domain, $msgid);
|
||||
}
|
||||
function dngettext($domain, $single, $plural, $number) {
|
||||
return _dngettext($domain, $single, $plural, $number);
|
||||
}
|
||||
function dcgettext($domain, $msgid, $category) {
|
||||
return _dcgettext($domain, $msgid, $category);
|
||||
}
|
||||
function dcngettext($domain, $single, $plural, $number, $category) {
|
||||
return _dcngettext($domain, $single, $plural, $number, $category);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
289
jappixmini/jappix/php/install.php
Normal file
289
jappixmini/jappix/php/install.php
Normal file
|
@ -0,0 +1,289 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix Install PHP/HTML code
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 25/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Define the configuration folder
|
||||
$conf_folder = JAPPIX_BASE.'/store/conf';
|
||||
|
||||
// Initialize the step
|
||||
$step = 1;
|
||||
|
||||
// Initialize some vars
|
||||
$form_parent = 'install';
|
||||
$user_name = '';
|
||||
$user_password = '';
|
||||
$valid_user = true;
|
||||
|
||||
if(isset($_POST['step']) && !empty($_POST['step'])) {
|
||||
$step = intval($_POST['step']);
|
||||
|
||||
switch($step) {
|
||||
// Administrator account configuration submitted
|
||||
case 3:
|
||||
include(JAPPIX_BASE.'/php/post-users.php');
|
||||
break;
|
||||
|
||||
// Main configuration submitted
|
||||
case 4:
|
||||
include(JAPPIX_BASE.'/php/post-main.php');
|
||||
break;
|
||||
|
||||
// Hosts configuration submitted
|
||||
case 5:
|
||||
include(JAPPIX_BASE.'/php/post-hosts.php');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Not frozen on the previous step?
|
||||
if(!isset($_POST['check']) && (isset($_POST['submit']) || isset($_POST['finish']))) {
|
||||
// Checks the current step is valid
|
||||
if(($step >= 2) && !is_dir($conf_folder))
|
||||
$step = 2;
|
||||
else if(($step >= 3) && !usersConfName())
|
||||
$step = 3;
|
||||
else if(($step >= 4) && !file_exists($conf_folder.'/main.xml'))
|
||||
$step = 4;
|
||||
else if(($step >= 5) && !file_exists($conf_folder.'/hosts.xml'))
|
||||
$step = 5;
|
||||
else
|
||||
$step++;
|
||||
}
|
||||
|
||||
// These steps are not available
|
||||
if(($step > 6) || !is_int($step))
|
||||
$step = 6;
|
||||
|
||||
// Get the current step title
|
||||
$names = array(
|
||||
T_("Welcome"),
|
||||
T_("Storage configuration"),
|
||||
T_("Administrator account"),
|
||||
T_("Main configuration"),
|
||||
T_("Hosts configuration"),
|
||||
T_("Services installation")
|
||||
);
|
||||
|
||||
// Continue marker
|
||||
$continue = true;
|
||||
|
||||
// Form action
|
||||
if($step < 6)
|
||||
$form_action = './?m=install'.keepGet('m', false);
|
||||
else
|
||||
$form_action = './'.keepGet('m', true);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<?php htmlTag($locale); ?>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="none" />
|
||||
<title><?php _e("Jappix installation"); ?> • <?php echo($names[$step - 1]); ?></title>
|
||||
<link rel="shortcut icon" href="./favicon.ico" />
|
||||
<?php echoGetFiles($hash, '', 'css', 'install.xml', ''); echo "\n"; ?>
|
||||
<!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
|
||||
</head>
|
||||
|
||||
<body class="body-images">
|
||||
<form id="install" method="post" action="<?php echo $form_action; ?>">
|
||||
<div id="install-top">
|
||||
<div class="logo install-images"><?php _e("Installation"); ?></div>
|
||||
<div class="step"><?php echo $step; ?> <span>/ 6</span></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<input type="hidden" name="step" value="<?php echo($step); ?>" />
|
||||
</div>
|
||||
|
||||
<div id="install-content">
|
||||
<?php
|
||||
|
||||
// First step: welcome
|
||||
if($step == 1) { ?>
|
||||
<h3 class="start install-images"><?php _e("Welcome to the Jappix installation!"); ?></h3>
|
||||
|
||||
<p><?php _e("This tool will help you fastly install Jappix, the first full-featured XMPP-based social platform, on your server. You don't even need any technical knowledge."); ?></p>
|
||||
<p><?php _e("Let's have a look at the installation steps:"); ?></p>
|
||||
|
||||
<ol>
|
||||
<li><?php _e("Welcome"); ?></li>
|
||||
<li><?php _e("Storage configuration"); ?></li>
|
||||
<li><?php _e("Administrator account"); ?></li>
|
||||
<li><?php _e("Main configuration"); ?></li>
|
||||
<li><?php _e("Hosts configuration"); ?></li>
|
||||
<li><?php _e("Services installation"); ?></li>
|
||||
</ol>
|
||||
|
||||
<p><?php printf(T_("If the current language does not match yours (%1s), you can make Jappix speak %2s it will be saved."), getLanguageName($locale), languageSwitcher($locale)); ?></p>
|
||||
|
||||
<p><?php _e("If you want to get some help about the Jappix installation and configuration, you can use our whole documentation, available at:"); ?> <a href="http://codingteam.net/project/jappix/doc" target="_blank">http://codingteam.net/project/jappix/doc</a></p>
|
||||
|
||||
<p><?php _e("It's time to build your own social cloud: just go to the next step!"); ?></p>
|
||||
<?php }
|
||||
|
||||
// Second step: storage configuration
|
||||
else if($step == 2) { ?>
|
||||
<h3 class="storage install-images"><?php _e("Storage configuration"); ?></h3>
|
||||
|
||||
<p><?php _e("Jappix stores persistent data (such as shared files, chat logs, your own music and its configuration) into a single secured storage folder."); ?></p>
|
||||
|
||||
<p><?php printf(T_("Jappix must be able to write in this folder to create its sub-directories. If not, you must set the rights to %1s or change the folder owner to %2s (depending of your configuration)."), '<em>777</em>', '<em>www-data</em>'); ?></p>
|
||||
|
||||
<?php if(is_writable(JAPPIX_BASE.'/store')) {
|
||||
// Create the store tree
|
||||
include(JAPPIX_BASE.'/php/store-tree.php');
|
||||
?>
|
||||
<p class="info bigspace success"><?php _e("The folder is writable, you can continue!"); ?></p>
|
||||
<?php }
|
||||
|
||||
else {
|
||||
$continue = false;
|
||||
?>
|
||||
<p class="info bigspace fail"><?php printf(T_("The folder is not writable, set the right permissions to the %s directory."), "<em>./store</em>"); ?></p>
|
||||
<?php } ?>
|
||||
<?php }
|
||||
|
||||
// Third step: administrator account
|
||||
else if($step == 3) { ?>
|
||||
<h3 class="account install-images"><?php _e("Administrator account"); ?></h3>
|
||||
|
||||
<p><?php _e("Jappix offers you the possibility to manage your configuration, install new plugins or search for updates. That's why you must create an administrator account to access the manager."); ?></p>
|
||||
|
||||
<p><?php _e("When Jappix will be installed, just click on the manager link on the home page to access it."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Include the user add form
|
||||
include(JAPPIX_BASE.'/php/form-users.php');
|
||||
|
||||
if(!$valid_user) { ?>
|
||||
<p class="info bigspace fail"><?php _e("Oops, you missed something or the two passwords do not match!"); ?></p>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Fourth step: main configuration
|
||||
else if($step == 4) { ?>
|
||||
<h3 class="main install-images"><?php _e("Main configuration"); ?></h3>
|
||||
|
||||
<p><?php _e("Jappix needs that you specify some values to work. Please correct the following inputs (or keep the default values, which are sufficient for most people)."); ?></p>
|
||||
|
||||
<p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Define the main configuration variables
|
||||
include(JAPPIX_BASE.'/php/vars-main.php');
|
||||
|
||||
// Are we using developer mode?
|
||||
if(preg_match('/~dev/i', $version))
|
||||
$developer = 'on';
|
||||
|
||||
// Include the main configuration form
|
||||
include(JAPPIX_BASE.'/php/form-main.php');
|
||||
}
|
||||
|
||||
// Fifth step: hosts configuration
|
||||
else if($step == 5) { ?>
|
||||
<h3 class="hosts install-images"><?php _e("Hosts configuration"); ?></h3>
|
||||
|
||||
<p><?php _e("This page helps you specify the default hosts Jappix will connect to. You can leave it as it is and continue if you want to use the official service hosts."); ?></p>
|
||||
|
||||
<p><?php _e("Maybe you don't know what a BOSH server is? In fact, this is a relay between a Jappix client and a XMPP server, which is necessary because of technical limitations."); ?></p>
|
||||
|
||||
<p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Define the hosts configuration variables
|
||||
include(JAPPIX_BASE.'/php/vars-hosts.php');
|
||||
|
||||
// Include the hosts configuration form
|
||||
include(JAPPIX_BASE.'/php/form-hosts.php');
|
||||
}
|
||||
|
||||
// Last step: services installation
|
||||
else if($step == 6) { ?>
|
||||
<h3 class="services install-images"><?php _e("Services installation"); ?></h3>
|
||||
|
||||
<p><?php _e("You can install some extra softwares on your server, to extend your Jappix features. Some others might be modified, because of security restrictions which are set by default."); ?></p>
|
||||
<p><?php _e("To perform this, you must be able to access your server's shell and be logged in as root. Remember this is facultative, Jappix will work without these modules, but some of its features will be unavailable."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Write the installed marker
|
||||
writeXML('conf', 'installed', '<installed>true</installed>');
|
||||
|
||||
// Checks some services are installed
|
||||
$services_functions = array('gd_info', 'curl_init');
|
||||
$services_names = array('GD', 'cURL');
|
||||
$services_packages = array('php5-gd', 'php5-curl');
|
||||
|
||||
for($i = 0; $i < count($services_names); $i++) {
|
||||
$service_class = 'info smallspace';
|
||||
|
||||
// First info?
|
||||
if($i == 0)
|
||||
$service_class .= ' first';
|
||||
|
||||
// Service installed?
|
||||
if(function_exists($services_functions[$i])) { ?>
|
||||
<p class="<?php echo($service_class) ?> success"><?php printf(T_("%s is installed on your system."), $services_names[$i]); ?></p>
|
||||
<?php }
|
||||
|
||||
// Missing service!
|
||||
else { ?>
|
||||
<p class="<?php echo($service_class) ?> fail"><?php printf(T_("%1s is not installed on your system, you should install %2s."), $services_names[$i], '<em>'.$services_packages[$i].'</em>'); ?></p>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Checks the upload size limit
|
||||
$upload_max = uploadMaxSize();
|
||||
$upload_human = formatBytes($upload_max);
|
||||
|
||||
if($upload_max >= 7000000) { ?>
|
||||
<p class="info smallspace last success"><?php printf(T_("PHP maximum upload size is sufficient (%s)."), $upload_human); ?></p>
|
||||
<?php }
|
||||
|
||||
else { ?>
|
||||
<p class="info smallspace last fail"><?php printf(T_("PHP maximum upload size is not sufficient (%1s), you should define it to %2s in %3s."), $upload_human, '8M', '<em>php.ini</em>'); ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<p><?php _e("After you finished the setup, Jappix will generate the cache files. It might be slow, just wait until the application is displayed and do not press any button."); ?></p>
|
||||
|
||||
<p><?php _e("Thanks for using Jappix!"); ?></p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div id="install-buttons">
|
||||
<?php if($continue && ($step < 6)) { ?>
|
||||
<input type="submit" name="submit" value="<?php _e("Next"); ?> »" />
|
||||
<?php } if($step == 6) { ?>
|
||||
<input type="submit" name="finish" value="<?php _e("Finish"); ?> »" />
|
||||
<?php } if(!$continue) { ?>
|
||||
<input type="submit" name="check" value="<?php _e("Check again"); ?>" />
|
||||
<?php } ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<!-- Jappix Install <?php echo $version; ?> - An open social platform -->
|
375
jappixmini/jappix/php/jsmin.php
Normal file
375
jappixmini/jappix/php/jsmin.php
Normal file
|
@ -0,0 +1,375 @@
|
|||
<?php
|
||||
/**
|
||||
* jsmin.php - PHP implementation of Douglas Crockford's JSMin.
|
||||
*
|
||||
* This is pretty much a direct port of jsmin.c to PHP with just a few
|
||||
* PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
|
||||
* outputs to stdout, this library accepts a string as input and returns another
|
||||
* string as output.
|
||||
*
|
||||
* PHP 5 or higher is required.
|
||||
*
|
||||
* Permission is hereby granted to use this version of the library under the
|
||||
* same terms as jsmin.c, which has the following license:
|
||||
*
|
||||
* --
|
||||
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* The Software shall be used for Good, not Evil.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
* --
|
||||
*
|
||||
* @package JSMin
|
||||
* @author Ryan Grove <ryan@wonko.com>
|
||||
* @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
|
||||
* @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 1.1.1 (2008-03-02)
|
||||
* @link https://github.com/rgrove/jsmin-php/
|
||||
*/
|
||||
|
||||
class JSMin {
|
||||
const ORD_LF = 10;
|
||||
const ORD_SPACE = 32;
|
||||
const ACTION_KEEP_A = 1;
|
||||
const ACTION_DELETE_A = 2;
|
||||
const ACTION_DELETE_A_B = 3;
|
||||
|
||||
protected $a = '';
|
||||
protected $b = '';
|
||||
protected $input = '';
|
||||
protected $inputIndex = 0;
|
||||
protected $inputLength = 0;
|
||||
protected $lookAhead = null;
|
||||
protected $output = '';
|
||||
|
||||
// -- Public Static Methods --------------------------------------------------
|
||||
|
||||
/**
|
||||
* Minify Javascript
|
||||
*
|
||||
* @uses __construct()
|
||||
* @uses min()
|
||||
* @param string $js Javascript to be minified
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($js) {
|
||||
$jsmin = new JSMin($js);
|
||||
return $jsmin->min();
|
||||
}
|
||||
|
||||
// -- Public Instance Methods ------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $input Javascript to be minified
|
||||
*/
|
||||
public function __construct($input) {
|
||||
$this->input = str_replace("\r\n", "\n", $input);
|
||||
$this->inputLength = strlen($this->input);
|
||||
}
|
||||
|
||||
// -- Protected Instance Methods ---------------------------------------------
|
||||
|
||||
/**
|
||||
* Action -- do something! What to do is determined by the $command argument.
|
||||
*
|
||||
* action treats a string as a single character. Wow!
|
||||
* action recognizes a regular expression if it is preceded by ( or , or =.
|
||||
*
|
||||
* @uses next()
|
||||
* @uses get()
|
||||
* @throws JSMinException If parser errors are found:
|
||||
* - Unterminated string literal
|
||||
* - Unterminated regular expression set in regex literal
|
||||
* - Unterminated regular expression literal
|
||||
* @param int $command One of class constants:
|
||||
* ACTION_KEEP_A Output A. Copy B to A. Get the next B.
|
||||
* ACTION_DELETE_A Copy B to A. Get the next B. (Delete A).
|
||||
* ACTION_DELETE_A_B Get the next B. (Delete B).
|
||||
*/
|
||||
protected function action($command) {
|
||||
switch($command) {
|
||||
case self::ACTION_KEEP_A:
|
||||
$this->output .= $this->a;
|
||||
|
||||
case self::ACTION_DELETE_A:
|
||||
$this->a = $this->b;
|
||||
|
||||
if ($this->a === "'" || $this->a === '"') {
|
||||
for (;;) {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
|
||||
if ($this->a === $this->b) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ord($this->a) <= self::ORD_LF) {
|
||||
throw new JSMinException('Unterminated string literal.');
|
||||
}
|
||||
|
||||
if ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case self::ACTION_DELETE_A_B:
|
||||
$this->b = $this->next();
|
||||
|
||||
if ($this->b === '/' && (
|
||||
$this->a === '(' || $this->a === ',' || $this->a === '=' ||
|
||||
$this->a === ':' || $this->a === '[' || $this->a === '!' ||
|
||||
$this->a === '&' || $this->a === '|' || $this->a === '?' ||
|
||||
$this->a === '{' || $this->a === '}' || $this->a === ';' ||
|
||||
$this->a === "\n" )) {
|
||||
|
||||
$this->output .= $this->a . $this->b;
|
||||
|
||||
for (;;) {
|
||||
$this->a = $this->get();
|
||||
|
||||
if ($this->a === '[') {
|
||||
/*
|
||||
inside a regex [...] set, which MAY contain a '/' itself. Example: mootools Form.Validator near line 460:
|
||||
return Form.Validator.getValidator('IsEmpty').test(element) || (/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]\.?){0,63}[a-z0-9!#$%&'*+/=?^_`{|}~-]@(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\])$/i).test(element.get('value'));
|
||||
*/
|
||||
for (;;) {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
|
||||
if ($this->a === ']') {
|
||||
break;
|
||||
} elseif ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
} elseif (ord($this->a) <= self::ORD_LF) {
|
||||
throw new JSMinException('Unterminated regular expression set in regex literal.');
|
||||
}
|
||||
}
|
||||
} elseif ($this->a === '/') {
|
||||
break;
|
||||
} elseif ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
} elseif (ord($this->a) <= self::ORD_LF) {
|
||||
throw new JSMinException('Unterminated regular expression literal.');
|
||||
}
|
||||
|
||||
$this->output .= $this->a;
|
||||
}
|
||||
|
||||
$this->b = $this->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next char. Convert ctrl char to space.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function get() {
|
||||
$c = $this->lookAhead;
|
||||
$this->lookAhead = null;
|
||||
|
||||
if ($c === null) {
|
||||
if ($this->inputIndex < $this->inputLength) {
|
||||
$c = substr($this->input, $this->inputIndex, 1);
|
||||
$this->inputIndex += 1;
|
||||
} else {
|
||||
$c = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($c === "\r") {
|
||||
return "\n";
|
||||
}
|
||||
|
||||
if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
|
||||
return $c;
|
||||
}
|
||||
|
||||
return ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is $c a letter, digit, underscore, dollar sign, or non-ASCII character.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isAlphaNum($c) {
|
||||
return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform minification, return result
|
||||
*
|
||||
* @uses action()
|
||||
* @uses isAlphaNum()
|
||||
* @return string
|
||||
*/
|
||||
protected function min() {
|
||||
$this->a = "\n";
|
||||
$this->action(self::ACTION_DELETE_A_B);
|
||||
|
||||
while ($this->a !== null) {
|
||||
switch ($this->a) {
|
||||
case ' ':
|
||||
if ($this->isAlphaNum($this->b)) {
|
||||
$this->action(self::ACTION_KEEP_A);
|
||||
} else {
|
||||
$this->action(self::ACTION_DELETE_A);
|
||||
}
|
||||
break;
|
||||
|
||||
case "\n":
|
||||
switch ($this->b) {
|
||||
case '{':
|
||||
case '[':
|
||||
case '(':
|
||||
case '+':
|
||||
case '-':
|
||||
$this->action(self::ACTION_KEEP_A);
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
$this->action(self::ACTION_DELETE_A_B);
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($this->isAlphaNum($this->b)) {
|
||||
$this->action(self::ACTION_KEEP_A);
|
||||
}
|
||||
else {
|
||||
$this->action(self::ACTION_DELETE_A);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
switch ($this->b) {
|
||||
case ' ':
|
||||
if ($this->isAlphaNum($this->a)) {
|
||||
$this->action(self::ACTION_KEEP_A);
|
||||
break;
|
||||
}
|
||||
|
||||
$this->action(self::ACTION_DELETE_A_B);
|
||||
break;
|
||||
|
||||
case "\n":
|
||||
switch ($this->a) {
|
||||
case '}':
|
||||
case ']':
|
||||
case ')':
|
||||
case '+':
|
||||
case '-':
|
||||
case '"':
|
||||
case "'":
|
||||
$this->action(self::ACTION_KEEP_A);
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($this->isAlphaNum($this->a)) {
|
||||
$this->action(self::ACTION_KEEP_A);
|
||||
}
|
||||
else {
|
||||
$this->action(self::ACTION_DELETE_A_B);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->action(self::ACTION_KEEP_A);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next character, skipping over comments. peek() is used to see
|
||||
* if a '/' is followed by a '/' or '*'.
|
||||
*
|
||||
* @uses get()
|
||||
* @uses peek()
|
||||
* @throws JSMinException On unterminated comment.
|
||||
* @return string
|
||||
*/
|
||||
protected function next() {
|
||||
$c = $this->get();
|
||||
|
||||
if ($c === '/') {
|
||||
switch($this->peek()) {
|
||||
case '/':
|
||||
for (;;) {
|
||||
$c = $this->get();
|
||||
|
||||
if (ord($c) <= self::ORD_LF) {
|
||||
return $c;
|
||||
}
|
||||
}
|
||||
|
||||
case '*':
|
||||
$this->get();
|
||||
|
||||
for (;;) {
|
||||
switch($this->get()) {
|
||||
case '*':
|
||||
if ($this->peek() === '/') {
|
||||
$this->get();
|
||||
return ' ';
|
||||
}
|
||||
break;
|
||||
|
||||
case null:
|
||||
throw new JSMinException('Unterminated comment.');
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return $c;
|
||||
}
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next char. If is ctrl character, translate to a space or newline.
|
||||
*
|
||||
* @uses get()
|
||||
* @return string|null
|
||||
*/
|
||||
protected function peek() {
|
||||
$this->lookAhead = $this->get();
|
||||
return $this->lookAhead;
|
||||
}
|
||||
}
|
||||
|
||||
// -- Exceptions ---------------------------------------------------------------
|
||||
class JSMinException extends Exception {}
|
||||
?>
|
839
jappixmini/jappix/php/manager.php
Normal file
839
jappixmini/jappix/php/manager.php
Normal file
|
@ -0,0 +1,839 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix Manager PHP/HTML code
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Get the manager functions
|
||||
require_once(JAPPIX_BASE.'/php/functions-manager.php');
|
||||
|
||||
// Session manager
|
||||
$id = 0;
|
||||
$login_fired = false;
|
||||
$logout_fired = false;
|
||||
$form_parent = 'manager';
|
||||
$user_password = '';
|
||||
$user_remember = '';
|
||||
$user = '';
|
||||
$password = '';
|
||||
$user_meta = T_("unknown");
|
||||
$user_name = '';
|
||||
$add_button = false;
|
||||
$remove_button = false;
|
||||
$save_button = false;
|
||||
$check_updates = false;
|
||||
|
||||
// Start the session
|
||||
session_start();
|
||||
|
||||
// Force the updates check?
|
||||
if(isset($_GET['p']) && ($_GET['p'] == 'check'))
|
||||
$check_updates = true;
|
||||
|
||||
// Login form is sent
|
||||
if(isset($_POST['login'])) {
|
||||
// Form sent pointer
|
||||
$login_fired = true;
|
||||
|
||||
// Extract the user name
|
||||
if(isset($_POST['admin_name']) && !empty($_POST['admin_name']))
|
||||
$user = trim($_POST['admin_name']);
|
||||
|
||||
if($user && (isset($_POST['admin_password']) && !empty($_POST['admin_password']))) {
|
||||
// Get the password values
|
||||
$password = genStrongHash(trim($_POST['admin_password']));
|
||||
|
||||
// Write the session
|
||||
$_SESSION['jappix_user'] = $user;
|
||||
$_SESSION['jappix_password'] = $password;
|
||||
}
|
||||
}
|
||||
|
||||
// Session is set
|
||||
else if((isset($_SESSION['jappix_user']) && !empty($_SESSION['jappix_user'])) && (isset($_SESSION['jappix_password']) && !empty($_SESSION['jappix_password']))) {
|
||||
// Form sent pointer
|
||||
$login_fired = true;
|
||||
|
||||
// Get the session values
|
||||
$user = $_SESSION['jappix_user'];
|
||||
$password = $_SESSION['jappix_password'];
|
||||
}
|
||||
|
||||
// Validate the current session
|
||||
if($login_fired && isAdmin($user, $password))
|
||||
$id = 1;
|
||||
|
||||
// Any special page requested (and authorized)?
|
||||
if(($id != 0) && isset($_GET['a']) && !empty($_GET['a'])) {
|
||||
// Extract the page name
|
||||
$page_requested = $_GET['a'];
|
||||
|
||||
switch($page_requested) {
|
||||
// Logout request
|
||||
case 'logout':
|
||||
// Remove the session
|
||||
unset($_SESSION['jappix_user']);
|
||||
unset($_SESSION['jappix_password']);
|
||||
|
||||
// Set a logout marker
|
||||
$logout_fired = true;
|
||||
|
||||
// Page ID
|
||||
$id = 0;
|
||||
|
||||
break;
|
||||
|
||||
// Configuration request
|
||||
case 'configuration':
|
||||
// Allowed buttons
|
||||
$save_button = true;
|
||||
|
||||
// Page ID
|
||||
$id = 2;
|
||||
|
||||
break;
|
||||
|
||||
// Hosts request
|
||||
case 'hosts':
|
||||
// Allowed buttons
|
||||
$save_button = true;
|
||||
|
||||
// Page ID
|
||||
$id = 3;
|
||||
|
||||
break;
|
||||
|
||||
// Storage request
|
||||
case 'storage':
|
||||
// Allowed buttons
|
||||
$remove_button = true;
|
||||
|
||||
// Page ID
|
||||
$id = 4;
|
||||
|
||||
break;
|
||||
|
||||
// Design request
|
||||
case 'design':
|
||||
// Allowed buttons
|
||||
$save_button = true;
|
||||
$remove_button = true;
|
||||
|
||||
// Page ID
|
||||
$id = 5;
|
||||
|
||||
break;
|
||||
|
||||
// Users request
|
||||
case 'users':
|
||||
// Allowed buttons
|
||||
$add_button = true;
|
||||
$remove_button = true;
|
||||
|
||||
// Page ID
|
||||
$id = 6;
|
||||
|
||||
break;
|
||||
|
||||
// Updates request
|
||||
case 'updates':
|
||||
// Page ID
|
||||
$id = 7;
|
||||
|
||||
break;
|
||||
|
||||
// Default page when authorized (statistics)
|
||||
default:
|
||||
// Page ID
|
||||
$id = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Page server-readable names
|
||||
$identifiers = array(
|
||||
'login',
|
||||
'statistics',
|
||||
'configuration',
|
||||
'hosts',
|
||||
'storage',
|
||||
'design',
|
||||
'users',
|
||||
'updates'
|
||||
);
|
||||
|
||||
// Page human-readable names
|
||||
$names = array(
|
||||
T_("Manager access"),
|
||||
T_("Statistics"),
|
||||
T_("Configuration"),
|
||||
T_("Hosts"),
|
||||
T_("Storage"),
|
||||
T_("Design"),
|
||||
T_("Users"),
|
||||
T_("Updates")
|
||||
);
|
||||
|
||||
// Any user for the meta?
|
||||
if($user && ($id != 0))
|
||||
$user_meta = $user;
|
||||
|
||||
// Define current page identifier & name
|
||||
$page_identifier = $identifiers[$id];
|
||||
$page_name = $names[$id];
|
||||
|
||||
// Define the current page form action
|
||||
if($id == 0)
|
||||
$form_action = keepGet('(m|a|p|k)', false);
|
||||
else
|
||||
$form_action = keepGet('(m|p|k)', false);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<?php htmlTag($locale); ?>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="none" />
|
||||
<title><?php _e("Jappix manager"); ?> • <?php echo($page_name); ?></title>
|
||||
<link rel="shortcut icon" href="./favicon.ico" />
|
||||
<?php echoGetFiles($hash, '', 'css', 'manager.xml', ''); echo "\n"; ?>
|
||||
<!--[if lt IE 9]><?php echoGetFiles($hash, '', 'css', '', 'ie.css'); ?><![endif]-->
|
||||
</head>
|
||||
|
||||
<body class="body-images">
|
||||
<form id="manager" enctype="multipart/form-data" method="post" action="./?m=manager<?php echo $form_action; ?>">
|
||||
<div id="manager-top">
|
||||
<div class="logo manager-images"><?php _e("Manager"); ?></div>
|
||||
|
||||
<div class="meta">
|
||||
<span><?php echo(htmlspecialchars($user_meta)); ?></span>
|
||||
|
||||
<?php if($id != 0) {
|
||||
|
||||
// Keep get
|
||||
$keep_get = keepGet('(a|p|b|s|k)', false);
|
||||
|
||||
?>
|
||||
<a class="logout manager-images" href="./?a=logout<?php echo $keep_get; ?>"><?php _e("Disconnect"); ?></a>
|
||||
<?php } ?>
|
||||
|
||||
<a class="close manager-images" href="./<?php echo keepGet('(m|a|p|b|s|k)', true); ?>"><?php _e("Close"); ?></a>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<?php if($id != 0) { ?>
|
||||
<div id="manager-tabs">
|
||||
<a<?php currentTab('statistics', $page_identifier); ?> href="./?a=statistics<?php echo $keep_get; ?>"><?php _e("Statistics"); ?></a>
|
||||
<a<?php currentTab('configuration', $page_identifier); ?> href="./?a=configuration<?php echo $keep_get; ?>"><?php _e("Configuration"); ?></a>
|
||||
<a<?php currentTab('hosts', $page_identifier); ?> href="./?a=hosts<?php echo $keep_get; ?>"><?php _e("Hosts"); ?></a>
|
||||
<a<?php currentTab('storage', $page_identifier); ?> href="./?a=storage<?php echo $keep_get; ?>"><?php _e("Storage"); ?></a>
|
||||
<a<?php currentTab('design', $page_identifier); ?> href="./?a=design<?php echo $keep_get; ?>"><?php _e("Design"); ?></a>
|
||||
<a<?php currentTab('users', $page_identifier); ?> href="./?a=users<?php echo $keep_get; ?>"><?php _e("Users"); ?></a>
|
||||
<a<?php currentTab('updates', $page_identifier); ?> class="last" href="./?a=updates<?php echo $keep_get; ?>"><?php _e("Updates"); ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div id="manager-content">
|
||||
<?php
|
||||
|
||||
if($id != 0) {
|
||||
if(!storageWritable()) { ?>
|
||||
<p class="info bottomspace fail"><?php _e("Your storage folders are not writable, please apply the good rights!"); ?></p>
|
||||
<?php }
|
||||
|
||||
if(BOSHProxy() && extension_loaded('suhosin') && (ini_get('suhosin.get.max_value_length') < 1000000)) { ?>
|
||||
<p class="info bottomspace neutral"><?php printf(T_("%1s may cause problems to the proxy, please increase %2s value up to %3s!"), 'Suhosin', '<em>suhosin.get.max_value_length</em>', '1000000'); ?></p>
|
||||
<?php }
|
||||
|
||||
if(newUpdates($check_updates)) { ?>
|
||||
<a class="info bottomspace neutral" href="./?a=updates<?php echo $keep_get; ?>"><?php _e("A new Jappix version is available! Check what is new and launch the update!"); ?></a>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Authorized and statistics page requested
|
||||
if($id == 1) { ?>
|
||||
<h3 class="statistics manager-images"><?php _e("Statistics"); ?></h3>
|
||||
|
||||
<p><?php _e("Basic statistics are processed by Jappix about some important things, you can find them below."); ?></p>
|
||||
|
||||
<h4><?php _e("Access statistics"); ?></h4>
|
||||
|
||||
<?php
|
||||
|
||||
// Read the visits values
|
||||
$visits = getVisits();
|
||||
|
||||
?>
|
||||
|
||||
<ul class="stats">
|
||||
<li class="total"><b><?php _e("Total"); ?></b><span><?php echo $visits['total']; ?></span></li>
|
||||
<li><b><?php _e("Daily"); ?></b><span><?php echo $visits['daily']; ?></span></li>
|
||||
<li><b><?php _e("Weekly"); ?></b><span><?php echo $visits['weekly']; ?></span></li>
|
||||
<li><b><?php _e("Monthly"); ?></b><span><?php echo $visits['monthly']; ?></span></li>
|
||||
<li><b><?php _e("Yearly"); ?></b><span><?php echo $visits['yearly']; ?></span></li>
|
||||
</ul>
|
||||
|
||||
<object class="stats" type="image/svg+xml" data="./php/stats-svg.php?l=<?php echo $locale; ?>&g=access"></object>
|
||||
|
||||
<?php
|
||||
|
||||
// Get the share stats
|
||||
$share_stats = shareStats();
|
||||
|
||||
// Any share stats to display?
|
||||
if(count($share_stats)) { ?>
|
||||
<h4><?php _e("Share statistics"); ?></h4>
|
||||
|
||||
<ol class="stats">
|
||||
<?php
|
||||
|
||||
// Display the users who have the largest share folder
|
||||
$share_users = largestShare($share_stats, 8);
|
||||
|
||||
foreach($share_users as $current_user => $current_value)
|
||||
echo('<li><b><a href="xmpp:'.$current_user.'">'.$current_user.'</a></b><span>'.formatBytes($current_value).'</span></li>');
|
||||
|
||||
?>
|
||||
</ol>
|
||||
|
||||
<object class="stats" type="image/svg+xml" data="./php/stats-svg.php?l=<?php echo $locale; ?>&g=share"></object>
|
||||
<?php } ?>
|
||||
|
||||
<h4><?php _e("Other statistics"); ?></h4>
|
||||
|
||||
<ul class="stats">
|
||||
<li class="total"><b><?php _e("Total"); ?></b><span><?php echo formatBytes(sizeDir(JAPPIX_BASE.'/store/')); ?></span></li>
|
||||
|
||||
<?php
|
||||
|
||||
// Append the human-readable array values
|
||||
$others_stats = otherStats();
|
||||
|
||||
foreach($others_stats as $others_name => $others_value)
|
||||
echo('<li><b>'.$others_name.'</b><span>'.formatBytes($others_value).'</span></li>');
|
||||
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<object class="stats" type="image/svg+xml" data="./php/stats-svg.php?l=<?php echo $locale; ?>&g=others"></object>
|
||||
<?php }
|
||||
|
||||
// Authorized and configuration page requested
|
||||
else if($id == 2) { ?>
|
||||
<h3 class="configuration manager-images"><?php _e("Configuration"); ?></h3>
|
||||
|
||||
<p><?php _e("Change your Jappix node configuration with this tool."); ?></p>
|
||||
|
||||
<p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Define the main configuration variables
|
||||
include(JAPPIX_BASE.'/php/vars-main.php');
|
||||
|
||||
// Read the main configuration POST
|
||||
if(isset($_POST['save'])) {
|
||||
include(JAPPIX_BASE.'/php/post-main.php');
|
||||
|
||||
// Show a success alert
|
||||
?>
|
||||
<p class="info smallspace success"><?php _e("Changes saved!"); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Include the main configuration form
|
||||
include(JAPPIX_BASE.'/php/form-main.php');
|
||||
}
|
||||
|
||||
// Authorized and hosts page requested
|
||||
else if($id == 3) { ?>
|
||||
<h3 class="hosts manager-images"><?php _e("Hosts"); ?></h3>
|
||||
|
||||
<p><?php _e("Change the XMPP hosts that this Jappix node serve with this tool."); ?></p>
|
||||
|
||||
<p><?php _e("Maybe you don't know what a BOSH server is? In fact, this is a relay between a Jappix client and a XMPP server, which is necessary because of technical limitations."); ?></p>
|
||||
|
||||
<p><?php _e("Note that if you don't specify a value which is compulsory, it will be automatically completed with the default one."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Define the hosts configuration variables
|
||||
include(JAPPIX_BASE.'/php/vars-hosts.php');
|
||||
|
||||
// Read the hosts configuration POST
|
||||
if(isset($_POST['save'])) {
|
||||
include(JAPPIX_BASE.'/php/post-hosts.php');
|
||||
|
||||
// Show a success alert
|
||||
?>
|
||||
<p class="info smallspace success"><?php _e("Changes saved!"); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Include the hosts configuration form
|
||||
include(JAPPIX_BASE.'/php/form-hosts.php');
|
||||
}
|
||||
|
||||
// Authorized and storage page requested
|
||||
else if($id == 4) { ?>
|
||||
<h3 class="storage manager-images"><?php _e("Storage"); ?></h3>
|
||||
|
||||
<p><?php _e("All this Jappix node stored files can be managed with this tool: please select a sub-folder and start editing its content!"); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Include the store configuration vars
|
||||
include(JAPPIX_BASE.'/php/vars-store.php');
|
||||
|
||||
// Include the store configuration POST handler
|
||||
include(JAPPIX_BASE.'/php/post-store.php');
|
||||
|
||||
// Include the store configuration GET handler
|
||||
include(JAPPIX_BASE.'/php/get-store.php');
|
||||
|
||||
?>
|
||||
|
||||
<h4><?php _e("Maintenance"); ?></h4>
|
||||
|
||||
<p><?php _e("Keep your Jappix node fresh and fast, clean the storage folders regularly!"); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Keep get
|
||||
$keep_get = keepGet('p', false);
|
||||
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<li class="total"><a href="./?p=everything<?php echo $keep_get; ?>"><?php _e("Clean everything"); ?></a></li>
|
||||
<li><a href="./?p=cache<?php echo $keep_get; ?>"><?php _e("Purge cache"); ?></a></li>
|
||||
<li><a href="./?p=logs<?php echo $keep_get; ?>"><?php _e("Purge logs"); ?></a></li>
|
||||
<li><a href="./?p=send<?php echo $keep_get; ?>"><?php _e("Purge sent files"); ?></a></li>
|
||||
<li><a href="./?p=updates<?php echo $keep_get; ?>"><?php _e("Purge updates"); ?></a></li>
|
||||
</ul>
|
||||
|
||||
<h4><?php _e("Share"); ?></h4>
|
||||
|
||||
<p><?php _e("Stay tuned in what your users store on your server and remove undesired content with this tool."); ?></p>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Browse"); ?></legend>
|
||||
|
||||
<div class="browse">
|
||||
<?php
|
||||
|
||||
// List the share files
|
||||
browseFolder($share_folder, 'share');
|
||||
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4><?php _e("Music"); ?></h4>
|
||||
|
||||
<p><?php _e("Upload your music (Ogg Vorbis, MP3 or WAV) to be able to listen to it in Jappix!"); ?></p>
|
||||
|
||||
<p><?php printf(T_("The file you want to upload must be smaller than %s."), formatBytes(uploadMaxSize()).''); ?></p>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("New"); ?></legend>
|
||||
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo(uploadMaxSize().''); ?>">
|
||||
|
||||
<label for="music_title"><?php _e("Title"); ?></label><input id="music_title" class="icon manager-images" type="text" name="music_title" value="<?php echo(htmlspecialchars($music_title)); ?>" />
|
||||
|
||||
<label for="music_artist"><?php _e("Artist"); ?></label><input id="music_artist" class="icon manager-images" type="text" name="music_artist" value="<?php echo(htmlspecialchars($music_artist)); ?>" />
|
||||
|
||||
<label for="music_album"><?php _e("Album"); ?></label><input id="music_album" class="icon manager-images" type="text" name="music_album" value="<?php echo(htmlspecialchars($music_album)); ?>" />
|
||||
|
||||
<label for="music_file"><?php _e("File"); ?></label><input id="music_file" type="file" name="music_file" accept="audio/*" />
|
||||
<label for="music_upload"><?php _e("Upload"); ?></label><input id="music_upload" type="submit" name="upload" value="<?php _e("Upload"); ?>" />
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Browse"); ?></legend>
|
||||
|
||||
<div class="browse">
|
||||
<?php
|
||||
|
||||
// List the music files
|
||||
browseFolder($music_folder, 'music');
|
||||
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php }
|
||||
|
||||
// Authorized and design page requested
|
||||
else if($id == 5) { ?>
|
||||
<h3 class="design manager-images"><?php _e("Design"); ?></h3>
|
||||
|
||||
<p><?php _e("Jappix is fully customisable: you can change its design right here."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Include the design configuration vars
|
||||
include(JAPPIX_BASE.'/php/vars-design.php');
|
||||
|
||||
// Include the design configuration POST handler
|
||||
include(JAPPIX_BASE.'/php/post-design.php');
|
||||
|
||||
// Include the design configuration reader
|
||||
include(JAPPIX_BASE.'/php/read-design.php');
|
||||
|
||||
// Folder view?
|
||||
if(isset($_GET['b']) && isset($_GET['s']) && ($_GET['b'] == 'backgrounds'))
|
||||
$backgrounds_folder = urldecode($_GET['s']);
|
||||
|
||||
?>
|
||||
|
||||
<h4><?php _e("Logo"); ?></h4>
|
||||
|
||||
<p><?php _e("You can set your own service logo to replace the default one. Take care of the size and the main color of each logo!"); ?></p>
|
||||
|
||||
<div class="sub">
|
||||
<p><?php _e("Upload each logo with the recommended maximum pixel size."); ?></p>
|
||||
<p><?php _e("Your logo format must be PNG. Leave a field empty and the logo will not be changed."); ?></p>
|
||||
|
||||
<label for="logo_own_1_location">Jappix Desktop, <em>311×113</em></label><?php logoFormField('1', 'desktop_home'); ?>
|
||||
<label for="logo_own_2_location">Jappix Desktop, <em>90×25</em></label><?php logoFormField('2', 'desktop_app'); ?>
|
||||
<label for="logo_own_3_location">Jappix Mobile, <em>83×30</em></label><?php logoFormField('3', 'mobile'); ?>
|
||||
<label for="logo_own_4_location">Jappix Mini, <em>81×22</em></label><?php logoFormField('4', 'mini'); ?>
|
||||
|
||||
<label for="logo_own_upload"><?php _e("Upload"); ?></label><input id="logo_own_upload" type="submit" name="logo_upload" value="<?php _e("Upload"); ?>" />
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<h4><?php _e("Background"); ?></h4>
|
||||
|
||||
<p><?php _e("Change your Jappix node background with this tool. You can either set a custom color or an uploaded image. Let your creativity flow!"); ?></p>
|
||||
|
||||
<label class="master" for="background_default"><input id="background_default" type="radio" name="background_type" value="default"<?php echo($background_default); ?> /><?php _e("Use default background"); ?></label>
|
||||
|
||||
<?php if($backgrounds_number) { ?>
|
||||
<label class="master" for="background_image"><input id="background_image" type="radio" name="background_type" value="image"<?php echo($background_image); ?> /><?php _e("Use your own image"); ?></label>
|
||||
|
||||
<div class="sub">
|
||||
<p><?php _e("Select a background to use and change the display options."); ?></p>
|
||||
|
||||
<label for="background_image_file"><?php _e("Image"); ?></label><select id="background_image_file" name="background_image_file">
|
||||
<?php
|
||||
|
||||
// List the background files
|
||||
foreach($backgrounds as $backgrounds_current) {
|
||||
// Check this is the selected background
|
||||
if($backgrounds_current == $background['image_file'])
|
||||
$backgrounds_selected = ' selected=""';
|
||||
else
|
||||
$backgrounds_selected = '';
|
||||
|
||||
// Encode the current background name
|
||||
$backgrounds_current = htmlspecialchars($backgrounds_current);
|
||||
|
||||
echo('<option value="'.$backgrounds_current.'"'.$backgrounds_selected.'>'.$backgrounds_current.'</option>');
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
|
||||
<label for="background_image_repeat"><?php _e("Repeat"); ?></label><select id="background_image_repeat" name="background_image_repeat">
|
||||
<option value="no-repeat"<?php echo($background_image_repeat_no); ?>><?php _e("No"); ?></option>
|
||||
<option value="repeat"<?php echo($background_image_repeat_all); ?>><?php _e("All"); ?></option>
|
||||
<option value="repeat-x"<?php echo($background_image_repeat_x); ?>><?php _e("Horizontal"); ?></option>
|
||||
<option value="repeat-y"<?php echo($background_image_repeat_y); ?>><?php _e("Vertical"); ?></option>
|
||||
</select>
|
||||
|
||||
<label for="background_image_horizontal"><?php _e("Horizontal"); ?></label><select id="background_image_horizontal" name="background_image_horizontal">
|
||||
<option value="center"<?php echo($background_image_horizontal_center); ?>><?php _e("Center"); ?></option>
|
||||
<option value="left"<?php echo($background_image_horizontal_left); ?>><?php _e("Left"); ?></option>
|
||||
<option value="right"<?php echo($background_image_horizontal_right); ?>><?php _e("Right"); ?></option>
|
||||
</select>
|
||||
|
||||
<label for="background_image_vertical"><?php _e("Vertical"); ?></label><select id="background_image_vertical" name="background_image_vertical">
|
||||
<option value="center"<?php echo($background_image_vertical_center); ?>><?php _e("Center"); ?></option>
|
||||
<option value="top"<?php echo($background_image_vertical_top); ?>><?php _e("Top"); ?></option>
|
||||
<option value="bottom"<?php echo($background_image_vertical_bottom); ?>><?php _e("Bottom"); ?></option>
|
||||
</select>
|
||||
|
||||
<label for="background_image_adapt"><?php _e("Adapt"); ?></label><input id="background_image_adapt" type="checkbox" name="background_image_adapt"<?php echo($background_image_adapt); ?> />
|
||||
|
||||
<label for="background_image_color"><?php _e("Color"); ?></label><input id="background_image_color" class="icon manager-images" type="color" name="background_image_color" value="<?php echo(htmlspecialchars($background['image_color'])); ?>" />
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<label class="master" for="background_color"><input id="background_color" type="radio" name="background_type" value="color"<?php echo($background_color); ?> /><?php _e("Use your own color"); ?></label>
|
||||
|
||||
<div class="sub">
|
||||
<p><?php _e("Type the hexadecimal color value you want to use as a background."); ?></p>
|
||||
|
||||
<label for="background_color_color"><?php _e("Color"); ?></label><input id="background_color_color" class="icon manager-images" type="color" name="background_color_color" value="<?php echo(htmlspecialchars($background['color_color'])); ?>" />
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<h4><?php _e("Manage backgrounds"); ?></h4>
|
||||
|
||||
<p><?php _e("You can add a new background to the list with this tool. Please send a valid image."); ?></p>
|
||||
|
||||
<div class="sub">
|
||||
<p><?php printf(T_("The file you want to upload must be smaller than %s."), formatBytes(uploadMaxSize()).''); ?></p>
|
||||
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo(uploadMaxSize().''); ?>">
|
||||
|
||||
<label for="background_image_location"><?php _e("File"); ?></label><input id="background_image_location" type="file" name="background_image_upload" accept="image/*" />
|
||||
<label for="background_image_upload"><?php _e("Upload"); ?></label><input id="background_image_upload" type="submit" name="background_upload" value="<?php _e("Upload"); ?>" />
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<p><?php _e("If you want to remove some backgrounds, use the browser below."); ?></p>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("List"); ?></legend>
|
||||
|
||||
<div class="browse">
|
||||
<?php
|
||||
|
||||
// List the background files
|
||||
browseFolder($backgrounds_folder, 'backgrounds');
|
||||
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4><?php _e("Notice"); ?></h4>
|
||||
|
||||
<p><?php _e("Define a homepage notice for all your users, such as a warn, an important message or an advert with this tool."); ?></p>
|
||||
|
||||
<label class="master" for="notice_none"><input id="notice_none" type="radio" name="notice_type" value="none"<?php echo($notice_none); ?> /><?php _e("None"); ?></label>
|
||||
|
||||
<label class="master" for="notice_simple"><input id="notice_simple" type="radio" name="notice_type" value="simple"<?php echo($notice_simple); ?> /><?php _e("Simple notice"); ?></label>
|
||||
|
||||
<div class="sub">
|
||||
<p><?php _e("This notice only needs simple text to be displayed, but no code is allowed!"); ?></p>
|
||||
</div>
|
||||
|
||||
<label class="master" for="notice_advanced"><input id="notice_advanced" type="radio" name="notice_type" value="advanced"<?php echo($notice_advanced); ?> /><?php _e("Advanced notice"); ?></label>
|
||||
|
||||
<div class="sub">
|
||||
<p><?php _e("You can customize your notice with embedded HTML, CSS and JavaScript, but you need to code the style."); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<textarea class="notice-text" name="notice_text" rows="8" cols="60"><?php echo(htmlspecialchars($notice_text)); ?></textarea>
|
||||
<?php }
|
||||
|
||||
// Authorized and users page requested
|
||||
else if($id == 6) { ?>
|
||||
<h3 class="users manager-images"><?php _e("Users"); ?></h3>
|
||||
|
||||
<p><?php _e("You can define more than one administrator for this Jappix node. You can also change a password with this tool."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Add an user?
|
||||
if(isset($_POST['add'])) {
|
||||
// Include the users POST handler
|
||||
include(JAPPIX_BASE.'/php/post-users.php');
|
||||
|
||||
if($valid_user) { ?>
|
||||
<p class="info smallspace success"><?php _e("The user has been added!"); ?></p>
|
||||
<?php }
|
||||
|
||||
else { ?>
|
||||
<p class="info smallspace fail"><?php _e("Oops, you missed something or the two passwords do not match!"); ?></p>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Remove an user?
|
||||
else if(isset($_POST['remove'])) {
|
||||
// Initialize the match
|
||||
$users_removed = false;
|
||||
$users_remove = array();
|
||||
|
||||
// Try to get the users to remove
|
||||
foreach($_POST as $post_key => $post_value) {
|
||||
// Is it an admin user?
|
||||
if(preg_match('/^admin_(.+)$/i', $post_key)) {
|
||||
// Update the marker
|
||||
$users_removed = true;
|
||||
|
||||
// Push the value to the global array
|
||||
array_push($users_remove, $post_value);
|
||||
}
|
||||
}
|
||||
|
||||
// Somebody has been removed
|
||||
if($users_removed) {
|
||||
|
||||
// Remove the users!
|
||||
manageUsers('remove', $users_remove);
|
||||
|
||||
?>
|
||||
<p class="info smallspace success"><?php _e("The chosen users have been removed."); ?></p>
|
||||
<?php }
|
||||
|
||||
// Nobody has been removed
|
||||
else { ?>
|
||||
<p class="info smallspace fail"><?php _e("You must select one or more users to be removed!"); ?></p>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
<h4><?php _e("Add"); ?></h4>
|
||||
|
||||
<p><?php _e("Add a new user with this tool, or change a password (type an existing username). Please submit a strong password!"); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Include the user add form
|
||||
include(JAPPIX_BASE.'/php/form-users.php');
|
||||
|
||||
?>
|
||||
|
||||
<h4><?php _e("Manage"); ?></h4>
|
||||
|
||||
<p><?php _e("Remove users with this tool. Note that you cannot remove an user if he is the only one remaining."); ?></p>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("List"); ?></legend>
|
||||
|
||||
<div class="browse">
|
||||
<?php
|
||||
|
||||
// List the users
|
||||
browseUsers();
|
||||
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php }
|
||||
|
||||
// Authorized and updates page requested
|
||||
else if($id == 7) { ?>
|
||||
<h3 class="updates manager-images"><?php _e("Updates"); ?></h3>
|
||||
|
||||
<p><?php _e("Update your Jappix node with this tool, or check if a new one is available. Informations about the latest version are also displayed (in english)."); ?></p>
|
||||
|
||||
<?php
|
||||
|
||||
// Using developer mode (no need to update)?
|
||||
if(isDeveloper()) { ?>
|
||||
<h4><?php _e("Check for updates"); ?></h4>
|
||||
|
||||
<p class="info smallspace neutral"><?php printf(T_("You are using a development version of Jappix. Update it through our repository by executing: %s."), '<em>svn up</em>'); ?></p>
|
||||
<?php }
|
||||
|
||||
// New updates available?
|
||||
else if(newUpdates($check_updates)) {
|
||||
// Get the update informations
|
||||
$update_infos = updateInformations();
|
||||
|
||||
// We can launch the update!
|
||||
if(isset($_GET['p']) && ($_GET['p'] == 'update')) { ?>
|
||||
<h4><?php _e("Update in progress"); ?></h4>
|
||||
|
||||
<?php if(processUpdate($update_infos['url'])) { ?>
|
||||
<p class="info smallspace success"><?php _e("Jappix has been updated: you are now running the latest version. Have fun!"); ?></p>
|
||||
<?php } else { ?>
|
||||
<p class="info smallspace fail"><?php _e("The update has failed! Please try again later."); ?></p>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// We just show a notice
|
||||
else {
|
||||
?>
|
||||
<h4><?php _e("Available updates"); ?></h4>
|
||||
|
||||
<a class="info smallspace fail" href="./?p=update<?php echo keepGet('(p|b|s)', false); ?>"><?php printf(T_("Your version is out to date. Update it now to %s by clicking here!"), '<em>'.$update_infos['id'].'</em>'); ?></a>
|
||||
|
||||
<h4><?php _e("What's new?"); ?></h4>
|
||||
|
||||
<div><?php echo $update_infos['description']; ?></div>
|
||||
<?php }
|
||||
|
||||
// No new update
|
||||
} else { ?>
|
||||
<h4><?php _e("Check for updates"); ?></h4>
|
||||
|
||||
<a class="info smallspace success" href="./?p=check<?php echo keepGet('(p|b|s)', false); ?>"><?php _e("Your version seems to be up to date, but you can check updates manually by clicking here."); ?></a>
|
||||
<?php } ?>
|
||||
<?php }
|
||||
|
||||
// Not authorized, show the login form
|
||||
else { ?>
|
||||
<h3 class="login manager-images"><?php _e("Manager access"); ?></h3>
|
||||
|
||||
<p><?php _e("This is a restricted area: only the authorized users can manage this Jappix node."); ?></p>
|
||||
<p><?php _e("Please use the form below to login to the administration panel."); ?></p>
|
||||
<p><?php _e("To improve security, sessions are limited in time and when your browser will be closed, you will be logged out."); ?></p>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e("Credentials"); ?></legend>
|
||||
|
||||
<label for="admin_name"><?php _e("User"); ?></label><input id="admin_name" class="icon manager-images" type="text" name="admin_name" value="<?php echo(htmlspecialchars($user)); ?>" required="" />
|
||||
|
||||
<label for="admin_password"><?php _e("Password"); ?></label><input id="admin_password" class="icon manager-images" type="password" name="admin_password" required="" />
|
||||
</fieldset>
|
||||
|
||||
<?php
|
||||
|
||||
// Disconnected
|
||||
if($logout_fired) { ?>
|
||||
<p class="info bigspace success"><?php _e("You have been logged out. Goodbye!"); ?></p>
|
||||
<?php }
|
||||
|
||||
// Login error
|
||||
else if($login_fired) { ?>
|
||||
<p class="info bigspace fail"><?php _e("Oops, you could not be recognized as a valid administrator. Check your credentials!"); ?></p>
|
||||
<?php
|
||||
|
||||
// Remove the session
|
||||
unset($_SESSION['jappix_user']);
|
||||
unset($_SESSION['jappix_password']);
|
||||
|
||||
}
|
||||
} ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<div id="manager-buttons">
|
||||
<?php if($id == 0) { ?>
|
||||
<input type="submit" name="login" value="<?php _e("Here we go!"); ?>" />
|
||||
<?php } else { ?>
|
||||
<?php } if($add_button) { ?>
|
||||
<input type="submit" name="add" value="<?php _e("Add"); ?>" />
|
||||
<?php } if($save_button) { ?>
|
||||
<input type="submit" name="save" value="<?php _e("Save"); ?>" />
|
||||
<?php } if($remove_button) { ?>
|
||||
<input type="submit" name="remove" value="<?php _e("Remove"); ?>" />
|
||||
<?php } ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<!-- Jappix Manager <?php echo $version; ?> - An open social platform -->
|
100
jappixmini/jappix/php/mobile-detect.php
Normal file
100
jappixmini/jappix/php/mobile-detect.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Mobile Detect
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
* @version SVN: $Id: Mobile_Detect.php 3 2009-05-21 13:06:28Z vic.stanciu $
|
||||
*/
|
||||
|
||||
/**
|
||||
* MODIFIED FOR THE JAPPIX PROJECT
|
||||
* Last revision: 20/11/10
|
||||
*
|
||||
* Thanks to LinkMauve for his patch!
|
||||
*/
|
||||
|
||||
class Mobile_Detect {
|
||||
|
||||
protected $accept;
|
||||
protected $userAgent;
|
||||
|
||||
protected $isMobile = false;
|
||||
protected $isAndroid = null;
|
||||
protected $isIphone = null;
|
||||
protected $isBlackberry = null;
|
||||
protected $isOpera = null;
|
||||
protected $isPalm = null;
|
||||
protected $isWindows = null;
|
||||
protected $isGeneric = null;
|
||||
|
||||
protected $devices = array(
|
||||
"android" => "android",
|
||||
"blackberry" => "blackberry",
|
||||
"iphone" => "(iphone|ipod)",
|
||||
"opera" => "opera mini",
|
||||
"palm" => "(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)",
|
||||
"windows" => "windows ce; (iemobile|ppc|smartphone)",
|
||||
"generic" => "(kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap)"
|
||||
);
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$this->userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
|
||||
if (isset($_SERVER['HTTP_ACCEPT']))
|
||||
$this->accept = $_SERVER['HTTP_ACCEPT'];
|
||||
else
|
||||
$this->accept = '';
|
||||
|
||||
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])|| isset($_SERVER['HTTP_PROFILE'])) {
|
||||
$this->isMobile = true;
|
||||
} elseif (strpos($this->accept,'text/vnd.wap.wml') > 0 || strpos($this->accept,'application/vnd.wap.xhtml+xml') > 0) {
|
||||
$this->isMobile = true;
|
||||
} else {
|
||||
foreach ($this->devices as $device => $regexp) {
|
||||
if ($this->isDevice($device)) {
|
||||
$this->isMobile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overloads isAndroid() | isBlackberry() | isOpera() | isPalm() | isWindows() | isGeneric() through isDevice()
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$device = substr($name, 2);
|
||||
if ($name == "is" . ucfirst($device)) {
|
||||
return $this->isDevice($device);
|
||||
} else {
|
||||
trigger_error("Method $name not defined", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if any type of mobile device detected, including special ones
|
||||
* @return bool
|
||||
*/
|
||||
public function isMobile() {
|
||||
return $this->isMobile;
|
||||
}
|
||||
|
||||
|
||||
protected function isDevice($device) {
|
||||
$var = "is" . ucfirst($device);
|
||||
$return = $this->$var === null ? (bool) preg_match("/" . $this->devices[$device] . "/i", $this->userAgent) : $this->$var;
|
||||
|
||||
if ($device != 'generic' && $return == true) {
|
||||
$this->isGeneric = false;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
73
jappixmini/jappix/php/mobile.php
Normal file
73
jappixmini/jappix/php/mobile.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix Mobile PHP/HTML code
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 10/07/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<?php htmlTag($locale); ?>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport">
|
||||
<title><?php _e("Jappix Mobile"); ?></title>
|
||||
<link rel="shortcut icon" href="./favicon.ico" />
|
||||
<?php echoGetFiles($hash, '', 'css', 'mobile.xml', ''); echo "\n"; ?>
|
||||
<?php echoGetFiles($hash, $locale, 'js', 'mobile.xml', ''); echo "\n"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="home">
|
||||
<div class="header">
|
||||
<div class="mobile-images"></div>
|
||||
</div>
|
||||
|
||||
<noscript>
|
||||
<div class="notification" id="noscript">
|
||||
<?php _e("Please enable JavaScript"); ?>
|
||||
</div>
|
||||
</noscript>
|
||||
|
||||
<div class="notification" id="error">
|
||||
<?php _e("Error"); ?>
|
||||
</div>
|
||||
|
||||
<div class="notification" id="info">
|
||||
<?php _e("Please wait..."); ?>
|
||||
</div>
|
||||
|
||||
<div class="login">
|
||||
<?php _e("Login"); ?>
|
||||
|
||||
<form action="#" method="post" onsubmit="return doLogin(this);">
|
||||
<input class="xid mobile-images" type="text" name="xid" required="" />
|
||||
<input class="password mobile-images" type="password" id="pwd" name="pwd" required="" />
|
||||
<?php if(REGISTRATION != 'off') { ?>
|
||||
<label><input class="register" type="checkbox" id="reg" name="reg" /><?php _e("Register"); ?></label>
|
||||
<?php } ?>
|
||||
<input type="submit" name="ok" value="<?php _e("Here we go!"); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<a href="./?m=desktop<?php echo keepGet('m', false); ?>"><?php _e("Desktop"); ?></a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<!-- Jappix Mobile <?php echo $version; ?> - An open social platform -->
|
103
jappixmini/jappix/php/music-search.php
Normal file
103
jappixmini/jappix/php/music-search.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix music search script
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 15/01/12
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed for a special node
|
||||
if(isStatic() || isUpload())
|
||||
exit;
|
||||
|
||||
// If valid data was sent
|
||||
if((isset($_GET['searchquery']) && !empty($_GET['searchquery'])) && (isset($_GET['location']) && !empty($_GET['location']))) {
|
||||
// Set a XML header
|
||||
header('Content-Type: text/xml; charset=utf-8');
|
||||
|
||||
// Get the values
|
||||
$searchquery = $_GET['searchquery'];
|
||||
$location = $_GET['location'];
|
||||
|
||||
// Jamendo search?
|
||||
if($location == 'jamendo')
|
||||
exit(read_url('http://api.jamendo.com/get2/name+id+duration+url/track/xml/?searchquery='.urlencode($searchquery).'&order=searchweight_desc'));
|
||||
|
||||
// Local music search
|
||||
$xml = '<data>';
|
||||
$searchquery = strtolower($searchquery);
|
||||
|
||||
// Escape the regex special characters
|
||||
$searchquery = escapeRegex($searchquery);
|
||||
|
||||
// Search in the directory
|
||||
$repertory = '../store/music/';
|
||||
$scan = scandir($repertory);
|
||||
|
||||
foreach($scan as $current) {
|
||||
// This file match our query!
|
||||
if(is_file($repertory.$current) && $current && preg_match('/(^|\s|\[)('.$searchquery.')(.+)?(\.(og(g|a)|mp3|wav))$/i', strtolower($current))) {
|
||||
// Get the basic informations
|
||||
$title = preg_replace('/^(.+)(\.)(og(g|a)|mp3|wav)$/i', '$1', $current);
|
||||
$url = $location.'store/music/'.$current;
|
||||
$ext = getFileExt($current);
|
||||
$id = md5($url);
|
||||
|
||||
// Get the MIME type
|
||||
if($ext == 'mp3')
|
||||
$type = 'audio/mpeg';
|
||||
else if($ext == 'wav')
|
||||
$type = 'audio/x-wav';
|
||||
else
|
||||
$type = 'audio/ogg';
|
||||
|
||||
// Get the advanced informations
|
||||
$locked_title = $title;
|
||||
$artist = '';
|
||||
$source = '';
|
||||
|
||||
$title_regex = '/^(([^-]+) - )?([^\[]+)( \[(.+))?$/i';
|
||||
$artist_regex = '/^(.+) - (.+)$/i';
|
||||
$source_regex = '/^(.+) \[(.+)\]$/i';
|
||||
|
||||
if(preg_match($title_regex, $locked_title))
|
||||
$title = preg_replace($title_regex, '$3', $locked_title);
|
||||
|
||||
if(preg_match($artist_regex, $locked_title))
|
||||
$artist = preg_replace($artist_regex, '$1', $locked_title);
|
||||
|
||||
if(preg_match($source_regex, $locked_title))
|
||||
$source = preg_replace($source_regex, '$2', $locked_title);
|
||||
|
||||
// Generate the XML
|
||||
$xml .= '<data><track><name>'.htmlspecialchars($title).'</name><artist>'.htmlspecialchars($artist).'</artist><source>'.htmlspecialchars($source).'</source><id>'.htmlspecialchars($id).'</id><url>'.htmlspecialchars($url).'</url><type>'.$type.'</type></track></data>';
|
||||
}
|
||||
}
|
||||
|
||||
// End
|
||||
$xml .= '</data>';
|
||||
|
||||
// Return the path to the file
|
||||
exit($xml);
|
||||
}
|
||||
|
||||
?>
|
215
jappixmini/jappix/php/post-design.php
Normal file
215
jappixmini/jappix/php/post-design.php
Normal file
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the design configuration POST handler (manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 25/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Handle the remove GET
|
||||
if(isset($_GET['k']) && !empty($_GET['k'])) {
|
||||
$kill_logo = JAPPIX_BASE.'/store/logos/'.$_GET['k'].'.png';
|
||||
|
||||
if(isSafe($kill_logo) && file_exists($kill_logo)) {
|
||||
unlink($kill_logo);
|
||||
|
||||
echo('<p class="info smallspace success">'.T_("The selected elements have been removed.").'</p>');
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the remove POST
|
||||
else if(isset($_POST['remove']))
|
||||
removeElements();
|
||||
|
||||
// Handle the logo upload POST
|
||||
else if(isset($_POST['logo_upload'])) {
|
||||
// Avoid errors
|
||||
$logos_arr_1_name = $logos_arr_1_tmp = $logos_arr_2_name = $logos_arr_2_tmp = $logos_arr_3_name = $logos_arr_3_tmp = $logos_arr_4_name = $logos_arr_4_tmp = '';
|
||||
|
||||
if(isset($_FILES['logo_own_1_location'])) {
|
||||
$logos_arr_1_name = $_FILES['logo_own_1_location']['name'];
|
||||
$logos_arr_1_tmp = $_FILES['logo_own_1_location']['tmp_name'];
|
||||
}
|
||||
|
||||
if(isset($_FILES['logo_own_2_location'])) {
|
||||
$logos_arr_2_name = $_FILES['logo_own_2_location']['name'];
|
||||
$logos_arr_2_tmp = $_FILES['logo_own_2_location']['tmp_name'];
|
||||
}
|
||||
|
||||
if(isset($_FILES['logo_own_3_location'])) {
|
||||
$logos_arr_3_name = $_FILES['logo_own_3_location']['name'];
|
||||
$logos_arr_3_tmp = $_FILES['logo_own_3_location']['tmp_name'];
|
||||
}
|
||||
|
||||
if(isset($_FILES['logo_own_4_location'])) {
|
||||
$logos_arr_4_name = $_FILES['logo_own_4_location']['name'];
|
||||
$logos_arr_4_tmp = $_FILES['logo_own_4_location']['tmp_name'];
|
||||
}
|
||||
|
||||
// File infos array
|
||||
$logos = array(
|
||||
array($logos_arr_1_name, $logos_arr_1_tmp, JAPPIX_BASE.'/store/logos/desktop_home.png'),
|
||||
array($logos_arr_2_name, $logos_arr_2_tmp, JAPPIX_BASE.'/store/logos/desktop_app.png'),
|
||||
array($logos_arr_3_name, $logos_arr_3_tmp, JAPPIX_BASE.'/store/logos/mobile.png'),
|
||||
array($logos_arr_4_name, $logos_arr_4_tmp, JAPPIX_BASE.'/store/logos/mini.png')
|
||||
);
|
||||
|
||||
// Check for errors
|
||||
$logo_error = false;
|
||||
$logo_not_png = false;
|
||||
$logo_anything = false;
|
||||
|
||||
foreach($logos as $sub_array) {
|
||||
// Nothing?
|
||||
if(!$sub_array[0] || !$sub_array[1])
|
||||
continue;
|
||||
|
||||
// Not an image?
|
||||
if(getFileExt($sub_array[0]) != 'png') {
|
||||
$logo_not_png = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Upload error?
|
||||
if(!move_uploaded_file($sub_array[1], $sub_array[2])) {
|
||||
$logo_error = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$logo_anything = true;
|
||||
}
|
||||
|
||||
// Not an image?
|
||||
if($logo_not_png) { ?>
|
||||
<p class="info smallspace fail"><?php _e("This is not a valid image, please use the PNG format!"); ?></p>
|
||||
<?php }
|
||||
|
||||
// Upload error?
|
||||
else if($logo_error || !$logo_anything) { ?>
|
||||
<p class="info smallspace fail"><?php _e("The image could not be received, would you mind retry?"); ?></p>
|
||||
<?php }
|
||||
|
||||
// Everything went fine
|
||||
else { ?>
|
||||
<p class="info smallspace success"><?php _e("Your service logo has been successfully changed!"); ?></p>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Handle the background upload POST
|
||||
else if(isset($_POST['background_upload'])) {
|
||||
// Get the file path
|
||||
$name_background_image = $_FILES['background_image_upload']['name'];
|
||||
$temp_background_image = $_FILES['background_image_upload']['tmp_name'];
|
||||
$path_background_image = JAPPIX_BASE.'/store/backgrounds/'.$name_background_image;
|
||||
|
||||
// An error occured?
|
||||
if(!isSafe($name_background_image) || $_FILES['background_image_upload']['error'] || !move_uploaded_file($temp_background_image, $path_background_image)) { ?>
|
||||
|
||||
<p class="info smallspace fail"><?php _e("The image could not be received, would you mind retry?"); ?></p>
|
||||
|
||||
<?php }
|
||||
|
||||
// Bad extension?
|
||||
else if(!isImage($name_background_image)) {
|
||||
// Remove the image file
|
||||
if(file_exists($path_background_image))
|
||||
unlink($path_background_image);
|
||||
?>
|
||||
|
||||
<p class="info smallspace fail"><?php _e("This is not a valid image, please use PNG, GIF or JPG!"); ?></p>
|
||||
|
||||
<?php }
|
||||
|
||||
// The file has been sent
|
||||
else { ?>
|
||||
|
||||
<p class="info smallspace success"><?php _e("Your image was added to the list!"); ?></p>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Handle the save POST
|
||||
else if(isset($_POST['save'])) {
|
||||
// Marker
|
||||
$save_marker = true;
|
||||
|
||||
// Handle it for background
|
||||
$background = array();
|
||||
|
||||
if(isset($_POST['background_type']))
|
||||
$background['type'] = $_POST['background_type'];
|
||||
|
||||
if(isset($_POST['background_image_file']))
|
||||
$background['image_file'] = $_POST['background_image_file'];
|
||||
|
||||
if(isset($_POST['background_image_repeat']))
|
||||
$background['image_repeat'] = $_POST['background_image_repeat'];
|
||||
|
||||
if(isset($_POST['background_image_horizontal']))
|
||||
$background['image_horizontal'] = $_POST['background_image_horizontal'];
|
||||
|
||||
if(isset($_POST['background_image_vertical']))
|
||||
$background['image_vertical'] = $_POST['background_image_vertical'];
|
||||
|
||||
if(isset($_POST['background_image_adapt']))
|
||||
$background['image_adapt'] = 'on';
|
||||
|
||||
if(isset($_POST['background_image_color']))
|
||||
$background['image_color'] = $_POST['background_image_color'];
|
||||
|
||||
if(isset($_POST['background_color_color']))
|
||||
$background['color_color'] = $_POST['background_color_color'];
|
||||
|
||||
// Write the configuration file
|
||||
writeBackground($background);
|
||||
|
||||
// Handle it for notice
|
||||
if(isset($_POST['notice_type']))
|
||||
$notice_type = $_POST['notice_type'];
|
||||
else
|
||||
$notice_type = 'none';
|
||||
|
||||
$notice_text = '';
|
||||
|
||||
if(isset($_POST['notice_text']))
|
||||
$notice_text = $_POST['notice_text'];
|
||||
|
||||
// Check our values
|
||||
if(!$notice_text && ($notice_type != 'none'))
|
||||
$save_marker = false;
|
||||
|
||||
// All is okay
|
||||
if($save_marker) {
|
||||
// Write the notice configuration
|
||||
writeNotice($notice_type, $notice_text);
|
||||
|
||||
// Show a success notice
|
||||
?>
|
||||
|
||||
<p class="info smallspace success"><?php _e("Your design preferences have been saved!"); ?></p>
|
||||
|
||||
<?php }
|
||||
|
||||
// Something went wrong
|
||||
else { ?>
|
||||
|
||||
<p class="info smallspace fail"><?php _e("Please check your inputs: something is missing!"); ?></p>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
95
jappixmini/jappix/php/post-hosts.php
Normal file
95
jappixmini/jappix/php/post-hosts.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the hosts configuration POST handler (install & manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 27/05/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Main host
|
||||
if(isset($_POST['host_main']) && !empty($_POST['host_main']))
|
||||
$host_main = stripslashes(htmlspecialchars($_POST['host_main']));
|
||||
else
|
||||
$host_main = stripslashes(htmlspecialchars($hosts_default['main']));
|
||||
|
||||
// Groupchat host
|
||||
if(isset($_POST['host_muc']) && !empty($_POST['host_muc']))
|
||||
$host_muc = stripslashes(htmlspecialchars($_POST['host_muc']));
|
||||
else
|
||||
$host_muc = stripslashes(htmlspecialchars($hosts_default['muc']));
|
||||
|
||||
// Pubsub host
|
||||
if(isset($_POST['host_pubsub']) && !empty($_POST['host_pubsub']))
|
||||
$host_pubsub = stripslashes(htmlspecialchars($_POST['host_pubsub']));
|
||||
else
|
||||
$host_pubsub = stripslashes(htmlspecialchars($hosts_default['pubsub']));
|
||||
|
||||
// Directory host
|
||||
if(isset($_POST['host_vjud']) && !empty($_POST['host_vjud']))
|
||||
$host_vjud = stripslashes(htmlspecialchars($_POST['host_vjud']));
|
||||
else
|
||||
$host_vjud = stripslashes(htmlspecialchars($hosts_default['vjud']));
|
||||
|
||||
// Anonymous host
|
||||
if(isset($_POST['host_anonymous']) && !empty($_POST['host_anonymous']))
|
||||
$host_anonymous = stripslashes(htmlspecialchars($_POST['host_anonymous']));
|
||||
else
|
||||
$host_anonymous = stripslashes(htmlspecialchars($hosts_default['anonymous']));
|
||||
|
||||
// BOSH host
|
||||
if(isset($_POST['host_bosh']) && !empty($_POST['host_bosh']))
|
||||
$host_bosh = stripslashes(htmlspecialchars($_POST['host_bosh']));
|
||||
else
|
||||
$host_bosh = stripslashes(htmlspecialchars($hosts_default['bosh']));
|
||||
|
||||
// Main BOSH host
|
||||
if(isset($_POST['host_bosh_main']) && !empty($_POST['host_bosh_main']))
|
||||
$host_bosh_main = stripslashes(htmlspecialchars($_POST['host_bosh_main']));
|
||||
else
|
||||
$host_bosh_main = stripslashes(htmlspecialchars($hosts_default['bosh_main']));
|
||||
|
||||
// Mini BOSH host
|
||||
if(isset($_POST['host_bosh_mini']) && !empty($_POST['host_bosh_mini']))
|
||||
$host_bosh_mini = stripslashes(htmlspecialchars($_POST['host_bosh_mini']));
|
||||
else
|
||||
$host_bosh_mini = stripslashes(htmlspecialchars($hosts_default['bosh_mini']));
|
||||
|
||||
// Static host
|
||||
if(isset($_POST['host_static']) && !empty($_POST['host_static']))
|
||||
$host_static = stripslashes(htmlspecialchars($_POST['host_static']));
|
||||
else
|
||||
$host_static = stripslashes(htmlspecialchars($hosts_default['static']));
|
||||
|
||||
// Upload host
|
||||
if(isset($_POST['host_upload']) && !empty($_POST['host_upload']))
|
||||
$host_upload = stripslashes(htmlspecialchars($_POST['host_upload']));
|
||||
else
|
||||
$host_upload = stripslashes(htmlspecialchars($hosts_default['upload']));
|
||||
|
||||
// Generate the hosts XML content
|
||||
$hosts_xml =
|
||||
'<main>'.$host_main.'</main>
|
||||
<muc>'.$host_muc.'</muc>
|
||||
<pubsub>'.$host_pubsub.'</pubsub>
|
||||
<vjud>'.$host_vjud.'</vjud>
|
||||
<anonymous>'.$host_anonymous.'</anonymous>
|
||||
<bosh>'.$host_bosh.'</bosh>
|
||||
<bosh_main>'.$host_bosh_main.'</bosh_main>
|
||||
<bosh_mini>'.$host_bosh_mini.'</bosh_mini>
|
||||
<static>'.$host_static.'</static>
|
||||
<upload>'.$host_upload.'</upload>'
|
||||
;
|
||||
|
||||
// Write the main configuration
|
||||
writeXML('conf', 'hosts', $hosts_xml);
|
130
jappixmini/jappix/php/post-main.php
Normal file
130
jappixmini/jappix/php/post-main.php
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the main configuration POST handler (install & manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Service name
|
||||
if(isset($_POST['service_name']) && !empty($_POST['service_name']))
|
||||
$service_name = stripslashes(htmlspecialchars($_POST['service_name']));
|
||||
else
|
||||
$service_name = stripslashes(htmlspecialchars($main_default['name']));
|
||||
|
||||
// Service description
|
||||
if(isset($_POST['service_desc']) && !empty($_POST['service_desc']))
|
||||
$service_desc = stripslashes(htmlspecialchars($_POST['service_desc']));
|
||||
else
|
||||
$service_desc = stripslashes(htmlspecialchars($main_default['desc']));
|
||||
|
||||
// Jappix resource
|
||||
if(isset($_POST['jappix_resource']) && !empty($_POST['jappix_resource']))
|
||||
$jappix_resource = stripslashes(htmlspecialchars($_POST['jappix_resource']));
|
||||
else
|
||||
$jappix_resource = stripslashes(htmlspecialchars($main_default['resource']));
|
||||
|
||||
// Lock host
|
||||
if(isset($_POST['lock_host']) && !empty($_POST['lock_host']))
|
||||
$lock_host = 'on';
|
||||
else
|
||||
$lock_host = 'off';
|
||||
|
||||
// Anonymous mode
|
||||
if(isset($_POST['anonymous_mode']) && !empty($_POST['anonymous_mode']))
|
||||
$anonymous_mode = 'on';
|
||||
else
|
||||
$anonymous_mode = 'off';
|
||||
|
||||
// Registration
|
||||
if(isset($_POST['registration']) && !empty($_POST['registration']))
|
||||
$registration = 'on';
|
||||
else
|
||||
$registration = 'off';
|
||||
|
||||
// BOSH proxy
|
||||
if(isset($_POST['bosh_proxy']) && !empty($_POST['bosh_proxy']))
|
||||
$bosh_proxy = 'on';
|
||||
else
|
||||
$bosh_proxy = 'off';
|
||||
|
||||
// Manager link
|
||||
if(isset($_POST['manager_link']) && !empty($_POST['manager_link']))
|
||||
$manager_link = 'on';
|
||||
else
|
||||
$manager_link = 'off';
|
||||
|
||||
// Groupchats to join
|
||||
if(isset($_POST['groupchats_join']) && !empty($_POST['groupchats_join']))
|
||||
$groupchats_join = stripslashes(htmlspecialchars(trim($_POST['groupchats_join'])));
|
||||
else
|
||||
$groupchats_join = stripslashes(htmlspecialchars($main_default['groupchats_join']));
|
||||
|
||||
// Encryption
|
||||
if(isset($_POST['encryption']) && !empty($_POST['encryption']))
|
||||
$encryption = 'on';
|
||||
else
|
||||
$encryption = 'off';
|
||||
|
||||
// HTTPS storage
|
||||
if(isset($_POST['https_storage']) && !empty($_POST['https_storage']))
|
||||
$https_storage = 'on';
|
||||
else
|
||||
$https_storage = 'off';
|
||||
|
||||
// Force HTTPS
|
||||
if(isset($_POST['https_force']) && !empty($_POST['https_force']))
|
||||
$https_force = 'on';
|
||||
else
|
||||
$https_force = 'off';
|
||||
|
||||
// Compression
|
||||
if(isset($_POST['compression']) && !empty($_POST['compression']))
|
||||
$compression = 'on';
|
||||
else
|
||||
$compression = 'off';
|
||||
|
||||
// Multiple resources
|
||||
if(isset($_POST['multi_files']) && ($_POST['multi_files'] == 'on'))
|
||||
$multi_files = 'on';
|
||||
else
|
||||
$multi_files = 'off';
|
||||
|
||||
// Developer mode
|
||||
if(isset($_POST['developer']) && ($_POST['developer'] == 'on'))
|
||||
$developer = 'on';
|
||||
else
|
||||
$developer = 'off';
|
||||
|
||||
// Generate the configuration XML content
|
||||
$conf_xml =
|
||||
'<name>'.$service_name.'</name>
|
||||
<desc>'.$service_desc.'</desc>
|
||||
<resource>'.$jappix_resource.'</resource>
|
||||
<lock>'.$lock_host.'</lock>
|
||||
<anonymous>'.$anonymous_mode.'</anonymous>
|
||||
<registration>'.$registration.'</registration>
|
||||
<bosh_proxy>'.$bosh_proxy.'</bosh_proxy>
|
||||
<manager_link>'.$manager_link.'</manager_link>
|
||||
<groupchats_join>'.$groupchats_join.'</groupchats_join>
|
||||
<encryption>'.$encryption.'</encryption>
|
||||
<https_storage>'.$https_storage.'</https_storage>
|
||||
<https_force>'.$https_force.'</https_force>
|
||||
<compression>'.$compression.'</compression>
|
||||
<multi_files>'.$multi_files.'</multi_files>
|
||||
<developer>'.$developer.'</developer>'
|
||||
;
|
||||
|
||||
// Write the main configuration
|
||||
writeXML('conf', 'main', $conf_xml);
|
100
jappixmini/jappix/php/post-store.php
Normal file
100
jappixmini/jappix/php/post-store.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the store configuration POST handler (manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 28/12/10
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Music upload?
|
||||
if(isset($_POST['upload'])) {
|
||||
// Get the file path
|
||||
$name_music = $_FILES['music_file']['name'];
|
||||
$temp_music = $_FILES['music_file']['tmp_name'];
|
||||
|
||||
// Any special name submitted?
|
||||
if(isset($_POST['music_title']) && !empty($_POST['music_title'])) {
|
||||
// Add a form var
|
||||
$music_title = $_POST['music_title'];
|
||||
|
||||
// Get the file extension
|
||||
$ext_music = getFileExt($name_music);
|
||||
|
||||
// New name
|
||||
$name_music = '';
|
||||
|
||||
// Add the artist name?
|
||||
if(isset($_POST['music_artist']) && !empty($_POST['music_artist'])) {
|
||||
// Add a form var
|
||||
$music_artist = $_POST['music_artist'];
|
||||
|
||||
// Add the current POST var to the global string
|
||||
$name_music .= $_POST['music_artist'].' - ';
|
||||
}
|
||||
|
||||
// Add the music title
|
||||
$name_music .= $_POST['music_title'];
|
||||
|
||||
// Add the album name?
|
||||
if(isset($_POST['music_album']) && !empty($_POST['music_album'])) {
|
||||
// Add a form var
|
||||
$music_album = $_POST['music_album'];
|
||||
|
||||
// Add the current POST var to the global string
|
||||
$name_music .= ' ['.$_POST['music_album'].']';
|
||||
}
|
||||
|
||||
// Add the extension
|
||||
$name_music .= '.'.$ext_music;
|
||||
}
|
||||
|
||||
// Music path with new name
|
||||
$path_music = JAPPIX_BASE.'/store/music/'.$name_music;
|
||||
|
||||
// An error occured?
|
||||
if(!isSafe($name_music) || $_FILES['music_file']['error'] || !move_uploaded_file($temp_music, $path_music)) { ?>
|
||||
|
||||
<p class="info smallspace fail"><?php _e("The music could not be received, please retry!"); ?></p>
|
||||
|
||||
<?php }
|
||||
|
||||
// Bad extension?
|
||||
else if(!preg_match('/^(.+)(\.(og(g|a)|mp3|wav))$/i', $name_music)) {
|
||||
// Remove the image file
|
||||
if(file_exists($path_music))
|
||||
unlink($path_music);
|
||||
?>
|
||||
|
||||
<p class="info smallspace fail"><?php _e("This is not a valid music file, please encode in Ogg Vorbis, MP3 or WAV!"); ?></p>
|
||||
|
||||
<?php }
|
||||
|
||||
// The file has been sent
|
||||
else { ?>
|
||||
|
||||
<p class="info smallspace success"><?php _e("Your music has been added!"); ?></p>
|
||||
|
||||
<?php
|
||||
// Reset the form vars
|
||||
$music_title = '';
|
||||
$music_artist = '';
|
||||
$music_album = '';
|
||||
}
|
||||
}
|
||||
|
||||
// File deletion?
|
||||
else if(isset($_POST['remove']))
|
||||
removeElements();
|
||||
|
||||
?>
|
48
jappixmini/jappix/php/post-users.php
Normal file
48
jappixmini/jappix/php/post-users.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the user add POST handler (install & manager)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 28/12/10
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Marker
|
||||
$valid_user = true;
|
||||
|
||||
// Administrator name
|
||||
if(isset($_POST['user_name']) && !empty($_POST['user_name']))
|
||||
$user_name = trim($_POST['user_name']);
|
||||
else
|
||||
$valid_user = false;
|
||||
|
||||
// Administrator password (first)
|
||||
if(isset($_POST['user_password']) && !empty($_POST['user_password']))
|
||||
$user_password = trim($_POST['user_password']);
|
||||
else
|
||||
$valid_user = false;
|
||||
|
||||
// Administrator password (second)
|
||||
if(isset($_POST['user_repassword']) && ($user_password != $_POST['user_repassword']))
|
||||
$valid_user = false;
|
||||
|
||||
// Generate the users XML content
|
||||
if($valid_user) {
|
||||
// Add our user
|
||||
manageUsers('add', array($user_name => $user_password));
|
||||
|
||||
// Reset the user name
|
||||
$user_name = '';
|
||||
}
|
||||
|
||||
?>
|
125
jappixmini/jappix/php/read-design.php
Normal file
125
jappixmini/jappix/php/read-design.php
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the design configuration reader
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 28/12/10
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Get the available backgrounds
|
||||
$backgrounds = getBackgrounds();
|
||||
$backgrounds_number = count($backgrounds);
|
||||
|
||||
// Read the background configuration
|
||||
$background = readBackground();
|
||||
|
||||
// Backgrounds are missing?
|
||||
if(!$backgrounds_number && ($background['type'] == 'image'))
|
||||
$background['type'] = 'default';
|
||||
|
||||
switch($background['type']) {
|
||||
// Simple notice input
|
||||
case 'image':
|
||||
$background_image = ' checked=""';
|
||||
$background_default = '';
|
||||
|
||||
break;
|
||||
|
||||
// Advanced notice input
|
||||
case 'color':
|
||||
$background_color = ' checked=""';
|
||||
$background_default = '';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch($background['image_repeat']) {
|
||||
// No repeat
|
||||
case 'no-repeat':
|
||||
$background_image_repeat_no = ' selected=""';
|
||||
$background_image_repeat_x = '';
|
||||
|
||||
break;
|
||||
|
||||
// Repeat
|
||||
case 'repeat':
|
||||
$background_image_repeat_all = ' selected=""';
|
||||
$background_image_repeat_x = '';
|
||||
|
||||
break;
|
||||
|
||||
// Y repeat
|
||||
case 'repeat-y':
|
||||
$background_image_repeat_y = ' selected=""';
|
||||
$background_image_repeat_x = '';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch($background['image_horizontal']) {
|
||||
// Left position
|
||||
case 'left':
|
||||
$background_image_horizontal_left = ' selected=""';
|
||||
$background_image_horizontal_center = '';
|
||||
|
||||
break;
|
||||
|
||||
// Right position
|
||||
case 'right':
|
||||
$background_image_horizontal_right = ' selected=""';
|
||||
$background_image_horizontal_center = '';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch($background['image_vertical']) {
|
||||
// Left position
|
||||
case 'top':
|
||||
$background_image_vertical_top = ' selected=""';
|
||||
$background_image_vertical_center = '';
|
||||
|
||||
break;
|
||||
|
||||
// Right position
|
||||
case 'bottom':
|
||||
$background_image_vertical_bottom = ' selected=""';
|
||||
$background_image_vertical_center = '';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if($background['image_adapt'] == 'on')
|
||||
$background_image_adapt = ' checked=""';
|
||||
|
||||
// Read the notice configuration
|
||||
$notice_conf = readNotice();
|
||||
$notice_text = $notice_conf['notice'];
|
||||
|
||||
switch($notice_conf['type']) {
|
||||
// Simple notice input
|
||||
case 'simple':
|
||||
$notice_simple = ' checked=""';
|
||||
$notice_none = '';
|
||||
|
||||
break;
|
||||
|
||||
// Advanced notice input
|
||||
case 'advanced':
|
||||
$notice_advanced = ' checked=""';
|
||||
$notice_none = '';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
84
jappixmini/jappix/php/read-hosts.php
Normal file
84
jappixmini/jappix/php/read-hosts.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the hosts configuration reader
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 29/05/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Get the protocol we use
|
||||
if(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))
|
||||
$protocol = 'https';
|
||||
else
|
||||
$protocol = 'http';
|
||||
|
||||
// Get the HTTP host
|
||||
$http_host = 'jappix.com';
|
||||
|
||||
if($_SERVER['HTTP_HOST']) {
|
||||
$http_host_split = str_replace('www.', '', $_SERVER['HTTP_HOST']);
|
||||
$http_host_split = preg_replace('/:[0-9]+$/i', '', $http_host_split);
|
||||
|
||||
if($http_host_split)
|
||||
$http_host = $http_host_split;
|
||||
}
|
||||
|
||||
// Define the default hosts configuration values
|
||||
$hosts_conf = array(
|
||||
'main' => $http_host,
|
||||
'muc' => 'muc.'.$http_host,
|
||||
'pubsub' => 'pubsub.'.$http_host,
|
||||
'vjud' => 'vjud.'.$http_host,
|
||||
'anonymous' => 'anonymous.'.$http_host,
|
||||
'bosh' => 'http://'.$http_host.':5280/http-bind',
|
||||
'bosh_main' => '',
|
||||
'bosh_mini' => '',
|
||||
'static' => '',
|
||||
'upload' => ''
|
||||
);
|
||||
|
||||
// Define a default values array
|
||||
$hosts_default = $hosts_conf;
|
||||
|
||||
// Read the hosts configuration file
|
||||
$hosts_data = readXML('conf', 'hosts');
|
||||
|
||||
// Read the hosts configuration file
|
||||
if($hosts_data) {
|
||||
// Initialize the hosts configuration XML data
|
||||
$hosts_xml = new SimpleXMLElement($hosts_data);
|
||||
|
||||
// Loop the hosts configuration elements
|
||||
foreach($hosts_xml->children() as $hosts_child) {
|
||||
$hosts_value = $hosts_child->getName();
|
||||
|
||||
// Only push this to the array if it exists
|
||||
if(isset($hosts_conf[$hosts_value]) && $hosts_child)
|
||||
$hosts_conf[$hosts_value] = str_replace('{PROTOCOL}', $protocol, $hosts_child);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, define the hosts configuration globals
|
||||
define('HOST_MAIN', $hosts_conf['main']);
|
||||
define('HOST_MUC', $hosts_conf['muc']);
|
||||
define('HOST_PUBSUB', $hosts_conf['pubsub']);
|
||||
define('HOST_VJUD', $hosts_conf['vjud']);
|
||||
define('HOST_ANONYMOUS', $hosts_conf['anonymous']);
|
||||
define('HOST_BOSH', $hosts_conf['bosh']);
|
||||
define('HOST_BOSH_MAIN', $hosts_conf['bosh_main']);
|
||||
define('HOST_BOSH_MINI', $hosts_conf['bosh_mini']);
|
||||
define('HOST_STATIC', $hosts_conf['static']);
|
||||
define('HOST_UPLOAD', $hosts_conf['upload']);
|
||||
|
||||
?>
|
77
jappixmini/jappix/php/read-main.php
Normal file
77
jappixmini/jappix/php/read-main.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the main configuration reader
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Define the default main configuration values
|
||||
$main_conf = array(
|
||||
'name' => 'Jappix',
|
||||
'desc' => 'a free social network',
|
||||
'resource' => 'Jappix',
|
||||
'lock' => 'on',
|
||||
'anonymous' => 'on',
|
||||
'registration' => 'on',
|
||||
'bosh_proxy' => 'on',
|
||||
'manager_link' => 'on',
|
||||
'groupchats_join' => '',
|
||||
'encryption' => 'on',
|
||||
'https_storage' => 'off',
|
||||
'https_force' => 'off',
|
||||
'compression' => 'off',
|
||||
'multi_files' => 'off',
|
||||
'developer' => 'off'
|
||||
);
|
||||
|
||||
// Define a default values array
|
||||
$main_default = $main_conf;
|
||||
|
||||
// Read the main configuration file
|
||||
$main_data = readXML('conf', 'main');
|
||||
|
||||
// Read the main configuration file
|
||||
if($main_data) {
|
||||
// Initialize the main configuration XML data
|
||||
$main_xml = new SimpleXMLElement($main_data);
|
||||
|
||||
// Loop the main configuration elements
|
||||
foreach($main_xml->children() as $main_child) {
|
||||
$main_value = $main_child->getName();
|
||||
|
||||
// Only push this to the array if it exists
|
||||
if(isset($main_conf[$main_value]) && $main_child)
|
||||
$main_conf[$main_value] = $main_child;
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, define the main configuration globals
|
||||
define('SERVICE_NAME', $main_conf['name']);
|
||||
define('SERVICE_DESC', $main_conf['desc']);
|
||||
define('JAPPIX_RESOURCE', $main_conf['resource']);
|
||||
define('LOCK_HOST', $main_conf['lock']);
|
||||
define('ANONYMOUS', $main_conf['anonymous']);
|
||||
define('REGISTRATION', $main_conf['registration']);
|
||||
define('BOSH_PROXY', $main_conf['bosh_proxy']);
|
||||
define('MANAGER_LINK', $main_conf['manager_link']);
|
||||
define('GROUPCHATS_JOIN', $main_conf['groupchats_join']);
|
||||
define('ENCRYPTION', $main_conf['encryption']);
|
||||
define('HTTPS_STORAGE', $main_conf['https_storage']);
|
||||
define('HTTPS_FORCE', $main_conf['https_force']);
|
||||
define('COMPRESSION', $main_conf['compression']);
|
||||
define('MULTI_FILES', $main_conf['multi_files']);
|
||||
define('DEVELOPER', $main_conf['developer']);
|
||||
|
||||
?>
|
130
jappixmini/jappix/php/send.php
Normal file
130
jappixmini/jappix/php/send.php
Normal file
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix Out of Band file send script
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 14/01/12
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the needed files
|
||||
require_once('./functions.php');
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Not allowed for a special node
|
||||
if(isStatic())
|
||||
exit;
|
||||
|
||||
// Action on an existing file
|
||||
if(isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$file_id = $_GET['id'];
|
||||
$file_path = JAPPIX_BASE.'/store/send/'.$file_id;
|
||||
|
||||
// Get file name
|
||||
if(isset($_GET['name']) && !empty($_GET['name']))
|
||||
$file_name = $_GET['name'];
|
||||
else
|
||||
$file_name = $file_id;
|
||||
|
||||
// Hack?
|
||||
if(!isSafe($file_id)) {
|
||||
header('Status: 406 Not Acceptable', true, 406);
|
||||
exit('HTTP/1.1 406 Not Acceptable');
|
||||
}
|
||||
|
||||
// File does not exist
|
||||
if(!file_exists($file_path)) {
|
||||
header('Status: 404 Not Found', true, 404);
|
||||
exit('HTTP/1.1 404 Not Found');
|
||||
}
|
||||
|
||||
// Remove a file
|
||||
if(isset($_GET['action']) && ($_GET['action'] == 'remove')) {
|
||||
header('Status: 204 No Content', true, 204);
|
||||
unlink($file_path);
|
||||
}
|
||||
|
||||
// Receive a file
|
||||
header("Content-disposition: attachment; filename=\"$file_name\"");
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Length: ".filesize($file_path));
|
||||
header("Pragma: no-cache");
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
|
||||
header("Expires: 0");
|
||||
readfile($file_path);
|
||||
unlink($file_path);
|
||||
}
|
||||
|
||||
// Send a file
|
||||
else if((isset($_FILES['file']) && !empty($_FILES['file'])) && (isset($_POST['id']) && !empty($_POST['id'])) && (isset($_POST['location']) && !empty($_POST['location']))) {
|
||||
header('Content-Type: text/xml; charset=utf-8');
|
||||
|
||||
// Get the file name
|
||||
$tmp_filename = $_FILES['file']['tmp_name'];
|
||||
$filename = $_FILES['file']['name'];
|
||||
|
||||
// Get the location
|
||||
if(HOST_UPLOAD)
|
||||
$location = HOST_UPLOAD;
|
||||
else
|
||||
$location = $_POST['location'];
|
||||
|
||||
// Get the file new name
|
||||
$ext = getFileExt($filename);
|
||||
$new_name = preg_replace('/(^)(.+)(\.)(.+)($)/i', '$2', $filename);
|
||||
|
||||
// Define some vars
|
||||
$name = sha1(time().$filename);
|
||||
$path = JAPPIX_BASE.'/store/send/'.$name.'.'.$ext;
|
||||
|
||||
// Forbidden file?
|
||||
if(!isSafe($filename) || !isSafe($name.'.'.$ext)) {
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:send\'>
|
||||
<error>forbidden-type</error>
|
||||
<id>'.htmlspecialchars($_POST['id']).'</id>
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
|
||||
// File upload error?
|
||||
if(!is_uploaded_file($tmp_filename) || !move_uploaded_file($tmp_filename, $path)) {
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:send\'>
|
||||
<error>move-error</error>
|
||||
<id>'.htmlspecialchars($_POST['id']).'</id>
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
|
||||
// Return the path to the file
|
||||
exit(
|
||||
'<jappix xmlns=\'jappix:file:send\'>
|
||||
<url>'.htmlspecialchars($location.'php/send.php?id='.urlencode($name).'.'.urlencode($ext).'&name='.urlencode($filename)).'</url>
|
||||
<desc>'.htmlspecialchars($new_name).'</desc>
|
||||
<id>'.htmlspecialchars($_POST['id']).'</id>
|
||||
</jappix>'
|
||||
);
|
||||
}
|
||||
|
||||
// Error?
|
||||
else {
|
||||
header('Status: 400 Bad Request', true, 400);
|
||||
exit('HTTP/1.1 400 Bad Request');
|
||||
}
|
||||
|
||||
?>
|
40
jappixmini/jappix/php/static.php
Normal file
40
jappixmini/jappix/php/static.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix Static PHP/HTML code
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 27/05/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<?php htmlTag($locale); ?>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title><?php echo htmlspecialchars(SERVICE_NAME); ?> • <?php _e("Static content server"); ?></title>
|
||||
<link rel="shortcut icon" href="./favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><?php echo htmlspecialchars(SERVICE_NAME); ?> - <?php _e("Static content server"); ?></h1>
|
||||
<p><?php printf(T_("This is the static content server for %1s, “%2s”."), htmlspecialchars(SERVICE_NAME), htmlspecialchars(SERVICE_DESC)); ?></p>
|
||||
<?php if(showManagerLink()) { ?>
|
||||
<p><a href="./?m=manager<?php echo keepGet('m', false); ?>"><?php _e("Manager"); ?></a></p>
|
||||
<?php } ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<!-- Jappix Static <?php echo $version; ?> - An open social platform -->
|
106
jappixmini/jappix/php/stats-svg.php
Normal file
106
jappixmini/jappix/php/stats-svg.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
The SVG loader for Jappix statistics
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 28/12/10
|
||||
|
||||
*/
|
||||
|
||||
// PHP base
|
||||
define('JAPPIX_BASE', '..');
|
||||
|
||||
// Get the functions
|
||||
require_once('./functions.php');
|
||||
require_once('./functions-manager.php');
|
||||
|
||||
// Get the configuration
|
||||
require_once('./read-main.php');
|
||||
require_once('./read-hosts.php');
|
||||
|
||||
// Get the libs
|
||||
require_once('./drawsvgchart.php');
|
||||
require_once('./gettext.php');
|
||||
|
||||
// Optimize the page rendering
|
||||
hideErrors();
|
||||
compressThis();
|
||||
|
||||
// Start the session
|
||||
session_start();
|
||||
|
||||
// Check if the user is authorized
|
||||
$is_admin = false;
|
||||
|
||||
if((isset($_SESSION['jappix_user']) && !empty($_SESSION['jappix_user'])) && (isset($_SESSION['jappix_password']) && !empty($_SESSION['jappix_password']))) {
|
||||
// Get the session values
|
||||
$user = $_SESSION['jappix_user'];
|
||||
$password = $_SESSION['jappix_password'];
|
||||
|
||||
// Checks the user is admin
|
||||
$is_admin = isAdmin($user, $password);
|
||||
}
|
||||
|
||||
// Not admin? Stop the script!
|
||||
if(!$is_admin)
|
||||
exit;
|
||||
|
||||
// Get the graph type
|
||||
if((isset($_GET['g']) && !empty($_GET['g'])))
|
||||
$graph = $_GET['g'];
|
||||
else
|
||||
$graph = 'others';
|
||||
|
||||
// Get the locale
|
||||
if((isset($_GET['l']) && !empty($_GET['l'])))
|
||||
$locale = $_GET['l'];
|
||||
else
|
||||
$locale = 'en';
|
||||
|
||||
// Include the translations
|
||||
includeTranslation($locale, 'main');
|
||||
|
||||
$drawsvgchart = new DrawSVGChart;
|
||||
|
||||
// Generation vars
|
||||
$link = FALSE;
|
||||
$evolution = FALSE;
|
||||
|
||||
// Access graph?
|
||||
if($graph == 'access') {
|
||||
// Values
|
||||
$elements = getMonthlyVisits();
|
||||
$legend = array(array('#5276A9', T_("Visits")));
|
||||
$evolution = TRUE;
|
||||
}
|
||||
|
||||
// Share graph?
|
||||
else if($graph == 'share') {
|
||||
// Values
|
||||
$elements = largestShare(shareStats(), 8);
|
||||
$legend = array(array('#5276A9', T_("Size")));
|
||||
}
|
||||
|
||||
// Others graph?
|
||||
else if($graph == 'others') {
|
||||
// Values
|
||||
$elements = otherStats();
|
||||
$legend = array(array('#5276A9', T_("Size")));
|
||||
}
|
||||
|
||||
// Generate the chart
|
||||
$svgchart = $drawsvgchart->createChart($elements, $legend, $link, $evolution, $graph);
|
||||
|
||||
// No error?
|
||||
if(!$drawsvgchart->has_errors()) {
|
||||
header('Content-Type: image/svg+xml; charset=utf-8');
|
||||
echo $drawsvgchart->getXMLOutput();
|
||||
}
|
||||
|
||||
?>
|
51
jappixmini/jappix/php/store-tree.php
Normal file
51
jappixmini/jappix/php/store-tree.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This script (re)generates the store sub-folders (after an update)
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Array of the sub-folders to create
|
||||
$store_folders = array(
|
||||
'access',
|
||||
'avatars',
|
||||
'backgrounds',
|
||||
'cache',
|
||||
'conf',
|
||||
'logos',
|
||||
'logs',
|
||||
'music',
|
||||
'send',
|
||||
'share',
|
||||
'updates'
|
||||
);
|
||||
|
||||
// Creates the sub-folders
|
||||
for($i = 0; $i < count($store_folders); $i++) {
|
||||
$current = JAPPIX_BASE.'/store/'.$store_folders[$i];
|
||||
|
||||
// Create the folder itself
|
||||
if(!is_dir($current))
|
||||
mkdir($current, 0777, true);
|
||||
|
||||
chmod($current, 0777);
|
||||
|
||||
// Create the security file inside the folder
|
||||
$security_html = securityHTML();
|
||||
|
||||
file_put_contents($current.'/index.html', $security_html);
|
||||
}
|
||||
|
||||
?>
|
40
jappixmini/jappix/php/upload.php
Normal file
40
jappixmini/jappix/php/upload.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
This is the Jappix Static PHP/HTML code
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 27/05/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<?php htmlTag($locale); ?>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title><?php echo htmlspecialchars(SERVICE_NAME); ?> • <?php _e("User uploads server"); ?></title>
|
||||
<link rel="shortcut icon" href="./favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><?php echo htmlspecialchars(SERVICE_NAME); ?> - <?php _e("User uploads server"); ?></h1>
|
||||
<p><?php printf(T_("This is the user uploads server for %1s, “%2s”."), htmlspecialchars(SERVICE_NAME), htmlspecialchars(SERVICE_DESC)); ?></p>
|
||||
<?php if(showManagerLink()) { ?>
|
||||
<p><a href="./?m=manager<?php echo keepGet('m', false); ?>"><?php _e("Manager"); ?></a></p>
|
||||
<?php } ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<!-- Jappix Upload <?php echo $version; ?> - An open social platform -->
|
49
jappixmini/jappix/php/vars-design.php
Normal file
49
jappixmini/jappix/php/vars-design.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
These are the design configuration variables
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 25/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Define initial logo form values
|
||||
$logo_default = ' checked=""';
|
||||
$logo_own = '';
|
||||
|
||||
// Define initial background form values
|
||||
$background_default = ' checked=""';
|
||||
$background_image = '';
|
||||
$background_color = '';
|
||||
$background_image_repeat_no = '';
|
||||
$background_image_repeat_all = '';
|
||||
$background_image_repeat_x = ' selected=""';
|
||||
$background_image_repeat_y = '';
|
||||
$background_image_horizontal_center = ' selected=""';
|
||||
$background_image_horizontal_left = '';
|
||||
$background_image_horizontal_right = '';
|
||||
$background_image_vertical_center = ' selected=""';
|
||||
$background_image_vertical_top = '';
|
||||
$background_image_vertical_bottom = '';
|
||||
$background_image_adapt = '';
|
||||
|
||||
// Define initial notice form values
|
||||
$notice_none = ' checked=""';
|
||||
$notice_simple = '';
|
||||
$notice_advanced = '';
|
||||
$notice_text = '';
|
||||
|
||||
// Current background folder
|
||||
$backgrounds_folder = 'backgrounds';
|
||||
|
||||
?>
|
32
jappixmini/jappix/php/vars-hosts.php
Normal file
32
jappixmini/jappix/php/vars-hosts.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
These are the hosts configuration variables
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 27/05/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Define the vars with the hosts configuration constants
|
||||
$host_main = htmlspecialchars(HOST_MAIN);
|
||||
$host_muc = htmlspecialchars(HOST_MUC);
|
||||
$host_pubsub = htmlspecialchars(HOST_PUBSUB);
|
||||
$host_vjud = htmlspecialchars(HOST_VJUD);
|
||||
$host_anonymous = htmlspecialchars(HOST_ANONYMOUS);
|
||||
$host_bosh = htmlspecialchars(HOST_BOSH);
|
||||
$host_bosh_main = htmlspecialchars(HOST_BOSH_MAIN);
|
||||
$host_bosh_mini = htmlspecialchars(HOST_BOSH_MINI);
|
||||
$host_static = htmlspecialchars(HOST_STATIC);
|
||||
$host_upload = htmlspecialchars(HOST_UPLOAD);
|
||||
|
||||
?>
|
37
jappixmini/jappix/php/vars-main.php
Normal file
37
jappixmini/jappix/php/vars-main.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
These are the main configuration variables
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 26/08/11
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Define the vars with the main configuration constants
|
||||
$service_name = htmlspecialchars(SERVICE_NAME);
|
||||
$service_desc = htmlspecialchars(SERVICE_DESC);
|
||||
$jappix_resource = htmlspecialchars(JAPPIX_RESOURCE);
|
||||
$lock_host = htmlspecialchars(LOCK_HOST);
|
||||
$anonymous_mode = htmlspecialchars(ANONYMOUS);
|
||||
$registration = htmlspecialchars(REGISTRATION);
|
||||
$bosh_proxy = htmlspecialchars(BOSH_PROXY);
|
||||
$manager_link = htmlspecialchars(MANAGER_LINK);
|
||||
$groupchats_join = htmlspecialchars(GROUPCHATS_JOIN);
|
||||
$encryption = htmlspecialchars(ENCRYPTION);
|
||||
$https_storage = htmlspecialchars(HTTPS_STORAGE);
|
||||
$https_force = htmlspecialchars(HTTPS_FORCE);
|
||||
$compression = htmlspecialchars(COMPRESSION);
|
||||
$multi_files = htmlspecialchars(MULTI_FILES);
|
||||
$developer = htmlspecialchars(DEVELOPER);
|
||||
|
||||
?>
|
29
jappixmini/jappix/php/vars-store.php
Normal file
29
jappixmini/jappix/php/vars-store.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
Jappix - An open social platform
|
||||
These are the store configuration variables
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
License: AGPL
|
||||
Author: Vanaryon
|
||||
Last revision: 28/12/10
|
||||
|
||||
*/
|
||||
|
||||
// Someone is trying to hack us?
|
||||
if(!defined('JAPPIX_BASE'))
|
||||
exit;
|
||||
|
||||
// Define the initial music form values
|
||||
$music_title = '';
|
||||
$music_artist = '';
|
||||
$music_album = '';
|
||||
|
||||
// Current store folders
|
||||
$share_folder = 'share';
|
||||
$music_folder = 'music';
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue