2013-08-28 22:47:04 +02:00
|
|
|
<?php
|
2013-09-28 13:12:29 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
/**
|
|
|
|
* File: settings.php.
|
|
|
|
* Author: Ulrich Block
|
|
|
|
* Contact: <ulrich.block@easy-wi.com>
|
|
|
|
*
|
|
|
|
* This file is part of Easy-WI.
|
|
|
|
*
|
|
|
|
* Easy-WI 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Easy-WI 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 Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Diese Datei ist Teil von Easy-WI.
|
|
|
|
*
|
|
|
|
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
|
|
|
* der GNU General Public License, wie von der Free Software Foundation,
|
|
|
|
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
|
|
|
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
|
|
|
*
|
|
|
|
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
|
|
|
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
|
|
|
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
|
|
|
* Siehe die GNU General Public License fuer weitere Details.
|
|
|
|
*
|
|
|
|
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
|
|
|
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-10-22 21:18:40 +02:00
|
|
|
// We cannot wait until it is removed from PHP and need to protect admins from themselves
|
2014-02-21 18:08:45 +01:00
|
|
|
|
2013-10-22 21:18:40 +02:00
|
|
|
if (ini_get('register_globals') == 'on') {
|
|
|
|
@ini_set('register_globals', 'off');
|
|
|
|
|
|
|
|
// check if we could turn it off. If not shut down.
|
|
|
|
if (ini_get('register_globals') == 'on') {
|
|
|
|
die('register_globals ist set to <b>on</b>. This setting is very dangerous. Easy-WI refuses to work in such an insecure inviroment');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-03 12:49:13 +02:00
|
|
|
$ui = new ValidateUserinput($_GET, $_POST, $_SERVER, array(), $_ENV);
|
2013-10-15 20:53:36 +02:00
|
|
|
unset($_GET, $_POST, $_SERVER, $_ENV, $type, $host, $user, $pwd, $db);
|
|
|
|
|
|
|
|
include(EASYWIDIR . '/stuff/config.php');
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$ewCfg['captcha'] = $captcha;
|
|
|
|
$ewCfg['title'] = $title;
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-12-14 14:39:48 +01:00
|
|
|
$dbConnect['type'] = "mysql";
|
2013-09-28 13:12:29 +02:00
|
|
|
$dbConnect['host'] = $host;
|
|
|
|
$dbConnect['user'] = $user;
|
|
|
|
$dbConnect['pwd'] = $pwd;
|
|
|
|
$dbConnect['db'] = $db;
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2015-06-06 21:03:17 +02:00
|
|
|
if (isset($demo) and $demo == 1) {
|
|
|
|
$ui->demoMode();
|
|
|
|
}
|
|
|
|
|
2014-03-22 10:10:33 +01:00
|
|
|
if (isset($debug) and $debug == 1) {
|
|
|
|
|
2013-09-29 15:29:58 +02:00
|
|
|
$dbConnect['debug'] = 1;
|
2013-08-28 22:47:04 +02:00
|
|
|
ini_set('display_errors',1);
|
|
|
|
error_reporting(E_ALL|E_STRICT);
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-10-05 13:39:56 +02:00
|
|
|
} else {
|
|
|
|
$dbConnect['debug'] = 0;
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
try {
|
|
|
|
$dbConnect['connect']="${dbConnect['type']}:host=${dbConnect['host']};dbname=${dbConnect['db']}";
|
2013-10-03 12:49:13 +02:00
|
|
|
$sql = ($dbConnect['type'] == 'mysql') ? new PDO($dbConnect['connect'], $dbConnect['user'], $dbConnect['pwd'], array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8")) : new PDO($dbConnect['connect'], $dbConnect['user'], $dbConnect['pwd']);
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if ($dbConnect['debug'] == 1) {
|
|
|
|
$sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
}
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$insertlog = $sql->prepare("INSERT INTO userlog (`userid`,`reseller`,`subuser`,`username`,`usertype`,`useraction`,`ip`,`hostname`,`logdate`,`resellerid`) VALUES (:userid,:reseller,:subuser,:username,:usertype,:useraction,:ip,:hostname,NOW(),:reseller_id)");
|
|
|
|
$insertlog->bindParam(':userid', $loguserid);
|
|
|
|
$insertlog->bindParam(':reseller', $logreseller);
|
|
|
|
$insertlog->bindParam(':subuser', $logsubuser);
|
|
|
|
$insertlog->bindParam(':username', $logusername);
|
|
|
|
$insertlog->bindParam(':usertype', $logusertype);
|
|
|
|
$insertlog->bindParam(':useraction', $loguseraction);
|
|
|
|
$insertlog->bindParam(':ip', $loguserip);
|
|
|
|
$insertlog->bindParam(':hostname', $userHostname);
|
|
|
|
$insertlog->bindParam(':reseller_id', $reseller_id);
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-10-13 11:42:31 +02:00
|
|
|
if ($ui->ip('REMOTE_ADDR', 'server')) {
|
|
|
|
$loguserip = $ui->ip('REMOTE_ADDR', 'server');
|
|
|
|
$userHostname = @gethostbyaddr($ui->ip('REMOTE_ADDR', 'server'));
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
} else {
|
2013-09-28 13:12:29 +02:00
|
|
|
$loguserip = 'localhost';
|
|
|
|
$userHostname = 'localhost';
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(PDOException $error) {
|
|
|
|
die($error->getMessage());
|
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2014-01-01 14:00:35 +01:00
|
|
|
// many peaple do not know how to properly configure their servers, so we need to help them and set the timezone
|
2014-04-21 11:11:59 +02:00
|
|
|
$timezoneDefined = @ini_get('date.timezone');
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2014-01-01 14:18:05 +01:00
|
|
|
if (!isset($dbConnect['timezone'])) {
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2014-01-01 14:18:05 +01:00
|
|
|
if ($timezoneDefined == '') {
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2014-04-21 11:11:59 +02:00
|
|
|
$dbConnect['timezone'] = @date_default_timezone_get();
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2014-01-01 14:18:05 +01:00
|
|
|
} else {
|
|
|
|
$dbConnect['timezone'] = $timezoneDefined;
|
|
|
|
}
|
2014-01-01 14:00:35 +01:00
|
|
|
}
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2014-01-01 14:00:35 +01:00
|
|
|
if ($dbConnect['timezone'] != $timezoneDefined) {
|
|
|
|
date_default_timezone_set($dbConnect['timezone']);
|
|
|
|
}
|
|
|
|
|
2014-03-22 10:10:33 +01:00
|
|
|
$page_url = ($ui->escaped ('HTTPS', 'server')) ? 'https://' . $ui->domain('HTTP_HOST', 'server') : 'http://' . $ui->domain('HTTP_HOST', 'server');
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if ($loguserip != 'localhost') {
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
session_start();
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
if (isset($_SESSION['userid']) and is_numeric($_SESSION['userid']) and isset($_SESSION['adminid']) and is_numeric($_SESSION['adminid'])) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$user_id = $_SESSION['userid'];
|
|
|
|
$admin_id = $_SESSION['adminid'];
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-10-13 13:11:38 +02:00
|
|
|
} else if (isset($_SESSION['userid']) and is_numeric($_SESSION['userid'])) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$user_id = $_SESSION['userid'];
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
} else if (isset($_SESSION['adminid']) and is_numeric($_SESSION['adminid'])) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$admin_id = $_SESSION['adminid'];
|
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if (isset($_SESSION['resellerid']) and is_numeric($_SESSION['resellerid'])) {
|
|
|
|
$reseller_id = $_SESSION['resellerid'];
|
2013-10-15 20:28:20 +02:00
|
|
|
} else if ((isset($_SESSION['userid']) or isset($_SESSION['adminid'])) and (!isset($_SESSION['resellerid']) or !is_numeric($_SESSION['resellerid']))) {
|
2013-10-15 21:45:11 +02:00
|
|
|
session_unset();
|
|
|
|
session_destroy();
|
2013-10-15 20:28:20 +02:00
|
|
|
redirect('login.php');
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
if (isset($_SESSION['HTTP_USER_AGENT']) and isset($_SESSION['REMOTE_ADDR'])){
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-10-13 11:42:31 +02:00
|
|
|
if ($_SESSION['HTTP_USER_AGENT'] != md5($ui->escaped('HTTP_USER_AGENT', 'server')) or $_SESSION['REMOTE_ADDR'] != md5($ui->ip('REMOTE_ADDR', 'server'))){
|
2013-08-28 22:47:04 +02:00
|
|
|
session_unset();
|
|
|
|
session_destroy();
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if (isset($page_include)) {
|
|
|
|
redirect('/');
|
|
|
|
} else {
|
|
|
|
redirect('login.php');
|
|
|
|
}
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
} else {
|
2013-10-13 11:42:31 +02:00
|
|
|
$_SESSION['REMOTE_ADDR'] = md5($ui->ip('REMOTE_ADDR', 'server'));
|
|
|
|
$_SESSION['HTTP_USER_AGENT'] = md5($ui->escaped('HTTP_USER_AGENT', 'server'));
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-29 15:29:58 +02:00
|
|
|
$rSA = array();
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2014-01-01 14:00:35 +01:00
|
|
|
$htmlExtraInformation = array(
|
|
|
|
'body' => array(),
|
|
|
|
'css' => array(),
|
|
|
|
'js' => array()
|
|
|
|
);
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
if (isset($reseller_id)) {
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("SELECT * FROM `settings` WHERE `resellerid`=? LIMIT 1");
|
2013-08-28 22:47:04 +02:00
|
|
|
$query->execute(array($reseller_id));
|
2014-11-30 12:55:07 +01:00
|
|
|
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
2013-10-26 11:59:03 +02:00
|
|
|
foreach ($row as $k => $v) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$rSA[$k] = $v;
|
|
|
|
}
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$resellerstimezone = $rSA['timezone'];
|
|
|
|
$template_to_use = $rSA['template'];
|
|
|
|
$downChecks = $rSA['down_checks'];
|
|
|
|
$logdate = date('Y-m-d H:i:s', strtotime($resellerstimezone .' hour'));
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-12-22 14:06:05 +01:00
|
|
|
if (isset($admin_id)) {
|
|
|
|
$resellerLockupID = ($reseller_id != 0 and $reseller_id != $admin_id) ? $admin_id : $reseller_id;
|
2014-11-22 12:34:25 +01:00
|
|
|
} else {
|
|
|
|
$resellerLockupID = $reseller_id;
|
2013-12-22 14:06:05 +01:00
|
|
|
}
|
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
if (isset($user_id) and !isset($admin_id)) {
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$lookupid = $reseller_id;
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
} else {
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-10-15 20:28:20 +02:00
|
|
|
$check_split = preg_split("/\//", $ui->escaped('SCRIPT_NAME', 'server'), -1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
$which_file = $check_split[count($check_split) - 1];
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-10-03 12:49:13 +02:00
|
|
|
if ($which_file == 'userpanel.php') {
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$lookupid = $reseller_id;
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
} else {
|
2013-09-28 13:12:29 +02:00
|
|
|
$lookupid = ($reseller_id == $admin_id) ? 0 : $reseller_id;
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("SELECT `supportnumber` FROM `settings` WHERE `resellerid`=? LIMIT 1");
|
2013-08-28 22:47:04 +02:00
|
|
|
$query->execute(array($lookupid));
|
2013-09-28 13:12:29 +02:00
|
|
|
$support_phonenumber = $query->fetchColumn();
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-12-22 14:06:05 +01:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
} else {
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("SELECT * FROM `settings` WHERE `resellerid`=0 LIMIT 1");
|
2013-08-28 22:47:04 +02:00
|
|
|
$query->execute();
|
2014-11-30 12:55:07 +01:00
|
|
|
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
2013-10-26 11:59:03 +02:00
|
|
|
foreach ($row as $k => $v) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$rSA[$k] = $v;
|
|
|
|
}
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$template_to_use = $rSA['template'];
|
|
|
|
$support_phonenumber = $rSA['supportnumber'];
|
|
|
|
$logdate = date('Y-m-d H:i:s');
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2015-02-26 19:07:19 +01:00
|
|
|
if ($loguserip != 'localhost') {
|
2013-10-05 13:39:56 +02:00
|
|
|
|
|
|
|
if (isset($_SESSION['language'])) {
|
|
|
|
$user_language = $_SESSION['language'];
|
|
|
|
}
|
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
if (isset($page_include)) {
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-12-22 18:32:01 +01:00
|
|
|
$query = $sql->prepare("SELECT * FROM `page_settings` WHERE `resellerid`=0 LIMIT 1");
|
2013-08-28 22:47:04 +02:00
|
|
|
$query->execute();
|
2014-11-30 12:55:07 +01:00
|
|
|
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
2013-11-24 13:46:33 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$seo = $row['seo'];
|
|
|
|
$rssfeed = $row['rssfeed'];
|
2013-08-28 22:47:04 +02:00
|
|
|
$maxnews=(isid($row['maxnews'],11)) ? $row['maxnews'] : 10;
|
2013-09-28 13:12:29 +02:00
|
|
|
$page_default = $row['defaultpage'];
|
2013-10-13 11:42:31 +02:00
|
|
|
$pageurl = $row['pageurl'];
|
2013-09-28 13:12:29 +02:00
|
|
|
$protectioncheck = $row['protectioncheck'];
|
|
|
|
$maxnews_sidebar = $row['maxnews_sidebar'];
|
|
|
|
$newssidebar_textlength = $row['newssidebar_textlength'];
|
|
|
|
$spamFilter = $row['spamFilter'];
|
|
|
|
$languageFilter = $row['languageFilter'];
|
|
|
|
$blockLinks = $row['blockLinks'];
|
|
|
|
$blockWords = $row['blockWords'];
|
|
|
|
$mailRequired = $row['mailRequired'];
|
|
|
|
$commentMinLength = $row['commentMinLength'];
|
|
|
|
$commentsModerated = $row['commentsModerated'];
|
|
|
|
$honeyPotKey = $row['honeyPotKey'];
|
2013-10-15 20:28:20 +02:00
|
|
|
|
|
|
|
if (!isurl($pageurl) and !isdomain($pageurl)) {
|
|
|
|
$pageurl = $page_url;
|
|
|
|
}
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2015-11-01 18:09:13 +01:00
|
|
|
$query = $sql->prepare("SELECT `active` FROM `modules` WHERE `type`='C' AND `get`='pn' AND `sub`='pn' LIMIT 1");
|
2013-11-24 13:46:33 +01:00
|
|
|
$query->execute();
|
|
|
|
$page_active = $query->fetchColumn();
|
|
|
|
$page_active = (active_check($page_active)) ? $page_active : 'Y';
|
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$ewInstallPath = EASYWIDIR;
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2014-01-10 22:16:51 +01:00
|
|
|
$elements = (!empty($ewInstallPath) and strpos($ui->escaped('REQUEST_URI', 'server'), $ewInstallPath) === false) ? preg_split('/\//', $ui->escaped('REQUEST_URI', 'server'), -1, PREG_SPLIT_NO_EMPTY) : preg_split('/\//',substr($ui->escaped('REQUEST_URI', 'server'), strlen($ewInstallPath)), -1, PREG_SPLIT_NO_EMPTY);
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2014-02-23 13:13:48 +01:00
|
|
|
if (isset($seo) and $seo == 'Y' and isset($elements[0])) {
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$page_detect_language = $elements[0];
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2014-06-08 10:04:42 +02:00
|
|
|
if (!preg_match('/^[a-z]{2}+$/', $elements[0]) and !$ui->w('site', 50, 'get') and $elements[0] != 'index.php') {
|
2013-09-28 13:12:29 +02:00
|
|
|
$throw404 = true;
|
|
|
|
}
|
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if (isset($elements[1]) and $elements[1] != '') {
|
2013-10-05 13:39:56 +02:00
|
|
|
$page_category = strtolower($elements[1]);
|
2013-09-28 13:12:29 +02:00
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if (isset($elements[2]) and $elements[2] != '') {
|
2013-10-05 13:39:56 +02:00
|
|
|
$page_name = strtolower($elements[2]);
|
2013-09-28 13:12:29 +02:00
|
|
|
}
|
2013-10-05 13:39:56 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if (isset($elements[3]) and $elements[3] != '') {
|
2013-10-05 13:39:56 +02:00
|
|
|
$page_count = strtolower($elements[3]);
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
if (!isset($user_language) and isset($user_id) and isset($admin_id)) {
|
2013-10-15 20:28:20 +02:00
|
|
|
$user_language = language($admin_id);
|
2013-10-13 13:11:38 +02:00
|
|
|
} else if (!isset($user_language) and isset($user_id) and !isset($admin_id)) {
|
2013-10-15 20:28:20 +02:00
|
|
|
$user_language = language($user_id);
|
2013-08-28 22:47:04 +02:00
|
|
|
} else if (!isset($user_language) and isset($admin_id)) {
|
2013-10-15 20:28:20 +02:00
|
|
|
$user_language = language($admin_id);
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-10-03 12:49:13 +02:00
|
|
|
if (isset($page_detect_language) and preg_match('/^[a-z]{2}+$/', $page_detect_language) and ((isset($_SESSION['language']) and $page_detect_language != $_SESSION['language']) or !isset($_SESSION['language']))){
|
2013-09-28 13:12:29 +02:00
|
|
|
$language_changed = true;
|
|
|
|
$user_language = $page_detect_language;
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-10-13 13:11:38 +02:00
|
|
|
if ($ui->st('l', 'get') or isset($language_changed)) {
|
|
|
|
if ($ui->st('l', 'get')) $user_language = $ui->st('l', 'get');
|
2013-09-28 13:12:29 +02:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
# https://github.com/easy-wi/developer/issues/2
|
|
|
|
if (isset($_SESSION['sID'])) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("UPDATE `userdata_substitutes` SET `language`=? WHERE `sID`=? AND `resellerID`=? LIMIT 1");
|
|
|
|
$query->execute(array($user_language, $_SESSION['sID'], $reseller_id));
|
2013-08-28 22:47:04 +02:00
|
|
|
} else if (isset($admin_id)) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("UPDATE `userdata` SET `language`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
|
|
|
|
$query->execute(array($user_language, $admin_id, $reseller_id));
|
2013-08-28 22:47:04 +02:00
|
|
|
} else if (isset($user_id)) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("UPDATE `userdata` SET `language`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
|
|
|
|
$query->execute(array($user_language, $user_id, $reseller_id));
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
}
|
2014-01-10 11:45:30 +01:00
|
|
|
|
2013-10-15 21:45:11 +02:00
|
|
|
$default_language = (!empty($user_language)) ? $user_language : $rSA['language'];
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
if (!isset($user_language) or empty($user_language)) {
|
|
|
|
$user_language = $default_language;
|
|
|
|
}
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$_SESSION['language'] = $user_language;
|
2013-10-15 20:28:20 +02:00
|
|
|
|
|
|
|
$gsprache = (isset($reseller_id)) ? getlanguagefile('general', $user_language, $reseller_id) : getlanguagefile('general', $user_language, 0);
|
|
|
|
$spracheResponse = (isset($reseller_id)) ? getlanguagefile('response', $user_language, $reseller_id) : getlanguagefile('response', $user_language, 0);
|
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2013-10-15 20:28:20 +02:00
|
|
|
|
2014-03-20 21:59:15 +01:00
|
|
|
if (!isset($user_language)) {
|
|
|
|
$user_language = $rSA['language'];
|
|
|
|
}
|
|
|
|
|
2013-10-13 11:42:31 +02:00
|
|
|
if (isset($logininclude) and $logininclude == true) {
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("DELETE FROM `badips` WHERE `bantime` <= ?");
|
2013-08-28 22:47:04 +02:00
|
|
|
$query->execute(array($logdate));
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("SELECT `id` FROM `badips` WHERE `badip`=? AND reason='bot' LIMIT 1");
|
2013-08-28 22:47:04 +02:00
|
|
|
$query->execute(array($loguserip));
|
2013-11-24 12:12:07 +01:00
|
|
|
if ($query->rowCount() > 0) {
|
2013-09-28 13:12:29 +02:00
|
|
|
die();
|
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("SELECT `faillogins` FROM `settings` WHERE `resellerid`=0 LIMIT 1");
|
2013-08-28 22:47:04 +02:00
|
|
|
$query->execute();
|
2013-09-28 13:12:29 +02:00
|
|
|
$allowedfails = $query->fetchColumn();
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$query = $sql->prepare("SELECT `id` FROM `badips` WHERE `badip`=? AND `reason`='password' AND `failcount`>=? LIMIT 1");
|
|
|
|
$query->execute(array($loguserip, $allowedfails));
|
2014-03-22 10:10:33 +01:00
|
|
|
|
2013-11-24 12:12:07 +01:00
|
|
|
if ($query->rowCount() > 0) {
|
2013-09-28 13:12:29 +02:00
|
|
|
die('Your IP is banned');
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-10-13 13:11:38 +02:00
|
|
|
if ($ui->st('r', 'get')) {
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2014-02-01 15:15:43 +01:00
|
|
|
$redirectID = ($ui->id('id', 30, 'get')) ? '&id=' . $ui->id('id', 30, 'get') : '';
|
2014-03-20 21:59:15 +01:00
|
|
|
$actionParam = ($redirectID != '' and $ui->smallletters('d', 10, 'get') == 'md') ? '&d=' . $ui->smallletters('d', 10, 'get') : '';
|
|
|
|
|
|
|
|
$header = '<meta http-equiv="refresh" content="3; URL=' . $ui->escaped('SCRIPT_NAME', 'server') . '?w=' . $ui->st('r', 'get') . $redirectID . $actionParam . '">';
|
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$rsprache = getlanguagefile('redirect', $user_language, 0);
|
|
|
|
$text = $rsprache->refresh;
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-10-20 12:02:02 +02:00
|
|
|
if ($ui->smallletters('site', 50, 'get')) {
|
|
|
|
$s = $ui->smallletters('site', 50, 'get');
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
|
2014-03-20 21:59:15 +01:00
|
|
|
$w = ($ui->st('w', 'get')) ? $ui->st('w', 'get') : 'ho';
|
|
|
|
$d = ($ui->st('d', 'get')) ? $ui->st('d', 'get') : 'md';
|
|
|
|
$start = ($ui->id('p', 19, 'get')) ? $ui->id('p', 19, 'get') : 0;
|
2013-09-28 13:12:29 +02:00
|
|
|
|
2013-10-13 13:11:38 +02:00
|
|
|
if ($ui->smallletters('t','1', 'get')) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$list_type = $ui->smallletters('t','1', 'get');
|
2013-08-28 22:47:04 +02:00
|
|
|
if ($list_type=="m") {
|
|
|
|
$where="WHERE `type`='map'";
|
|
|
|
} else if ($list_type=="t") {
|
|
|
|
$where="WHERE `type`='tool'";
|
|
|
|
} else {
|
|
|
|
$list_type="a";
|
2013-09-28 13:12:29 +02:00
|
|
|
$where = '';
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$list_type="a";
|
2013-09-28 13:12:29 +02:00
|
|
|
$where = '';
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-10-13 13:11:38 +02:00
|
|
|
if ($ui->pregw('g','14', 'get')) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$list_gtype = $ui->pregw('g','14', 'get');
|
|
|
|
if ($where != '') {
|
2013-08-28 22:47:04 +02:00
|
|
|
$where .=" AND shorten='$list_gtype'";
|
|
|
|
} else {
|
|
|
|
if ($w=="lo") {
|
2013-09-28 13:12:29 +02:00
|
|
|
$where = $list_gtype;
|
2013-08-28 22:47:04 +02:00
|
|
|
} else if ($list_gtype!='all') {
|
|
|
|
$where="WHERE shorten='$list_gtype'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2013-09-28 13:12:29 +02:00
|
|
|
$list_gtype = '';
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2014-03-22 18:37:31 +01:00
|
|
|
if ($ui->pregw('m', 20, 'get')) {
|
|
|
|
$list_gtype = $ui->pregw('m', 20, 'get');
|
2013-09-28 13:12:29 +02:00
|
|
|
if ($where != '') {
|
2013-12-18 08:28:42 +01:00
|
|
|
$where .=" AND s.`shorten`='$list_gtype'";
|
2013-08-28 22:47:04 +02:00
|
|
|
} else if ($list_gtype!="all") {
|
2013-12-18 08:28:42 +01:00
|
|
|
$where="WHERE s.`shorten`='$list_gtype'";
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
2013-09-28 13:12:29 +02:00
|
|
|
$list_gtype = '';
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
if (empty($where) and $w!="lo" and $w!="rs" and ($w!="ma" and $d!="ud")) {
|
|
|
|
$where="WHERE `resellerid`=:reseller_id";
|
|
|
|
} else if (empty($where) and $w!="lo" and $w!="rs" and ($w=="ma" and $d=="ud")) {
|
|
|
|
$where="WHERE r.`resellerid`=:reseller_id";
|
|
|
|
} else if ($w!="lo" and ($w!="ma" and $d!="ud")) {
|
|
|
|
$where .=" AND `resellerid`=:reseller_id";
|
|
|
|
} else if ($w!="lo" and ($w=="ma" and $d=="ud")) {
|
|
|
|
$where .=" AND r.`resellerid`=:reseller_id";
|
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-10-13 13:11:38 +02:00
|
|
|
if ($ui->isinteger('a', 'get')) {
|
2013-09-28 13:12:29 +02:00
|
|
|
$a = (int) $ui->isinteger('a', 'get');
|
|
|
|
$amount = $a;
|
|
|
|
$_SESSION['amount'] = $a;
|
2013-08-28 22:47:04 +02:00
|
|
|
} else {
|
2013-09-28 13:12:29 +02:00
|
|
|
$amount = (isset($_SESSION['amount']) and is_int($_SESSION['amount'])) ? $_SESSION['amount'] : 20;
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-09-28 13:17:04 +02:00
|
|
|
$dirs = array();
|
2014-03-20 21:59:15 +01:00
|
|
|
$languages = array();
|
|
|
|
|
2013-10-12 08:40:09 +02:00
|
|
|
if (is_dir(EASYWIDIR . '/languages/' . $template_to_use . '/')) {
|
|
|
|
$dirs = array_merge($dirs, scandir(EASYWIDIR . '/languages/' . $template_to_use . '/'));
|
2013-09-28 13:12:29 +02:00
|
|
|
}
|
|
|
|
if (is_dir(EASYWIDIR . '/languages/default/')) {
|
2014-03-20 21:59:15 +01:00
|
|
|
$dirs = array_merge($dirs , scandir(EASYWIDIR . '/languages/default/'));
|
2013-09-28 13:12:29 +02:00
|
|
|
}
|
|
|
|
if (is_dir(EASYWIDIR . '/languages/')) {
|
2014-03-20 21:59:15 +01:00
|
|
|
$dirs = array_merge($dirs , scandir(EASYWIDIR . '/languages/'));
|
2013-09-28 13:12:29 +02:00
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-09-28 13:12:29 +02:00
|
|
|
$dirs = array_unique($dirs);
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-08-28 22:47:04 +02:00
|
|
|
foreach ($dirs as $row) {
|
2014-03-20 21:59:15 +01:00
|
|
|
if (small_letters_check($row, 2)) {
|
|
|
|
$languages[] = $row;
|
|
|
|
}
|
2013-08-28 22:47:04 +02:00
|
|
|
}
|
2014-03-20 21:59:15 +01:00
|
|
|
|
2013-10-13 11:42:31 +02:00
|
|
|
if ($ui->escaped('HTTP_REFERER', 'server')) {
|
|
|
|
$referrer = $ui->escaped('HTTP_REFERER', 'server');
|
2015-02-26 19:07:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($reseller_id)) {
|
|
|
|
$reseller_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($resellerLockupID)) {
|
|
|
|
$resellerLockupID = $reseller_id;
|
2013-09-28 13:12:29 +02:00
|
|
|
}
|