kleeja 3.1

3.1.0
This commit is contained in:
Mitan Omar
2019-06-02 17:31:49 +02:00
committed by GitHub
134 changed files with 7616 additions and 8327 deletions

4
.gitignore vendored
View File

@@ -13,6 +13,10 @@ uploads/thumbs/*
!uploads/thumbs/index.html
!uploads/thumbs/php.ini
!uploads/thumbs/.htaccess
styles/*
!styles/bootstrap/*
!styles/default/*
!styles/index.html
.DS_Store
*/.DS_Store
*/*/.DS_Store

View File

@@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 3.1.0
- add the ability to auto-update kleeja from admin panel with one click!
- add plugins/styles store (one click download, install and update or even delete)
- a plugins/styles catalog (any developer can add his/her plugins/styles now)
- fix `fields doesn't have a default value` error #104
- fix e modifier is deprecated #103
- fix update check redirect error #97
- improve ban control page #94
- add the ability to ban by username
- add support of mkv files #83
- add support of most known-to-humans timezones #78
- fix download counter to skip unwanted visits.
- fix pagination error in user files page
- fix some issues with some plugins (kj_ftp, for example.)
- replace Kleeja team page with current github contributors 😇
- add ability to hide/show widgets in home page of admin panel.
- fix issues with downloaded persian/arabic filesnames #53
- fix `remember me` issue on login page.
- add solution for hosts running under suexec (by adding `define('HAS_SUEXEC', true);` to config.php)
- fix issue with auto-deleting old files feature.
- removed feature : Uploading from URLs (leech).
## 3.0.2
- new styles, drag and drop and progressbar and bootstrap black.
- cleaning the header and footer after removing the plugin.

View File

@@ -9,26 +9,87 @@
<div class="card">
<div class="card-body">
{lang.BAN_EXP1}
<br>
{lang.BAN_EXP2}
</div>
</div>
<br>
<div class="d-flex justify-content-end my-2">
<a class="btn btn-primary btn-sm" href="#" data-toggle="modal" data-target="#new_item_form">
<i class="fa fa-plus"></i> {lang.NEW}
</a>
</div>
<form method="post" action="{action}" id="ban_form">
<div class="form-group">
<!-- textarea -->
<textarea name="ban_text" class="form-control" rows="2" cols="20" style="width:99%; height: 100px;direction:ltr;">{ban}</textarea>
<IF NAME="show_message">
<div class="alert alert-info alert-dismissible fade show small my-2" role="alert">
{show_message}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true" class="small" style="cursor:pointer">&times;</span>
</button>
</div>
<script>
setTimeout(function() {
$('.alert-dismissible').fadeOut();
}, 5000);
</script>
</IF>
<div class="table-responsive-sm">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">{lang.IP} / {lang.USERNAME}</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<LOOP NAME="banned_items">
<tr>
<th scope="row">{{id}}</th>
<td>{{content}}</td>
<td class="d-flex justify-content-end">
<a class="btn btn-outline-danger btn-sm" href="{delete_item}{{del_key}}" title="{lang.DELETE}" onclick="javascript:return confirm_form();">
<i class="fa fa-remove" title="{lang.DELETE}"></i>
</a>
</td>
</tr>
</LOOP>
</tbody>
</table>
</div>
<!-- new banned item modal -->
<div id="new_item_form" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addNewBannedItem"
aria-hidden="true">
<form method="post" action="{new_item_action}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addNewBannedItem">{lang.IP} / {lang.USERNAME}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<label class="form-control">
<input type="text" class="form-control" id="k" name="k" placeholder="{lang.IP} {lang.OR} {lang.USERNAME}" value="">
</label>
<small>
{lang.BAN_EXP2}
</small>
{H_FORM_KEYS}
</div>
<div class="modal-footer">
<br>
<input type="submit" name="submit" value="{lang.UPDATE_BAN}" class="btn btn-primary">
{H_FORM_KEYS}
</form>
<input type="submit" name="submit" class="btn btn-primary" value="{lang.SUBMIT}">
</div>
</div>
</div>
</form>
</div>
<!-- end new banned item modal -->

View File

@@ -69,7 +69,9 @@ function checkVersion() {
.done(function (data) {
if(data.content) {
var info = data.content.split(":::");
$('#updateInfo').addClass(info[0] != 0 ? 'alert-warning' : 'alert-info');
$('#updateInfo').addClass(
info[0] != 0 ? 'alert-warning' : 'alert-info'
);
$('#updateInfoStatus').html(info[1]);
<UNLESS NAME="showMessage">
if(info[0] == 2) {
@@ -128,9 +130,10 @@ function updateNow(step) {
}
})
.fail(function(data) {
var tryAgainMsg = '{lang.ERROR_TRY_AGAIN}';
$('#update'+step+' .update-status').html('<i class="fa fa-warning text-danger"></i>');
$('#update'+step+' .update-message').removeClass('d-none').addClass('d-block').html(
(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : '{lang.ERROR_TRY_AGAIN}'))
<IGNORE>(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : tryAgainMsg))</IGNORE>
);
});
}

View File

@@ -1,8 +1,5 @@
<form method="post" action="{action}" id="opt_form" class="form">
<form method="post" action="{action}" id="opt_form" class="form p-3">
<!-- admin configs tr extra begin -->
{options}
<!-- admin configs tr extra -->

View File

@@ -232,6 +232,8 @@ function get_kleeja_link(link) {
}
</script>
<IF ISSET="extra_admin_footer_code">
{extra_admin_footer_code}
</IF>
</body>
</html>

View File

@@ -43,7 +43,9 @@
var STYLE_PATH_ADMIN = '{STYLE_PATH_ADMIN}';
var go_to = '{go_to}';
</script>
<IF ISSET="extra_admin_header_code">
{extra_admin_header_code}
</IF>
</head>
<body class="fixed-nav sticky-footer bg-{admin_theme_color}" id="page-top">
@@ -68,17 +70,17 @@
<li class="nav-item<IF NAME="go_to==start"> activex</IF>" data-toggle="tooltip" data-placement="right" title="{lang.R_CPINDEX}">
<a class="first-level nav-link <IF NAME="go_to==start">nav-link-collapse</IF>" href="./"><i class="fa fa-fw fa-dashboard"></i> {lang.R_CPINDEX}</a>
<ul class="sidenav-second-level<IF NAME="go_to!=start"> collapse</IF>" id="collapseIndex">
<IF NAME="go_to==start">{go_menu_html}</IF>
<IF NAME="go_to==start" AND="" ISSET="go_menu_html">{go_menu_html}</IF>
</ul>
</li>
<LOOP NAME="adm_extensions_menu">
<li class="nav-item ({{current}}?activex:)" id="menu_item{{i}}" data-toggle="tooltip" data-placement="right" title="{{title}}">
<a class="first-level nav-link<IF LOOP="current"><IF NAME="go_menu_html"> nav-link-collapse</IF></IF>" title="{{title}}" href="{{link}}"<IF LOOP="confirm"> onclick="return confirm_form();"</IF>>
<a class="first-level nav-link<IF LOOP="current"><IF ISSET="go_menu_html"> nav-link-collapse</IF></IF>" title="{{title}}" href="{{link}}"<IF LOOP="confirm"> onclick="return confirm_form();"</IF>>
<i class="fa fa-fw fa-{{icon}}"></i> {{title}} {{bubble}}
</a>
<IF NAME="go_menu_html">
<IF ISSET="go_menu_html">
<ul class="sidenav-second-level<IF LOOP="current"><ELSE> collapse</IF>" id="collapseItem{{i}}">
<IF LOOP="current">{go_menu_html}</IF>
</ul>

View File

@@ -21,7 +21,7 @@
<IF NAME="no_results">
<div class="alert alert-info">
<h2>{lang.NO_RESULT_USE_SYNC}</h2>
{lang.NO_RESULT_USE_SYNC}
</div>
<ELSE>

View File

@@ -37,35 +37,42 @@
<LOOP NAME="installed_plugins">
<div class="col-sm-12 col-md-3 mt-2">
<div class="card">
<img class="card-img-top" src="{{icon}}" alt="{{plg_name}}">
<div class="card-body">
<h4 class="card-title" style="max-height: 30px; min-height: 30px; overflow-y: auto">
<img class="card-img-top img-responsive" src="{{icon}}" alt="{{plg_name}}">
<div class="card-img-overlay p-3">
<div class="font-weight-normal px-2 rounded text-white" style="line-height:2; background: rgba(18, 16, 16, 0.4);">
<IF LOOP="plg_disabled">
{{plg_name}}
<i class="fa fa-toggle-off"></i>
<ELSE>
{{extra_info.plugin_title}} {{extra_info.plugin_version}}
</IF>
</h4>
<p class="card-text" style="max-height: 100px; min-height: 100px; overflow-y: auto">
</div>
</div>
<div class="card-body">
<p class="card-text " style="font-size:13px; max-height: 100px; min-height: 50px; overflow-y: auto">
<IF LOOP="plg_disabled">
{{plg_dsc}}
<ELSE>
{{extra_info.plugin_description}}
</IF>
</ELSE>
<br>
<small>{{extra_info.plugin_developer}}</small>
</IF>
</p>
</div>
<div class="card-footer">
<div class="card-footer btn-group">
<IF LOOP="plg_disabled">
<a class="btn btn-outline-primary btn-sm" href="{plugin_enable_link}{{plg_name}}" title="{lang.ENABLE}"><i class="fa fa-toggle-on" title="{lang.ENABLE}"></i> {lang.ENABLE}</a>
<a class="btn btn-outline-secondary btn-sm" href="{plugin_enable_link}{{plg_name}}" title="{lang.ENABLE}"><i class="fa fa-toggle-on" title="{lang.ENABLE}"></i> {lang.ENABLE}</a>
<ELSE>
<a class="btn btn-outline-primary btn-sm" href="{plugin_disable_link}{{plg_name}}" title="{lang.DISABLE}"><i class="fa fa-toggle-off" title="{lang.DISABLE}"></i> {lang.DISABLE}</a>
<IF LOOP="has_settings_page">
<a class="btn btn-outline-secondary btn-sm" href="./?{{extra_info.settings_page}}" title="{lang.R_CONFIGS}"><i class="fa fa-gear" title="{lang.R_CONFIGS}"></i></a>
</IF>
<a class="btn btn-outline-secondary btn-sm" href="{plugin_disable_link}{{plg_name}}" title="{lang.DISABLE}"><i class="fa fa-toggle-off" title="{lang.DISABLE}"></i> {lang.DISABLE}</a>
</IF>
<a class="btn btn-outline-primary btn-sm" href="{plugin_uninstall_link}{{plg_name}}" title="{lang.DELETE}" onclick="javascript:return confirm_form();"><i class="fa fa-remove" title="{lang.DELETE}"></i> {lang.DELETE}</a>
<a class="btn btn-outline-secondary btn-sm" href="{plugin_uninstall_link}{{plg_name}}" title="{lang.DELETE}" onclick="javascript:return confirm_form();"><i class="fa fa-remove" title="{lang.DELETE}"></i> {lang.DELETE}</a>
</div>
</div>
</div>
@@ -149,7 +156,7 @@
</div>
</UNLESS>
<IF NAME="store_plugins_count gt 1" AND="case == check">
<IF NAME="store_plugins_count gt 1" NAME="case == check">
<div class="d-flex justify-content-end my-3">
<button id="updateAllBtn" type="button" onclick="updateAll()" class="btn btn-primary px-5">
<i class="fa fa-flash"></i> {lang.UPDATE_ALL}
@@ -164,7 +171,6 @@
<div class="media-body d-flex justify-content-between">
<div>
<h5 class="mt-0 mb-2">{{title}}</h5>
<div style="direction: ltr;">
<IF NAME="case == check">{{current_version}} → </IF>{{version}}
</div>
@@ -232,7 +238,9 @@ function downloadPlugin(name, nextPlugins) {
.done(function (data) {
if(data.content) {
var info = data.content.split(":::");
$('#installLoading-'+name).removeClass('badge-light').addClass(info[0] != 1 ? 'badge-warning' : 'badge-success');
$('#installLoading-'+name).removeClass('badge-light').addClass(
info[0] != 1 ? 'badge-warning' : 'badge-success'
);
$('#installLoading-'+name).html(info[1]);
} else {
this.fail();
@@ -244,9 +252,10 @@ function downloadPlugin(name, nextPlugins) {
}, 500);
})
.fail(function(data) {
var tryAgainMsg = '{lang.ERROR_TRY_AGAIN}';
$('#downloadBtn-' + name).prop('disabled', false);
$('#installLoading-'+name).removeClass('badge-light').addClass('badge-danger').html(
(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : '{lang.ERROR_TRY_AGAIN}'))
<IGNORE>(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : tryAgainMsg))</IGNORE>
);
});
}

View File

@@ -8,7 +8,7 @@
<div class="card card-inverse card-primary">
<div class="card-body">
<h3 class="card-title">{lang.DEL_CACHE}</h3>
<h5 class="card-title">{lang.DEL_CACHE}</h5>
<a href="{del_cache_link}" class="btn btn-secondary">{lang.DELETE}</a>
</div>
</div>
@@ -17,7 +17,7 @@
<div class="card card-primary card-inverse">
<div class="card-body">
<h3 class="card-title">{lang.ALL_FILES}: {all_files}</h3>
<h5 class="card-title">{lang.ALL_FILES}: {all_files}</h5>
<p class="card-text">{lang.WHY_SYNCING}</p>
<a href="{resync_files_link}" class="btn btn-secondary">{lang.RESYNC}</a>
</div>
@@ -27,7 +27,7 @@
<div class="card card-primary card-inverse">
<div class="card-body">
<h3 class="card-title">{lang.ALL_IMAGES}: {all_images}</h3>
<h5 class="card-title">{lang.ALL_IMAGES}: {all_images}</h5>
<p class="card-text">{lang.WHY_SYNCING}</p>
<a href="{resync_images_link}" class="btn btn-secondary">{lang.RESYNC}</a>
</div>
@@ -37,7 +37,7 @@
<div class="card card-primary card-inverse">
<div class="card-body">
<h3 class="card-title">{lang.USERS_ST}: {all_users}</h3>
<h5 class="card-title">{lang.USERS_ST}: {all_users}</h5>
<p class="card-text">{lang.WHY_SYNCING}</p>
<a href="{resync_users_link}" class="btn btn-secondary">{lang.RESYNC}</a>
</div>
@@ -47,14 +47,14 @@
<div class="card card-primary card-inverse">
<div class="card-body">
<h3 class="card-title">{lang.SIZES_ST}: {all_sizes}</h3>
<h5 class="card-title">{lang.SIZES_ST}: {all_sizes}</h5>
</div>
</div>
<br>
<div class="card card-primary card-inverse">
<div class="card-body">
<h3 class="card-title">{lang.REPAIR_DB_TABLES}</h3>
<h5 class="card-title">{lang.REPAIR_DB_TABLES}</h5>
<p class="card-text">{lang.WHY_SYNCING}</p>
<a href="{repair_tables_link}" class="btn btn-secondary">{lang.SUBMIT}</a>
</div>
@@ -62,7 +62,7 @@
<br>
<div class="card card-primary card-inverse">
<div class="card-body">
<h4 class="card-title">{lang.ADVICE_CRON_LINK}:</h4>
<h5 class="card-title">{lang.ADVICE_CRON_LINK}:</h5>
<p class="card-text">
<input class="form-control" value="{queue_cron_job_url}" readonly="readonly" />
</p>

View File

@@ -4,7 +4,7 @@
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="./">{lang.R_CPINDEX}</a></li>
<li class="breadcrumb-item active">{lang.R_REPORTS}</li>
<IF NAME="current_smt == show_h24"><li class="breadcrumb-item active"> {lang.SHOW_FROM_24H}</li></IF>
<IF NAME="current_smt == 'show_h24'"><li class="breadcrumb-item active"> {lang.SHOW_FROM_24H}</li></IF>
</ol>

View File

@@ -17,7 +17,10 @@ function toggleStartBox(name, hide, current) {
}
})
.fail(function(data) {
$('#boxesErrors>span').html((data.content ? data.content : (data.responseJSON ? data.responseJSON.content : '{lang.ERROR_TRY_AGAIN}')));
var tryAgainMsg = '{lang.ERROR_TRY_AGAIN}';
$('#boxesErrors>span').html(
<IGNORE>(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : tryAgainMsg))</IGNORE>
);
$('#boxesErrors').removeClass('d-none alert-info').addClass('alert-danger');
var itemRemoveClass = current == 1 ? 'cb-disable' : 'cb-enable';
var itemAddClass = current == 0 ? 'cb-disable' : 'cb-enable';

View File

@@ -159,9 +159,10 @@ function downloadStyle(name, nextStyles) {
}, 500);
})
.fail(function(data) {
var tryAgainMsg = '{lang.ERROR_TRY_AGAIN}';
$('#downloadBtn-' + name).prop('disabled', false);
$('#installLoading-'+name).removeClass('badge-light').addClass('badge-danger').html(
(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : '{lang.ERROR_TRY_AGAIN}'))
<IGNORE>(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : tryAgainMsg))</IGNORE>
);
});
}

View File

@@ -32,11 +32,11 @@
<!-- start data table -->
<UNLESS NAME="no_results">
<h3>{lang.ESSENTIAL_GROUPS}</h3>
<h4>{lang.ESSENTIAL_GROUPS}</h4>
<!-- start essential groups -->
<div class="row">
<div class="row mt-3">
<LOOP NAME="e_groups">
@@ -85,9 +85,9 @@
<br>
<h3>{lang.CUSTOM_GROUPS}</h3>
<h4>{lang.CUSTOM_GROUPS}</h4>
<div class="row">
<div class="row mt-3">
<LOOP NAME="c_groups">
@@ -160,7 +160,9 @@
<select class="form-control" id="cfrom" name="cfrom">
<option value="-1">{lang.DEFAULT_GROUP}</option>
<LOOP NAME="e_groups"><IF LOOP="id == 2"><ELSE><option value="{{id}}">{{name}}</option></IF></LOOP>
<IF NAME="c_groups">
<LOOP NAME="c_groups"><option value="{{id}}">{{name}}</option></LOOP>
</IF>
</select>
</div>
@@ -178,6 +180,7 @@
<!-- end delete group modal -->
<IF NAME="c_groups">
<LOOP NAME="c_groups">
<div id="delete_group_{{id}}" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="delAGroup" aria-hidden="true">
@@ -218,6 +221,7 @@
</form>
</div>
</LOOP>
</IF>
<!-- end delete group modal -->
<!-- ********** -->
@@ -250,7 +254,7 @@
</IF>
<IF NAME="GE_INFO">
<IF ISSET="GE_INFO">
<script type="text/javascript">
setTimeout(function() {
$('.infoexts').fadeOut('fast');

View File

@@ -12,8 +12,8 @@
* @ignore
*/
define('IN_KLEEJA', true);
define ('PATH', '../');
define ('IN_ADMIN', true);
define('PATH', '../');
define('IN_ADMIN', true);
require_once PATH . 'includes/common.php';
@@ -39,7 +39,7 @@ get_lang('acp');
//
if (
(empty($_SESSION['ADMINLOGIN']) || $_SESSION['ADMINLOGIN'] != md5(sha1($config['h_key']) . $usrcp->name() . $config['siteurl'])) ||
(empty($_SESSION['USER_SESS']) || $_SESSION['USER_SESS'] != session_id()) ||
(empty($_SESSION['USER_SESS']) || $_SESSION['USER_SESS'] != KJ_SESSION) ||
(empty($_SESSION['ADMINLOGIN_T']) || $_SESSION['ADMINLOGIN_T'] < time())
) {
if (ig('go') && g('go') == 'login')
@@ -48,7 +48,7 @@ if (
{
//login
$ERRORS = [];
$pass_field = 'lpass_' . preg_replace('/[^0-9]/', '', sha1($klj_session . sha1($config['h_key']) . p('kid')));
$pass_field = 'lpass_' . preg_replace('/[^0-9]/', '', sha1(KJ_SESSION . sha1($config['h_key']) . p('kid')));
if (! empty($_SESSION['SHOW_CAPTCHA']))
@@ -79,7 +79,7 @@ if (
{
if ($f = $usrcp->data(p('lname'), p($pass_field), false, 3600*6, true))
{
$_SESSION['USER_SESS'] = session_id();
$_SESSION['USER_SESS'] = KJ_SESSION;
$_SESSION['ADMINLOGIN'] = md5(sha1($config['h_key']) . $usrcp->name() . $config['siteurl']);
//to make sure, sometime setting time from functions doesn't work
$_SESSION['ADMINLOGIN_T'] = time() + 18000;
@@ -115,7 +115,7 @@ if (
$action = './' . basename(ADMIN_PATH) . '?go=login&amp;cp=' . $go_to;
$H_FORM_KEYS = kleeja_add_form_key('admin_login');
$KEY_FOR_WEE = sha1(microtime() . sha1($config['h_key']));
$KEY_FOR_PASS = preg_replace('/[^0-9]/', '', sha1($klj_session . sha1($config['h_key']) . $KEY_FOR_WEE));
$KEY_FOR_PASS = preg_replace('/[^0-9]/', '', sha1(KJ_SESSION . sha1($config['h_key']) . $KEY_FOR_WEE));
$not_you = sprintf($lang['USERNAME_NOT_YOU'], '<a href="' . $config['siteurl'] . 'ucp.php?go=logout">', '</a>');
$show_captcha = ! empty($_SESSION['SHOW_CAPTCHA']);
@@ -427,7 +427,7 @@ if (isset($go_menu))
foreach ($go_menu as $m=>$d)
{
$go_menu_html .= '<li class="' . ($d['current'] ? 'active' : '') . '" id="c_' . $d['goto'] . '">' .
'<a' . ($m == 'site' ? ' target="_blank" ' : ' ') . 'href="' . $d['link'] . '" ' . ($d['confirm'] ? ' onclick="javascript:return confirm_form();"' : '') . '>' .
'<a' . ($m == 'site' ? ' target="_blank" ' : ' ') . 'href="' . $d['link'] . '" ' . (! empty($d['confirm']) ? ' onclick="javascript:return confirm_form();"' : '') . '>' .
$d['name'] . '</a></li>';
}
}

30
do.php
View File

@@ -4,7 +4,7 @@
* @package Kleeja
* @copyright (c) 2007 Kleeja.com
* @license ./docs/license.txt
* hi
*
*/
@@ -13,7 +13,7 @@
* @ignore
*/
define('IN_KLEEJA', true);
define ('IN_DOWNLOAD', true);
define('IN_DOWNLOAD', true);
require_once 'includes/common.php';
@@ -275,7 +275,7 @@ elseif (ig('down') || ig('downf') ||
//is internet explore 8 ?
$is_ie8 = is_browser('ie8');
//is internet explore 6 ?
$is_ie6 = is_browser('ie6');
// $is_ie6 = is_browser('ie6');
$livexts = explode(',', $config['livexts']);
@@ -320,7 +320,7 @@ elseif (ig('down') || ig('downf') ||
$is_live = in_array($t, $livexts) ? true : false;
$SQL->free($result);
$SQL->freeresult($result);
//fix bug where a user can override files wait counter
if (! $is_image && (ig('img') || ig('thmb')))
@@ -332,6 +332,8 @@ elseif (ig('down') || ig('downf') ||
//check if the vistor is new in this page before updating kleeja counter
if (! preg_match('/,' . $ii . ',/i', $usrcp->kleeja_get_cookie('oldvistor')) && ! isset($_SERVER['HTTP_RANGE']))
{
if ($usrcp->group_id() != 1)
{
//updates number of uploads ..
$update_query = [
@@ -359,6 +361,7 @@ elseif (ig('down') || ig('downf') ||
}
}
}
}
else
{
//not exists img or thumb
@@ -414,13 +417,20 @@ elseif (ig('down') || ig('downf') ||
}
}
if (! ($size = @kleeja_filesize($path_file)))
if (! ($size = @filesize($path_file)))
{
$size = $d_size;
}
$name = empty($rn) ? $n : $rn;
$dots_in_name = substr_count($name, '.') - 1;
if ($dots_in_name > 0)
{
$name = preg_replace('/\./', '_', $name, $dots_in_name);
}
if (is_browser('mozilla'))
{
$h_name = "filename*=UTF-8''" . rawurlencode(htmlspecialchars_decode($name));
@@ -487,7 +497,12 @@ elseif (ig('down') || ig('downf') ||
header('Pragma: public');
header('Accept-Ranges: bytes');
header('Content-Description: File Transfer');
//dirty fix
if (! is_browser('chrome') && $ext != 'apk')
{
header("Content-Type: $mime_type");
}
header('Date: ' . gmdate('D, d M Y H:i:s', empty($ftime) ? time() : $ftime) . ' GMT');
//header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $ftime) . ' GMT');
//header('Content-Encoding: none');
@@ -502,10 +517,6 @@ elseif (ig('down') || ig('downf') ||
// header('X-Download-Options: noopen');
//}
//header(($is_ie6 ? 'Expires: -1' : 'Expires: Mon, 26 Jul 1997 05:00:00 GMT'));
//(($is_ie8) ? '; authoritative=true; X-Content-Type-Options: nosniff;' : '')
//add multipart download and resume support
if (isset($_SERVER['HTTP_RANGE']) && $resuming_on)
{
@@ -524,6 +535,7 @@ elseif (ig('down') || ig('downf') ||
}
else
{
header('HTTP/1.1 200 OK');
$partial_length = $size;
header("Content-Length: $partial_length");
}

8
go.php
View File

@@ -53,10 +53,10 @@ switch ($current_go_case)
'ext' => $ext,
'size' => readable_size($size),
'group' => $gid,
'group_name'=> str_replace(['{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'],
'group_name' => str_replace(['{lang.ADMINS}', '{lang.USERS}', '{lang.GUESTS}'],
[$lang['ADMINS'], $lang['USERS'], $lang['GUESTS']],
$d_groups[$gid]['data']['group_name']),
'most_firstrow'=> $same_group == 0 ? true : false,
'most_firstrow' => $same_group == 0 ? true : false,
'firstrow' => $same_group ==0 or $same_group != $gid ? true : false,
'rando' => $rando,
];
@@ -280,7 +280,7 @@ switch ($current_go_case)
$ERRORS['captcha'] = $lang['WRONG_VERTY_CODE'];
}
if ((empty(p('cname')) && $NOT_USER) || empty(p('ctext')) )
if ((empty(p('cname')) && $NOT_USER) || empty(p('ctext')))
{
$ERRORS['cname'] = $lang['EMPTY_FIELDS'] . ' : ' . (empty(p('cname')) && $NOT_USER ? ' [ ' . $lang['YOURNAME'] . ' ] ' : '')
. (empty(p('ctext')) ? ' [ ' . $lang['TEXT'] . ' ] ': '');
@@ -361,7 +361,7 @@ switch ($current_go_case)
if (ig('sure') && g('sure') == 'ok')
{
$query = [
'SELECT'=> 'f.id, f.name, f.folder, f.size, f.type',
'SELECT' => 'f.id, f.name, f.folder, f.size, f.type',
'FROM' => "{$dbprefix}files f",
'WHERE' => "f.code_del='" . $cd . "'",
'LIMIT' => '1',

191
includes/FetchFile.php Normal file
View File

@@ -0,0 +1,191 @@
<?php
/**
*
* @package Kleeja
* @copyright (c) 2007 Kleeja.com
* @license http://www.kleeja.com/license
*
*/
//no for directly open
if (! defined('IN_COMMON'))
{
exit;
}
class FetchFile
{
private $url;
private $timeout = 60;
private $destinationPath = '';
private $maxRedirects = 3;
private $binary = false;
public function __construct($url)
{
$this->url = $url;
}
public static function make($url)
{
return new static($url);
}
public function setTimeOut($seconds)
{
$this->timeout = $seconds;
return $this;
}
public function setDestinationPath($path)
{
$this->destinationPath = $path;
return $this;
}
public function setMaxRedirects($limit)
{
$this->maxRedirects = $limit;
return $this;
}
public function isBinaryFile($val)
{
$this->binary = $val;
return $this;
}
public function get()
{
$fetchType = '';
$allow_url_fopen = function_exists('ini_get')
? strtolower(@ini_get('allow_url_fopen'))
: strtolower(@get_cfg_var('allow_url_fopen'));
if (function_exists('curl_init'))
{
$fetchType = 'curl';
}
elseif (in_array($allow_url_fopen, ['on', 'true', '1']))
{
$fetchType = 'fopen';
}
session_write_close();
$result = null;
is_array($plugin_run_result = Plugins::getInstance()->run('kleeja_fetch_file_start', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if (! empty($fetchType))
{
$result = $this->{$fetchType}();
}
$this->finishUp();
return $result;
}
protected function finishUp()
{
if (defined('KJ_SESSION'))
{
session_id(constant('KJ_SESSION'));
}
session_start();
}
protected function curl()
{
$ch = curl_init($this->url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Kleeja)');
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
if ($this->binary)
{
curl_setopt($ch, CURLOPT_ENCODING, '');
}
//let's open new file to save it in.
if (! empty($this->destinationPath))
{
$out = fopen($this->destinationPath, 'w');
curl_setopt($ch, CURLOPT_FILE, $out);
$result = curl_exec($ch);
if ($result === false)
{
kleeja_log(sprintf("cUrl error (#%d): %s\n", curl_errno($ch), htmlspecialchars(curl_error($ch))));
}
curl_close($ch);
fclose($out);
return true;
}
else
{
$data = curl_exec($ch);
if ($data === false)
{
kleeja_log(sprintf("FetchFile error (curl: #%d): %s\n", curl_errno($ch), htmlspecialchars(curl_error($ch))));
}
curl_close($ch);
return $data;
}
}
protected function fopen()
{
// Setup a stream context
$stream_context = stream_context_create(
[
'http' => [
'method' => 'GET',
'user_agent' => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Kleeja)',
'max_redirects' => $this->maxRedirects + 1,
'timeout' => $this->timeout
]
]
);
$content = @file_get_contents($this->url, false, $stream_context);
// Did we get anything?
if ($content !== false)
{
if (! empty($this->destinationPath))
{
$fp2 = fopen($this->destinationPath, 'w' . ($this->binary ? 'b' : ''));
@fwrite($fp2, $content);
@fclose($fp2);
unset($content);
return true;
}
return $content;
}
else
{
$error = error_get_last();
kleeja_log(sprintf("FetchFile error (stream: #%s): %s\n", $error['type'], $error['message']));
}
return false;
}
}

View File

@@ -86,8 +86,7 @@ interface KleejaUploader
/**
* here happens the magic, call this on upload submit
* @param int $uploadType upload from files input or links
* @return void
*/
public function upload($uploadType);
public function upload();
}

View File

@@ -151,29 +151,9 @@ while ($row=$SQL->fetch_array($result))
@closedir($dh);
}
}
elseif ($row['name'] == 'user_system')
elseif (in_array($row['name'], ['user_system', 'www_url']))
{
//get auth types
//fix previous choices in old kleeja
if (in_array($con['user_system'], ['2', '3', '4']))
{
$con['user_system'] = str_replace(['2', '3', '4'], ['phpbb', 'vb', 'mysmartbb'], $con['user_system']);
}
$authtypes .= '<option value="1"' . ($con['user_system']=='1' ? ' selected="selected"' : '') . '>' . $lang['NORMAL'] . '</option>' . "\n";
if ($dh = @opendir(PATH . 'includes/auth_integration'))
{
while (($file = readdir($dh)) !== false)
{
if (strpos($file, '.php') !== false)
{
$file = trim(str_replace('.php', '', $file));
$authtypes .= '<option value="' . $file . '"' . ($con['user_system'] == $file ? ' selected="selected"' : '') . '>' . $file . '</option>' . "\n";
}
}
@closedir($dh);
}
continue;
}
is_array($plugin_run_result = Plugins::getInstance()->run('while_fetch_adm_config', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -235,6 +215,14 @@ while ($row=$SQL->fetch_array($result))
if (! file_exists(PATH . '.htaccess') && file_exists(PATH . 'htaccess.txt') && function_exists('rename'))
{
rename(PATH . 'htaccess.txt', PATH . '.htaccess');
if (! file_exists(PATH . '.htaccess'))
{
chmod(PATH . '.htaccess', K_FILE_CHMOD);
}
//re-do after chmod
rename(PATH . 'htaccess.txt', PATH . '.htaccess');
}
}
}
@@ -242,7 +230,6 @@ while ($row=$SQL->fetch_array($result))
{
$got_lang = preg_replace('[^a-zA-Z0-9]', '', $new[$row['name']]);
//all groups
foreach ($d_groups as $group_id => $group_info)
{

View File

@@ -75,11 +75,11 @@ if (ip('submit'))
while ($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
@kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name']))
{
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name'] );
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name']);
}
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
@@ -137,7 +137,7 @@ else
{
//
//Delete all user files [only one user]
//Delete all user files [only one user]
//
if (ig('deletefiles'))
{
@@ -168,12 +168,12 @@ else
while ($row=$SQL->fetch_array($result))
{
//delete from folder ..
@kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
@kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name']))
{
@kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name']);
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name']);
}
$is_image = in_array(strtolower(trim($row['type'])), ['gif', 'jpg', 'jpeg', 'bmp', 'png']) ? true : false;
@@ -277,7 +277,7 @@ else
{
//display files or display pics and files only in search
$img_types = ['gif','jpg','png','bmp','jpeg','GIF','JPG','PNG','BMP','JPEG'];
$query['WHERE'] = $query['WHERE'] . (empty($query['WHERE']) ? '' : ' AND ') . "f.type NOT IN ('" . implode("', '", $img_types) . "')";
$query['WHERE'] = (empty($query['WHERE']) ? '' : $query['WHERE'] . ' AND ') . "f.type NOT IN ('" . implode("', '", $img_types) . "')";
}
else
{
@@ -304,7 +304,7 @@ else
//pager
$currentPage= ig('page') ? g('page', 'int') : 1;
$currentPage = ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($files_acp_perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();

View File

@@ -64,16 +64,16 @@ if (ip('submit'))
//delete from folder ..
@kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name'] ))
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name']))
{
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name'] );
@kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name']);
}
$ids[] = $row['id'];
$num++;
$sizes += $row['size'];
}
$SQL->free($result);
$SQL->freeresult($result);
}
@@ -172,7 +172,7 @@ else
}
//pager
$currentPage= ig('page') ? g('page', 'int') : 1;
$currentPage = ig('page') ? g('page', 'int') : 1;
$Pager = new Pagination($images_acp_perpage, $nums_rows, $currentPage);
$start = $Pager->getStartRow();
@@ -228,7 +228,7 @@ else
'time' => date('d-m-Y h:i a', $row['time']),
'user' => (int) $row['user'] == -1 ? $lang['GUST'] : $row['username'],
'is_user' => (int) $row['user'] == -1 ? 0 : 1,
'thumb_link'=> $url_thumb
'thumb_link' => $url_thumb
];
//fix ...

View File

@@ -86,7 +86,7 @@ if ($nums_rows > 0)
'name' => $row['name'],
'mail' => $row['mail'],
'text' => htmlspecialchars($row['text']),
'human_time'=> kleeja_date($row['time']),
'human_time' => kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'ip' => $row['ip'],
'sent' => $row['id'] == $msg_sent,

View File

@@ -86,7 +86,7 @@ if ($nums_rows > 0)
'mail' => $row['mail'],
'url' => $row['url'],
'text' => $row['text'],
'human_time'=> kleeja_date($row['time']),
'human_time' => kleeja_date($row['time']),
'time' => kleeja_date($row['time'], false),
'ip' => $row['ip'],
'sent' => $row['id'] == $msg_sent,

View File

@@ -26,7 +26,7 @@ $action_all = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&am
$cp_users_url = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
//if not normal user system
$user_not_normal = (int) $config['user_system'] != 1 ? true : false;
$user_not_normal = (int) $config['user_system'] != 1;
$is_search = $affected = false;
$GET_FORM_KEY = kleeja_add_form_key_get('adm_users');
$H_FORM_KEYS = kleeja_add_form_key('adm_users');
@@ -135,11 +135,11 @@ if (ig('deleteuserfile'))
while ($row=$SQL->fetch_array($result))
{
//delete from folder ..
kleeja_unlink (PATH . $row['folder'] . '/' . $row['name']);
kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists(PATH . $row['folder'] . '/thumbs/' . $row['name']))
{
kleeja_unlink (PATH . $row['folder'] . '/thumbs/' . $row['name']);
kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name']);
}
$num++;
@@ -237,7 +237,7 @@ elseif (ip('newuser'))
if (empty($ERRORS))
{
$name = (string) $SQL->escape(trim(p('lname')));
$user_salt = (string) substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_salt = (string) substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$pass = (string) $usrcp->kleeja_hash_password($SQL->escape(trim(p('lpass'))) . $user_salt);
$mail = (string) trim(strtolower(p('lmail')));
$clean_name = (string) $usrcp->cleanusername($name);
@@ -349,7 +349,7 @@ if (ip('edituser'))
}
elseif (trim(p('l_pass')) != '')
{
$user_salt = substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_salt = substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$pass = "password = '" . $usrcp->kleeja_hash_password(trim(p('l_pass')) . $user_salt) . "', password_salt='" . $user_salt . "',";
}
@@ -460,7 +460,7 @@ if (ip('newgroup'))
];
$SQL->build($insert_query);
}
$SQL->free($result);
$SQL->freeresult($result);
//copy configs from the other group to this group
$query = [
@@ -480,7 +480,7 @@ if (ip('newgroup'))
];
$SQL->build($insert_query);
}
$SQL->free($result);
$SQL->freeresult($result);
//copy exts from the other group to this group
$query = [
@@ -500,7 +500,7 @@ if (ip('newgroup'))
];
$SQL->build($insert_query);
}
$SQL->free($result);
$SQL->freeresult($result);
//show group-is-added message
delete_cache('data_groups');
@@ -716,7 +716,7 @@ case 'group_acl':
}
$acls[] = [
'acl_title' => ! empty( $lang['ACLS_' . strtoupper($row['acl_name'])] ) ? $lang['ACLS_' . strtoupper($row['acl_name'])] : $olang['ACLS_' . strtoupper($row['acl_name'])],
'acl_title' => ! empty($lang['ACLS_' . strtoupper($row['acl_name'])]) ? $lang['ACLS_' . strtoupper($row['acl_name'])] : $olang['ACLS_' . strtoupper($row['acl_name'])],
'acl_name' => $row['acl_name'],
'acl_can' => (int) $row['acl_can']
];
@@ -818,7 +818,7 @@ case 'group_data':
$gdata = $d_groups[$req_group]['data'];
$query = [
'SELECT' => 'c.name, c.option',
'SELECT' => 'c.name, c.option, c.value',
'FROM' => "{$dbprefix}config c",
'WHERE' => "c.type='groups'",
'ORDER BY' => 'c.display_order ASC'
@@ -852,6 +852,8 @@ case 'group_data':
if ($row['name'] == 'language')
{
$lngfiles = '';
//get languages
if ($dh = @opendir(PATH . 'lang'))
{
@@ -932,50 +934,6 @@ case 'group_exts':
$d_groups[$req_group]['data']['group_name']);
//check if there is klj_exts which means this is an upgraded website !
if (empty($config['exts_upraded1_5']))
{
$ex_exts = $SQL->query("SHOW TABLES LIKE '{$dbprefix}exts';");
if ($SQL->num_rows($ex_exts))
{
$xquery = [
'SELECT' => 'ext, gust_size, user_size, gust_allow, user_allow',
'FROM' => "{$dbprefix}exts",
'WHERE' => 'gust_allow=1 OR user_allow=1',
];
$xresult = $SQL->build($xquery);
$xexts = '';
while ($row=$SQL->fetch_array($xresult))
{
if ($row['gust_allow'])
{
$xexts .= ($xexts == '' ? '' : ',') . "('" . $SQL->escape($row['ext']) . "', 2, " . $row['gust_size'] . ')';
}
if ($row['user_allow'])
{
$xexts .= ($xexts == '' ? '' : ',') . "('" . $SQL->escape($row['ext']) . "', 3, " . $row['user_size'] . ')';
}
}
$SQL->freeresult($result);
//delete prev exts before adding
$query_del = [
'DELETE' => "{$dbprefix}groups_exts",
'WHERE' => 'group_id=2 OR group_id=3'
];
$SQL->build($query_del);
$SQL->query("INSERT INTO {$dbprefix}groups_exts (ext, group_id, size) VALUES " . $xexts . ';');
add_config('exts_upraded1_5', 'done');
}
}
//delete ext?
$DELETED_EXT = $GE_INFO = false;
@@ -1219,7 +1177,7 @@ case 'edit_user':
if (! $SQL->num_rows($SQL->query("SELECT * FROM {$dbprefix}users WHERE id=" . $userid)))
{
kleeja_admin_err('ERROR-NO-USER-FOUND', true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
kleeja_admin_err($lang['NOT_EXSIT_USER'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
}
}
@@ -1230,6 +1188,10 @@ case 'edit_user':
];
$result = $SQL->build($query);
if (! $SQL->num_rows($result))
{
kleeja_admin_err($lang['NOT_EXSIT_USER'], true, '', true, basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php'));
}
$udata = $SQL->fetch_array($result);
$SQL->freeresult($result);

View File

@@ -20,7 +20,7 @@ $stylee = 'admin_search';
$action = basename(ADMIN_PATH) . '?cp=h_search';
//wut the default user system
$default_user_system = (int) $config['user_system'] == 1 ? true : false;
$default_user_system = (int) $config['user_system'] == 1;
$H_FORM_KEYS = kleeja_add_form_key('adm_files_search');
$H_FORM_KEYS2 = kleeja_add_form_key('adm_users_search');
@@ -50,33 +50,13 @@ if (ip('search_file'))
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search', 1);
}
//delete all searches greater than 10
$s_del = [
'SELECT' => 'filter_id',
'FROM' => "{$dbprefix}filters",
'WHERE' => "filter_type='file_search' AND filter_user=" . $userinfo['id'],
'ORDER BY' => 'filter_id DESC',
'LIMIT' => '5, 18446744073709551615'
];
$result = $SQL->build($s_del);
$ids = [];
while ($row=$SQL->fetch_array($result))
{
$ids[] = $row['filter_id'];
}
$SQL->free($result);
if ($ids != '')
{
//delete all searches greater than 3 days
$query_del = [
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
'WHERE' => "filter_type='file_search' AND filter_user=" . $userinfo['id'] . " AND filter_time > " . (time() - 3600 * 24 * 3)
];
$SQL->build($query_del);
}
//add as a file_search filter
$s = array_map('htmlspecialchars', $_POST);
@@ -113,32 +93,14 @@ if (ip('search_user'))
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, basename(ADMIN_PATH) . '?cp=h_search&smt=users', 1);
}
//delete all searches greater than 10
$s_del = [
'SELECT' => 'filter_id',
'FROM' => "{$dbprefix}filters",
'WHERE' => "filter_type='user_search' AND filter_user=" . $userinfo['id'],
'ORDER BY' => 'filter_id DESC',
'LIMIT' => '5, 18446744073709551615'
];
$result = $SQL->build($s_del);
$ids = [];
while ($row=$SQL->fetch_array($result))
{
$ids[] = $row['filter_id'];
}
$SQL->free($result);
if ($ids != '')
{
//delete all searches greater than 3 days
$query_del = [
'DELETE' => "{$dbprefix}filters",
'WHERE' => "filter_id IN('" . implode("', '", $ids) . "')"
'WHERE' => "filter_type='user_search' AND filter_user=" . $userinfo['id'] . " AND filter_time > " . (time() - 3600 * 24 * 3)
];
$SQL->build($query_del);
}
//add as a user_search filter
$s = $_POST;

View File

@@ -74,6 +74,11 @@ switch ($case):
while ($row = $SQL->fetch($result))
{
if (! file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . '/init.php'))
{
continue;
}
$installed_plugins[$row['plg_name']] = $row;
$installed_plugins[$row['plg_name']]['extra_info'] = Plugins::getInstance()->installed_plugin_info($row['plg_name']);
@@ -84,29 +89,35 @@ switch ($case):
? PATH . KLEEJA_PLUGINS_FOLDER . '/' . $row['plg_name'] . '/icon.png'
: $STYLE_PATH_ADMIN . 'images/plugin.png';
foreach (['plugin_title', 'plugin_description'] as $localizedInfo)
$installed_plugins[$row['plg_name']]['has_settings_page'] = ! empty(
$installed_plugins[$row['plg_name']]['extra_info']['settings_page']
) && ! preg_match('/^https?:\/\//', $installed_plugins[$row['plg_name']]['extra_info']['settings_page']);
foreach (['plugin_title', 'plugin_description'] as $localized_info)
{
if (is_array($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]))
if (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localized_info]) &&
is_array($installed_plugins[$row['plg_name']]['extra_info'][$localized_info]))
{
if (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']]))
if (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localized_info][$config['language']]))
{
$installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][$config['language']], 100);
$installed_plugins[$row['plg_name']]['extra_info'][$localized_info] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localized_info][$config['language']], 100);
}
elseif (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en']))
elseif (! empty($installed_plugins[$row['plg_name']]['extra_info'][$localized_info]['en']))
{
$installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo]['en'], 100);
$installed_plugins[$row['plg_name']]['extra_info'][$localized_info] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localized_info]['en'], 100);
}
else
{
$installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localizedInfo][0], 100);
$installed_plugins[$row['plg_name']]['extra_info'][$localized_info] =
shorten_text($installed_plugins[$row['plg_name']]['extra_info'][$localized_info][0], 100);
}
}
}
}
$SQL->free($result);
$SQL->freeresult($result);
//get available plugins
$dh = opendir(PATH . KLEEJA_PLUGINS_FOLDER);
@@ -144,7 +155,7 @@ switch ($case):
{
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$store_catalog = fetch_remote_file($store_link);
$store_catalog = FetchFile::make($store_link)->get();
$store_catalog = json_decode($store_catalog, true);
if (json_last_error() == JSON_ERROR_NONE)
@@ -165,6 +176,20 @@ switch ($case):
continue;
}
if (isset($plugin_info['preview']) && defined('DEV_STAGE'))
{
$plugin_file = $plugin_info['preview'];
}
elseif (isset($plugin_info['file']))
{
$plugin_file = $plugin_info['file'];
}
else
{
continue;
}
if ($case == 'store' && (in_array($plugin_info['name'], $available_plugins_names) ||
! empty($installed_plugins[$plugin_info['name']]))
) {
@@ -175,7 +200,7 @@ switch ($case):
elseif ($case == 'check' && (! empty($installed_plugins[$plugin_info['name']]) &&
version_compare(
strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']),
strtolower($plugin_info['file']['version']),
strtolower($plugin_file['version']),
'>='
) || empty($installed_plugins[$plugin_info['name']]))
) {
@@ -185,7 +210,7 @@ switch ($case):
$store_plugins[$plugin_info['name']] = [
'name' => $plugin_info['name'],
'developer' => $plugin_info['developer'],
'version' => $plugin_info['file']['version'],
'version' => $plugin_file['version'],
'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
'website' => $plugin_info['website'],
'current_version' => ! empty($installed_plugins[$plugin_info['name']]) ? strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']) : '',
@@ -275,7 +300,7 @@ switch ($case):
if (empty($plg_name))
{
if (defined('DEBUG'))
if (defined('DEV_STAGE'))
{
exit('empty($plg_name)');
}
@@ -286,7 +311,7 @@ switch ($case):
{
if (! file_exists(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php'))
{
if (defined('DEBUG'))
if (defined('DEV_STAGE'))
{
exit('!file_exists($plg_name)');
}
@@ -306,7 +331,13 @@ switch ($case):
$kleeja_plugin = [];
include PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php';
//don't show mysql errors
if (! defined('SQL_NO_ERRORS'))
{
define('SQL_NO_ERRORS', true);
}
@include PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plg_name . '/init.php';
$install_callback = $kleeja_plugin[$plg_name]['install'];
$plugin_info = $kleeja_plugin[$plg_name]['information'];
@@ -325,7 +356,10 @@ switch ($case):
//'plugin_kleeja_version_min' => '1.8',
// Max version of Kleeja that's required to run this plugin
//'plugin_kleeja_version_max' => '3.8',
//3.1.0 < 3.1.0
if (! empty($plugin_info['plugin_kleeja_version_min']))
{
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_min'], '<'))
{
kleeja_admin_info(
@@ -338,8 +372,9 @@ switch ($case):
exit;
}
}
if ($plugin_info['plugin_kleeja_version_max'] != '0')
if (! empty($plugin_info['plugin_kleeja_version_max']))
{
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_max'], '>'))
{
@@ -552,7 +587,7 @@ switch ($case):
// plugins avilable in kleeja store
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$catalog_plugins = fetch_remote_file($store_link);
$catalog_plugins = FetchFile::make($store_link)->get();
if ($catalog_plugins)
{
@@ -568,10 +603,24 @@ switch ($case):
continue;
}
if (isset($plugin_info['preview']) && defined('DEV_STAGE'))
{
$plugin_file = $plugin_info['preview'];
}
elseif (isset($plugin_info['file']))
{
$plugin_file = $plugin_info['file'];
}
else
{
continue;
}
$store_plugins[$plugin_info['name']] = [
'name' => $plugin_info['name'],
'plg_version' => $plugin_info['file']['version'],
'url' => $plugin_info['file']['url'],
'plg_version' => $plugin_file['version'],
'url' => $plugin_file['url'],
'kj_min_version' => $plugin_info['kleeja_version']['min'],
'kj_max_version' => $plugin_info['kleeja_version']['max'],
];
@@ -587,7 +636,10 @@ switch ($case):
) {
$plugin_name_link = $store_plugins[$plugin_name]['url'];
$plugin_archive = fetch_remote_file($plugin_name_link, PATH . 'cache/' . $plugin_name . '.zip', 60, false, 10, true);
$plugin_archive = FetchFile::make($plugin_name_link)
->setDestinationPath(PATH . 'cache/' . $plugin_name . '.zip')
->isBinaryFile(true)
->get();
if ($plugin_archive)
{

View File

@@ -16,22 +16,20 @@ if (! defined('IN_ADMIN'))
//for style ..
$stylee = 'admin_ban';
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
$affected = false;
$H_FORM_KEYS_GET = kleeja_add_form_key_get('adm_ban_get');
$H_FORM_KEYS = kleeja_add_form_key('adm_ban');
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
$delete_item = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;' . $H_FORM_KEYS_GET . '&amp;case=del&amp;k=';
$new_item_action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;case=new';
//
// Check form key
//
if (ip('submit'))
{
if (! kleeja_check_form_key('adm_ban'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
}
$case = g('case', 'str', 'view');
$update_ban_content = false;
$query = [
'SELECT' => 'ban',
@@ -40,35 +38,69 @@ $query = [
$result = $SQL->build($query);
$current_ban_data =$SQL->fetch_array($result);
$current_ban_data = $SQL->fetch_array($result);
$SQL->freeresult($result);
$ban = p('ban_text', 'str', $current_ban_data['ban']);
$banned_items = explode('|', $current_ban_data['ban']);
//when submit
if (ip('submit'))
$show_message = false;
if ($case == 'del' && ig('k'))
{
if (! kleeja_check_form_key_get('adm_ban_get'))
{
header('HTTP/1.0 401 Unauthorized');
kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
}
$to_delete = g('k');
$banned_items = array_filter($banned_items, function($item) use ($to_delete, $lang, &$show_message) {
if (md5($item) == $to_delete)
{
$show_message = sprintf($lang['ITEM_DELETED'], $item);
return false;
}
return true;
});
$update_ban_content = $show_message;
}
if ($case == 'new')
{
if (! kleeja_check_form_key('adm_ban'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action, 1);
}
$to_add = p('k', 'str', '');
if (! empty($to_add))
{
$banned_items[] = $to_add;
$show_message = $lang['BAN_UPDATED'];
$update_ban_content = true;
}
}
if ($update_ban_content)
{
$banned_items = array_filter($banned_items);
//update
$update_query = [
'UPDATE' => "{$dbprefix}stats",
'SET' => "ban='" . $SQL->escape($ban) . "'"
'SET' => "ban='" . $SQL->escape(implode('|', $banned_items)) . "'"
];
$SQL->build($update_query);
if ($SQL->affected())
{
$affected = true;
delete_cache('data_ban');
}
}
$SQL->freeresult($result);
//after submit
if (ip('submit'))
{
$text = ($affected ? $lang['BAN_UPDATED'] : $lang['NO_UP_CHANGE_S']);
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
}
array_walk($banned_items, function (&$value, &$key) {
$value = ['content' => $value, 'del_key' => md5($value), 'id' => $key+1];
});

View File

@@ -117,7 +117,7 @@ case 'store':
{
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$store_catalog = fetch_remote_file($store_link);
$store_catalog = FetchFile::make($store_link)->get();
$store_catalog = json_decode($store_catalog, true);
if (json_last_error() == JSON_ERROR_NONE)
@@ -382,7 +382,7 @@ case 'download':
// plugins avilable in kleeja store
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$catalog_styles = fetch_remote_file($store_link);
$catalog_styles = FetchFile::make($store_link)->get();
if ($catalog_styles)
{
@@ -417,7 +417,10 @@ case 'download':
) {
$style_name_link = $store_styles[$style_name]['url'];
$style_archive = fetch_remote_file($style_name_link, PATH . 'cache/' . $style_name . '.zip', 60, false, 10, true);
$style_archive = FetchFile::make($style_name_link)
->setDestinationPath(PATH . 'cache/' . $style_name . '.zip')
->isBinaryFile(true)
->get();
if ($style_archive)
{

View File

@@ -17,9 +17,9 @@ if (! defined('IN_ADMIN'))
//for style ..
$stylee = 'admin_extra';
$current_smt= preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'he'));
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'he'));
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php') . '&amp;smt=' . $current_smt;
$H_FORM_KEYS= kleeja_add_form_key('adm_extra');
$H_FORM_KEYS = kleeja_add_form_key('adm_extra');
//
// Check form key

View File

@@ -54,7 +54,7 @@ if ($current_smt == 'check')
//get data from kleeja github repo
if (! ($version_data = $cache->get('kleeja_repo_version')))
{
$github_data = fetch_remote_file(KLEEJA_VERSION_CHECK_LINK, false, 100);
$github_data = FetchFile::make(KLEEJA_VERSION_CHECK_LINK)->setTimeOut(100)->get();
if (! empty($github_data))
{
@@ -151,7 +151,10 @@ elseif ($current_smt == 'update1')
else
{
// downloaded the last package to cache folder
fetch_remote_file(KLEEJA_LATEST_PACKAGE_LINK . $new_version , PATH . "cache/kleeja-{$new_version}.zip", 60, false, 10, true);
FetchFile::make(KLEEJA_LATEST_PACKAGE_LINK . $new_version)
->setDestinationPath(PATH . "cache/kleeja-{$new_version}.zip")
->isBinaryFile(true)
->get();
if (file_exists(PATH . "cache/kleeja-{$new_version}.zip"))
{
@@ -185,7 +188,8 @@ elseif ($current_smt == 'update2')
$ex_folder = trim($zip->getNameIndex(0), '/');
$zip->extractTo(PATH . 'cache/');
$zip->close();
if(rename(
if (rename(
PATH . "cache/{$ex_folder}",
PATH . "cache/kleeja-{$new_version}"
) === false)
@@ -206,7 +210,7 @@ elseif ($current_smt == 'update2')
{
// move the update file from install folder to cache folder to include it later and delete install folder
// becuse if install folder is exists , it can make some problems if dev mode is not active
if(rename($update_file, PATH . 'cache/update_schema.php') === false)
if (rename($update_file, PATH . 'cache/update_schema.php') === false)
{
copy($update_file, PATH . 'cache/update_schema.php');
}
@@ -293,7 +297,6 @@ elseif ($current_smt == 'update3')
file_get_contents($file->getPathname())
) === false)
{
if (copy($file->getPathname(), $file_path) === false)
{
$update_failed = true;

View File

@@ -40,6 +40,9 @@ if ($case && in_array($case, ['clearc', 'sync_files', 'sync_images', 'sync_users
}
}
$text = '';
switch ($case):
default:
@@ -73,7 +76,6 @@ case 'tables':
$query = 'SHOW TABLE STATUS';
$result = $SQL->query($query);
$text = '';
while ($row=$SQL->fetch_array($result))
{

View File

@@ -29,9 +29,9 @@ $files_sizes = readable_size($stat_sizes);
$users_number = $stat_users;
$last_del_fles = (int) $config['del_f_day'] <= 0 ? $lang['CLOSED_FEATURE'] : kleeja_date($stat_last_f_del);
$php_version = isset($NO_PHPINFO) || ! function_exists('phpinfo') ? phpversion() : 'PHP ' . phpversion();
$mysql_version = 'MySQL ' . $SQL->mysql_version();
$mysql_version = $SQL->server_info();
$max_execution_time = function_exists('ini_get') ? @ini_get('max_execution_time') : @get_cfg_var('max_execution_time');
$upload_max_filesize= function_exists('ini_get') ? @ini_get('upload_max_filesize') : @get_cfg_var('upload_max_filesize');
$upload_max_filesize = function_exists('ini_get') ? @ini_get('upload_max_filesize') : @get_cfg_var('upload_max_filesize');
$post_max_size = function_exists('ini_get') ? @ini_get('post_max_size') : @get_cfg_var('post_max_size');
$memory_limit = function_exists('ini_get') ? @ini_get('memory_limit') : @get_cfg_var('memory_limit');
$s_last_google = $stat_last_google == 0 ? '[ ? ]' : kleeja_date($stat_last_google);
@@ -177,7 +177,7 @@ if (! empty($d_groups) && is_array($d_groups))
// rev: let's say cache is not refreshed, so we will redirect alots of time,
// so update_done will be good solution
//
if (empty($v['last_check']) || ((time() - $v['last_check']) > 3600 * 24 * 10 && $_SERVER['SERVER_NAME'] != 'localhost' && ! ig('update_done')))
if ((empty($v['last_check']) || time() - $v['last_check'] > 3600 * 24 * 10) && ! ig('update_done'))
{
redirect(basename(ADMIN_PATH) . '?cp=p_check_update&amp;show_msg=1');
$SQL->close();

View File

@@ -1,115 +0,0 @@
<?php
/**
*
* @package auth
* @copyright (c) 2007 Kleeja.com
* @license ./docs/license.txt
*
*/
//no for directly open
if (! defined('IN_COMMON'))
{
exit();
}
function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = false, $return_username = false)
{
global $lang, $config, $usrcp, $userinfo;
global $script_path, $script_api_key, $script_cp1256;
//URL must be begin with http://
if (empty($script_path) || $script_path[0] != 'h')
{
big_error('Forum URL must be begin with http://', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'API'));
}
//api key is the key to make the query between the remote script and kleeja more secure !
//this must be changed in the real use
if (empty($script_api_key))
{
big_error('api key', 'To connect to the remote script you have to write the API key ...');
}
$pass = empty($script_cp1256) || ! $script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
$name = empty($script_cp1256) || ! $script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
// @see file : docs/kleeja_(vb,mysmartbb,phpbb)_api.txt
$api_http_query = 'api_key=' . kleeja_base64_encode($script_api_key) . '&' . ($hashed ? 'userid' : 'username') . '=' . urlencode($name) . '&pass=' . kleeja_base64_encode($pass);
//if only username, let tell him in the query
$api_http_query .= $return_username ? '&return_username=1' : '';
//get it
$remote_data = fetch_remote_file($script_path . '?' . $api_http_query);
//no responde
//empty or can not connect
if ($remote_data == false || empty($remote_data))
{
return false;
}
//see kleeja_api.php file
//split the data , the first one is always 0 or 1
//0 : error
//1: ok
$user_info = explode('%|%', kleeja_base64_decode($remote_data));
//omg, it's 0 , 0 : error, lets die here
if ((int) $user_info[0] == 0)
{
return false;
}
//
//if we want username only we have to return it quickly and die here
//
if ($return_username)
{
return empty($script_cp1256) || ! $script_cp1256 ? $user_info[1] : $usrcp->kleeja_utf8($user_info[1]);
}
//
//when loggin to admin, we just want a check, no data setup ..
//
if (! $loginadm)
{
define('USER_ID', $user_info[1]);
define('GROUP_ID', 3);
define('USER_NAME', empty($script_cp1256) || ! $script_cp1256 ? $user_info[2] : $usrcp->kleeja_utf8($user_info[2]));
define('USER_MAIL', $user_info[3]);
define('USER_ADMIN', ((int) $user_info[5] == 1) ? 1 : 0);
}
//user ifo
//and this must be filled with user data comming from url
$userinfo = [];
$userinfo['group_id'] = GROUP_ID;
$user_y = kleeja_base64_encode(serialize(['id'=>USER_ID, 'name'=>USER_NAME, 'mail'=>USER_MAIL, 'last_visit'=>time()]));
//add cookies
if (! $loginadm)
{
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($user_info[1] . '|' . $user_info[4] . '|' . $expire . '|' . sha1(md5($config['h_key'] . $user_info[4]) . $expire) . '|' . GROUP_ID . '|' . $user_y), $expire);
}
//no need after now
unset($pass);
//yes ! he is a real user
return true;
}
//
//return username
//
function kleeja_auth_username ($user_id)
{
return kleeja_auth_login($user_id, false, false, false, false, true);
}
//<-- EOF

View File

@@ -1,58 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>
<title>Powered by Kleeja</title>
<style type="text/css">* {
font-size: 100%;
margin: 0;
padding: 0;
color: #CECFCE;
}
body {
font-family: Tahoma, Arial, sans-serif;
font-size: 100%;
color: #69788E;
margin: 10px 30px;
background: #F7F7F7;
}
a:link, a:visited {
text-decoration: none;
color: #CECFCE;
}
a:active, a:hover {
text-decoration: underline;
color: #111;
}
h1 {
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 1.70em;
font-weight: normal;
color: #333333;
margin-top: 0;
margin-bottom: 10px;
}
.content_box {
border: 1px dashed #CECFCE;
background: #FFFFFF;
padding: 10px;
margin-right: auto;
margin-left: auto;
}</style>
</head>
<body title="&#1603;&#1604;&#1610;&#1580;&#1575;"><br/>
<div class="content_box">
<p>
<a target="_blank" href="http://www.kleeja.com" title="kleeja"></a>
</p>
<br/>
<h1><span style="font-size:250%;color:#D80000;">403 - Access forbidden!</span></h1></div>
<br/>
<div class="content_box"style="font-size: 140%">Powered by Kleeja</div>
</body>
</html>

View File

@@ -1,347 +0,0 @@
<?php
/**
*
* @package auth
* @copyright (c) 2007 Kleeja.com
* @license ./docs/license.txt
*
*/
//no for directly open
if (! defined('IN_COMMON'))
{
exit();
}
//
//Path of config file in phpBB3
//
if (! defined('SCRIPT_CONFIG_PATH'))
{
define('SCRIPT_CONFIG_PATH', '/config.php');
}
function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
{
global $lang, $config, $usrcp, $userinfo;
global $script_path, $script_encoding, $script_srv, $script_db, $script_user, $script_pass, $script_prefix;
//check for last slash /
if (isset($script_path))
{
if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/')
{
$script_path = substr($script_path, 0, strlen($script_path));
}
//get some useful data from phbb config file
if (file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH))
{
include PATH . $script_path . SCRIPT_CONFIG_PATH;
$forum_srv = $dbhost;
$forum_db = $dbname;
$forum_user = $dbuser;
$forum_pass = $dbpasswd;
$forum_prefix = $table_prefix;
if (empty($dbhost))
{
$forum_srv = 'localhost';
}
if (! empty($dbport))
{
$forum_srv .= ':' . $dbport;
}
}
else
{
big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'phpBB3'));
}
}
else
{
$forum_srv = $script_srv;
$forum_db = $script_db;
$forum_user = $script_user;
$forum_pass = $script_pass;
$forum_prefix = $script_prefix;
}
//if no variables of db
if (empty($forum_srv) || empty($forum_user) || empty($forum_db))
{
return;
}
//conecting ...
$SQLBB = new KleejaDatabase($forum_srv, $forum_user, $forum_pass, $forum_db, true);
$SQLBB->set_names('utf8');
unset($forum_pass); // We do not need this any longer
//get utf tools
global $phpbb_root_path, $phpEx;
$phpbb_root_path = PATH . $script_path . '/';
$phpEx = 'php';
define('IN_PHPBB', true);
include_once PATH . $script_path . '/includes/utf/utf_tools.' . $phpEx;
$row_leve = 'user_type';
$admin_level = 3;
$query2 = [
'SELECT' => '*',
'FROM' => "`{$forum_prefix}users`",
];
$query2['WHERE'] = $hashed ? 'user_id=' . intval($name) . " AND user_password='" . $SQLBB->real_escape($pass) . "' " : "username_clean='" . $SQLBB->real_escape(utf8_clean_string($name)) . "'";
if ($return_name)
{
$query2['SELECT'] = 'username';
$query2['WHERE'] = 'user_id=' . intval($name);
}
$query = '';
if (! $hashed)
{
$result2 = $SQLBB->build($query2);
while ($row=$SQLBB->fetch_array($result2))
{
$SQLBB->freeresult($result2);
if ($return_name)
{
return $row['username'];
}
else
{
if (phpbb_check_hash($pass, $row['user_password']))
{
$query = $query2;
}
}
}
}
else
{
$query = $query2;
}
if (empty($query))
{
$SQLBB->close();
return false;
}
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_usrdata_phpbb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result = $SQLBB->build($query);
if ($SQLBB->num_rows($result) != 0)
{
while ($row=$SQLBB->fetch_array($result))
{
if ($SQLBB->num_rows($SQLBB->query("SELECT ban_userid FROM `{$forum_prefix}banlist` WHERE ban_userid=" . intval($row['user_id']))) == 0)
{
if (! $loginadm)
{
define('USER_ID', $row['user_id']);
define('GROUP_ID', ($row[$row_leve] == $admin_level ? '1' : '3'));
define('USER_NAME', $row['username']);
define('USER_MAIL', $row['user_email']);
if ($row[$row_leve] == $admin_level)
{
define('USER_ADMIN', true);
}
}
$userinfo = $row;
$userinfo['group_id'] = ($row[$row_leve] == $admin_level ? '1' : '3');
$user_y = kleeja_base64_encode(serialize(['id'=>$row['user_id'], 'name'=>$row['username'], 'mail'=>$row['user_email'], 'last_visit'=>time()]));
if (! $hashed && ! $loginadm)
{
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt(
$row['user_id'] . '|' .
$row['user_password'] . '|' .
$expire . '|' .
sha1(md5($config['h_key'] . $row['user_password']) . $expire) . '|' .
($row[$row_leve] == $admin_level ? '1' : '3') . '|' .
$user_y
), $expire);
}
is_array($plugin_run_result = Plugins::getInstance()->run('qr_while_usrdata_phpbb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}
else
{
//he is banned from phpBB
$SQLBB->freeresult($result);
unset($pass);
$SQLBB->close();
return false;
}
}
$SQLBB->freeresult($result);
unset($pass);
$SQLBB->close();
return true;
}
else
{
$SQLBB->freeresult($result);
$SQLBB->close();
return false;
}
//dont know why they come here !
return false;
}
function kleeja_auth_username ($user_id)
{
return kleeja_auth_login ($user_id, false, false, 0, false, true);
}
/**
* Check for correct password
*/
function phpbb_check_hash($password, $hash)
{
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (strlen($hash) == 34)
{
return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
}
return (md5($password) === $hash) ? true : false;
}
/**
* Generate salt for hash generation
*/
function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
{
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
{
$iteration_count_log2 = 8;
}
$output = '$H$';
$output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)];
$output .= _hash_encode64($input, 6, $itoa64);
return $output;
}
/**
* Encode hash
*/
function _hash_encode64($input, $count, &$itoa64)
{
$output = '';
$i = 0;
do
{
$value = ord($input[$i++]);
$output .= $itoa64[$value & 0x3f];
if ($i < $count)
{
$value |= ord($input[$i]) << 8;
}
$output .= $itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
{
break;
}
if ($i < $count)
{
$value |= ord($input[$i]) << 16;
}
$output .= $itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
{
break;
}
$output .= $itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
/**
* The crypt function/replacement
*/
function _hash_crypt_private($password, $setting, &$itoa64)
{
$output = '*';
// Check for correct hash
if (substr($setting, 0, 3) != '$H$')
{
return $output;
}
$count_log2 = strpos($itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
{
return $output;
}
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
{
return $output;
}
/**
* We're kind of forced to use MD5 here since it's the only
* cryptographic primitive available in all versions of PHP
* currently in use. To implement our own low-level crypto
* in PHP would result in much worse performance and
* consequently in lower iteration counts and hashes that are
* quicker to crack (by non-PHP code).
*/
if (PHP_VERSION >= 5)
{
$hash = md5($salt . $password, true);
do
{
$hash = md5($hash . $password, true);
} while (--$count);
}
else
{
$hash = pack('H*', md5($salt . $password));
do
{
$hash = pack('H*', md5($hash . $password));
} while (--$count);
}
$output = substr($setting, 0, 12);
$output .= _hash_encode64($hash, 16, $itoa64);
return $output;
}

View File

@@ -1,237 +0,0 @@
<?php
/**
*
* @package auth
* @copyright (c) 2007 Kleeja.com
* @license ./docs/license.txt
*
*/
//no for directly open
if (! defined('IN_COMMON'))
{
exit();
}
//
//Path of config file in vb
//
if (! defined('SCRIPT_CONFIG_PATH'))
{
define('SCRIPT_CONFIG_PATH', '/includes/config.php');
}
function kleeja_auth_login ($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
{
global $lang, $config, $usrcp, $userinfo;
global $script_path, $script_cp1256, $script_srv, $script_db, $script_user, $script_pass, $script_prefix, $script_db_charset;
if (isset($script_path))
{
//check for last slash
if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/')
{
$script_path = substr($script_path, 0, strlen($script_path));
}
$configExists = false;
if (file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH))
{
$configPath = PATH . $script_path . SCRIPT_CONFIG_PATH;
$configExists = true;
}
elseif (file_exists(PATH . $script_path . '/core/includes/config.php'))
{
$configPath = PATH . $script_path . '/core/includes/config.php';
$configExists = true;
$isVB5 = true;
}
//get some useful data from vb config file
if ($configExists)
{
require_once $configPath;
//
//get config from config file
//
$forum_srv = $config['MasterServer']['servername'];
$forum_db = $config['Database']['dbname'];
$forum_user = $config['MasterServer']['username'];
$forum_pass = $config['MasterServer']['password'];
$forum_prefix= $config['Database']['tableprefix'];
if ($config['MasterServer']['port'] != 3306)
{
$forum_srv .= ':' . $config['MasterServer']['port'];
}
//some people change their db charset
if (isset($config['Mysqli']['charset']))
{
$forum_db_charset = $config['Mysqli']['charset'];
}
}
else
{
big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'Vbulletin'));
}
}
else
{
//
//custom config data
//
$forum_srv = $script_srv;
$forum_db = $script_db;
$forum_user = $script_user;
$forum_pass = $script_pass;
$forum_prefix = $script_prefix;
//some people change their db charset
if (isset($script_db_charset))
{
$forum_db_charset = $script_db_charset;
}
}
if (empty($forum_srv) || empty($forum_user) || empty($forum_db))
{
return;
}
$SQLVB = new KleejaDatabase($forum_srv, $forum_user, $forum_pass, $forum_db, true);
if (isset($forum_db_charset))
{ //config
$SQLVB->set_names($forum_db_charset);
}
else
{ //auto
$SQLVB->set_names('latin1');
}
unset($forum_pass); // We do not need this any longer
$pass = empty($script_cp1256) || ! $script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
$name = empty($script_cp1256) || ! $script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
$query_salt = [
'SELECT' => $hashed ? '*' : ($isVB5 ? 'token' : 'salt'),
'FROM' => "`{$forum_prefix}user`",
];
$query_salt['WHERE'] = $hashed ? 'userid=' . intval($name) . ' AND ' . ($isVB5 ? 'token' : 'password') . "='" . $SQLVB->real_escape($pass) . "' AND usergroupid != '8'" : "username='" . $SQLVB->real_escape($name) . "' AND usergroupid != '8'";
//if return only name let's ignore the above
if ($return_name)
{
$query_salt['SELECT'] = 'username';
$query_salt['WHERE'] = 'userid=' . intval($name);
}
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_usrdata_vb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result_salt = $SQLVB->build($query_salt);
if ($SQLVB->num_rows($result_salt) > 0)
{
while ($row1=$SQLVB->fetch_array($result_salt))
{
if ($return_name)
{
return empty($script_cp1256) || ! $script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']);
}
if (! $hashed)
{
$pass = ! $isVB5
? md5(md5($pass) . $row1['salt']) // without normal md5
: crypt(md5($pass), $row1['token']);
$query = [
'SELECT' => '*',
'FROM' => "`{$forum_prefix}user`",
'WHERE' => "username='" . $SQLVB->real_escape($name) . "' AND " . ($isVB5 ? 'token' : 'password') . "='" . $SQLVB->real_escape($pass) . "' AND usergroupid != '8'"
];
$result = $SQLVB->build($query);
if ($SQLVB->num_rows($result) != 0)
{
while ($row=$SQLVB->fetch_array($result))
{
if (! $loginadm)
{
define('USER_ID', $row['userid']);
define('GROUP_ID', ($row['usergroupid'] == 6 ? 1 : 3));
define('USER_NAME', empty($script_cp1256) || ! $script_cp1256 ? $row['username'] : $usrcp->kleeja_utf8($row['username']));
define('USER_MAIL', $row['email']);
define('USER_ADMIN', ($row['usergroupid'] == 6 ? 1 : 0));
}
//define('LAST_VISIT',$row['last_visit']);
$userinfo = $row;
$userinfo['group_id'] = ($row['usergroupid'] == 6 ? 1 : 3);
$user_y = kleeja_base64_encode(serialize(['id'=>$row['userid'], 'name'=>USER_NAME, 'mail'=>$row['email'], 'last_visit'=>time()]));
$hash_key_expire = sha1(md5($config['h_key'] . ($isVB5 ? $row['token'] : $row['password'])) . $expire);
if (! $loginadm)
{
$usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt(
$row['userid'] . '|' .
($isVB5 ? $row['token'] : $row['password']) . '|' .
$expire . '|' .
$hash_key_expire . '|' .
($row['usergroupid'] == 6 ? 1 : 3) . '|' .
$user_y
), $expire);
}
is_array($plugin_run_result = Plugins::getInstance()->run('qr_while_usrdata_vb_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
}
$SQLVB->freeresult($result);
}//nums_sql2
else
{
$SQLVB->close();
return false;
}
}
else
{
if (! $loginadm)
{
define('USER_ID', $row1['userid']);
define('USER_NAME', empty($script_cp1256) || ! $script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']));
define('USER_MAIL', $row1['email']);
define('USER_ADMIN', ($row1['usergroupid'] == 6) ? 1 : 0);
define('GROUP_ID', ($row1['usergroupid'] == 6) ? 1 : 3);
$userinfo = $row1;
$userinfo['group_id'] = ($row1['usergroupid'] == 6 ? 1 : 3);
}
}
}//whil1
$SQLVB->freeresult($result_salt);
unset($pass);
$SQLVB->close();
return true;
}
else
{
$SQLVB->close();
return false;
}
}
function kleeja_auth_username ($user_id)
{
return kleeja_auth_login ($user_id, false, true, 0, false, true);
}

View File

@@ -60,16 +60,6 @@ class cache
public function save($name, $data, $time = 86400)
{
//
//We have problems if APC is enabled, so we disable our cache
//system if it's lodoed to prevent those problems, but we will
//try to fix it in the near future .. I hope that.
//
if (defined('APC_CACHE'))
{
//return;
}
$name = preg_replace('![^a-z0-9_]!i', '_', $name);
$data_for_save = '<?' . 'php' . "\n";
$data_for_save .= '//Cache file, generated for Kleeja at ' . gmdate('d-m-Y h:i A') . "\n\n";

View File

@@ -68,12 +68,12 @@ function kleeja_cpatcha_image()
// We figure a bug that happens when you add font name without './' before it ..
// he search in the Linux fonts cache , but when you add './' he will know it's our font.
//
imagettftext ($image, 16, $angle, rand(50, $x), $y+rand(1, 3), $white, dirname(__FILE__) . '/arial.ttf', $security_code);
imagettftext($image, 16, $angle, rand(50, $x), $y+rand(1, 3), $white, dirname(__FILE__) . '/arial.ttf', $security_code);
//imagettftext ($image, 7, 0, $width-30, $height-4, $white,'./arial.ttf', 'Kleeja');
}
else
{
imagestring ($image, imageloadfont(dirname(__FILE__) . '/arial.gdf'), $x+rand(10, 15), $y-rand(10, 15), $security_code, $white);
imagestring($image, imageloadfont(dirname(__FILE__) . '/arial.gdf'), $x+rand(10, 15), $y-rand(10, 15), $security_code, $white);
//imagestring ($image, 1, $width-35, $height-10, 'Kleeja', ImageColorAllocate($image, 200, 200, 200));
}

View File

@@ -33,10 +33,6 @@ if (@extension_loaded('apc'))
//path
if (! defined('PATH'))
{
if (! defined('__DIR__'))
{
define('__DIR__', dirname(__FILE__));
}
define('PATH', str_replace('/includes', '', __DIR__) . '/');
}
@@ -71,7 +67,16 @@ function kleeja_show_error($error_number, $error_string = '', $error_file = '',
{
switch ($error_number)
{
case E_NOTICE: case E_WARNING: case E_USER_WARNING: case E_USER_NOTICE: case E_STRICT: break;
case E_NOTICE: case E_WARNING: case E_USER_WARNING: case E_USER_NOTICE: case E_STRICT:
if (function_exists('kleeja_log'))
{
$error_name = [
2 => 'Warning', 8 => 'Notice', 512 => 'U_Warning', 1024 => 'U_Notice', 2048 => 'Strict'
][$error_number];
kleeja_log('[' . $error_name . '] ' . basename($error_file) . ':' . $error_line . ' ' . $error_string);
}
break;
default:
header('HTTP/1.1 503 Service Temporarily Unavailable');
@@ -123,8 +128,6 @@ if (! is_bot() && ! isset($_SESSION))
}
//no enough data
if (empty($dbname) || empty($dbuser))
{
@@ -139,13 +142,23 @@ define('K_DIR_CHMOD', defined('HAS_SUEXEC') ? (0755 & ~umask()) : 0755);
include PATH . 'includes/functions_alternative.php';
include PATH . 'includes/version.php';
include PATH . 'includes/mysqli.php';
if (isset($dbtype) && $dbtype == 'sqlite')
{
include PATH . 'includes/sqlite.php';
}
else
{
include PATH . 'includes/mysqli.php';
}
include PATH . 'includes/style.php';
include PATH . 'includes/usr.php';
include PATH . 'includes/pager.php';
include PATH . 'includes/functions.php';
include PATH . 'includes/functions_display.php';
include PATH . 'includes/plugins.php';
include PATH . 'includes/FetchFile.php';
if (defined('IN_ADMIN'))
@@ -161,7 +174,7 @@ if (empty($script_encoding))
}
//start classes ..
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
//no need after now
unset($dbpass);
@@ -187,6 +200,7 @@ while ($row=$SQL->fetch_array($result))
$config[$row['name']] = $row['value'];
}
$SQL->freeresult($result);
//check user or guest
@@ -239,18 +253,14 @@ is_array($plugin_run_result = Plugins::getInstance()->run('boot_common', get_def
*/
date_default_timezone_set('GMT');
//remove PHP version header
header_remove('X-Powered-By');
//kleeja session id
$klj_session = $SQL->escape(session_id());
define('KJ_SESSION', preg_replace('/[^-,a-zA-Z0-9]/', '', session_id()));
//site url must end with /
if ($config['siteurl'])
{
$config['siteurl'] = $config['siteurl'][strlen($config['siteurl'])-1] != '/'
? $config['siteurl'] . '/'
: $config['siteurl'];
}
$config['siteurl'] = rtrim($config['siteurl'], '/') . '/';
//check lang
@@ -384,11 +394,13 @@ if (defined('STOP_CAPTCHA'))
is_array($plugin_run_result = Plugins::getInstance()->run('end_common', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if (function_exists('session_register_shutdown'))
{
session_register_shutdown();
}
else
{
register_shutdown_function('session_write_close');
}
register_shutdown_function(function() {
session_write_close();
$err = error_get_last();
if(is_array($err) && ! empty($err['type']) && in_array($err['type'], [E_ERROR, E_PARSE]))
{
kleeja_log('[FATAL] ' . basename($err['file']) . ':' . $err['line'] . ' ' . $err['message']);
}
});

View File

@@ -68,28 +68,42 @@ function kleeja_detecting_bots()
*/
function get_ban()
{
global $banss, $lang, $tpl, $text, $SQL;
global $banss, $lang, $SQL, $usrcp;
//visitor ip now
$ip = get_ip();
$username = $usrcp->name();
//now .. loop for banned ips
if (is_array($banss) && ! empty($ip))
if (is_array($banss) && (! empty($ip) || ! empty($username)))
{
foreach ($banss as $ip2)
foreach ($banss as $banned_item)
{
$ip2 = trim($ip2);
$banned_item = trim($banned_item);
if (empty($ip2))
if (empty($banned_item))
{
continue;
}
$is_banned = false;
//first .. replace all * with something good .
$replace_it = str_replace('*', '([0-9]{1,3})', $ip2);
if (! empty($ip) && strpos($banned_item, '.') !== false)
{
$replace_it = str_replace('*', '([0-9]{1,3})', $banned_item);
$replace_it = str_replace('.', '\.', $replace_it);
if ($ip == $ip2 || @preg_match('/' . preg_quote($replace_it, '/') . '/i', $ip))
$is_banned = $ip == $banned_item || @preg_match('/' . preg_quote($replace_it, '/') . '/i', $ip);
}
elseif (! empty($username) && $banned_item == $username)
{
$is_banned = true;
}
if ($is_banned)
{
is_array($plugin_run_result = Plugins::getInstance()->run('banned_get_ban_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -202,7 +216,7 @@ function kleeja_get_page()
*/
function _sm_mk_utf8($text)
{
return '=?UTF-8?B?' . kleeja_base64_encode($text) . '?=';
return '=?UTF-8?B?' . base64_encode($text) . '?=';
}
/**
@@ -250,244 +264,6 @@ function send_mail($to, $body, $subject, $fromAddress, $fromName, $bcc = '')
return $mail_sent;
}
/**
* Get remote files
* (c) punbb + Kleeja team
* @param $url
* @param bool $save_in
* @param int $timeout
* @param bool $head_only
* @param int $max_redirects
* @param bool $binary
* @return bool|string|array
*/
function fetch_remote_file($url, $save_in = false, $timeout = 20, $head_only = false, $max_redirects = 10, $binary = false)
{
is_array($plugin_run_result = Plugins::getInstance()->run('kleeja_fetch_remote_file_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
// Quite unlikely that this will be allowed on a shared host, but it can't hurt
if (function_exists('ini_set'))
{
@ini_set('default_socket_timeout', $timeout);
}
$allow_url_fopen = function_exists('ini_get')
? strtolower(@ini_get('allow_url_fopen'))
: strtolower(@get_cfg_var('allow_url_fopen'));
if (function_exists('curl_init'))
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, $head_only);
curl_setopt($ch, CURLOPT_NOBODY, $head_only);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Kleeja)');
curl_setopt($ch, CURLOPT_FAILONERROR, true);
if ($binary)
{
curl_setopt($ch, CURLOPT_ENCODING, '');
}
//let's open new file to save it in.
if ($save_in)
{
$out = @fopen($save_in, 'w');
curl_setopt($ch, CURLOPT_FILE, $out);
@curl_exec($ch);
curl_close($ch);
fclose($out);
}
if ($head_only)
{
// Grab the page
$data = @curl_exec($ch);
$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close();
if ($data !== false && $response_code == '200')
{
return explode("\r\n", str_replace("\r\n\r\n", "\r\n", trim($data)));
}
}
else
{
if (! $save_in)
{
$data = @curl_exec($ch);
curl_close();
}
return $save_in ? true : $data;
}
}
// fsockopen() is the second best thing
elseif (function_exists('fsockopen'))
{
$url_parsed = parse_url($url);
$host = $url_parsed['host'];
$port = empty($url_parsed['port']) || $url_parsed['port'] == 0 ? 80 : $url_parsed['port'];
$path = $url_parsed['path'];
if (isset($url_parsed['query']) && $url_parsed['query'] != '')
{
$path .= '?' . $url_parsed['query'];
}
if (! $fp = @fsockopen($host, $port, $errno, $errstr, $timeout))
{
return false;
}
// Send a standard HTTP 1.0 request for the page
fwrite($fp, ($head_only ? 'HEAD' : 'GET') . " $path HTTP/1.0\r\n");
fwrite($fp, "Host: $host\r\n");
fwrite($fp, 'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Kleeja)' . "\r\n");
fwrite($fp, 'Connection: Close' . "\r\n\r\n");
stream_set_timeout($fp, $timeout);
$stream_meta = stream_get_meta_data($fp);
$fp2 = null;
//let's open new file to save it in.
if ($save_in)
{
$fp2 = @fopen($save_in, 'w' . ($binary ? '' : ''));
}
// Fetch the response 1024 bytes at a time and watch out for a timeout
$in = false;
$h = false;
while (! feof($fp) && ! $stream_meta['timed_out'])
{
$s = fgets($fp, 1024);
if ($save_in)
{
if ($s == "\r\n")
{ //|| $s == "\n")
$h = true;
continue;
}
if ($h)
{
@fwrite($fp2, $s);
}
}
$in .= $s;
$stream_meta = stream_get_meta_data($fp);
}
fclose($fp);
if ($save_in)
{
unset($in);
@fclose($fp2);
return true;
}
// Process 301/302 redirect
if ($in !== false && $max_redirects > 0 && preg_match('#^HTTP/1.[01] 30[12]#', $in))
{
$headers = explode("\r\n", trim($in));
foreach ($headers as $header)
{
if (substr($header, 0, 10) == 'Location: ')
{
$response = fetch_remote_file(substr($header, 10), $save_in, $timeout, $head_only, $max_redirects - 1);
if ($response != false)
{
$headers[] = $response;
}
return $headers;
}
}
}
// Ignore everything except a 200 response code
if ($in !== false && preg_match('#^HTTP/1.[01] 200 OK#', $in))
{
if ($head_only)
{
return explode("\r\n", trim($in));
}
else
{
$content_start = strpos($in, "\r\n\r\n");
if ($content_start !== false)
{
return substr($in, $content_start + 4);
}
}
}
return $in;
}
// Last case scenario, we use file_get_contents provided allow_url_fopen is enabled (any non 200 response results in a failure)
elseif (in_array($allow_url_fopen, ['on', 'true', '1']))
{
// PHP5's version of file_get_contents() supports stream options
if (version_compare(PHP_VERSION, '5.0.0', '>='))
{
// Setup a stream context
$stream_context = stream_context_create(
[
'http' => [
'method' => $head_only ? 'HEAD' : 'GET',
'user_agent' => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Kleeja)',
'max_redirects' => $max_redirects + 1, // PHP >=5.1.0 only
'timeout' => $timeout // PHP >=5.2.1 only
]
]
);
$content = @file_get_contents($url, false, $stream_context);
}
else
{
$content = @file_get_contents($url);
}
// Did we get anything?
if ($content !== false)
{
// Gotta love the fact that $http_response_header just appears in the global scope (*cough* hack! *cough*)
if ($head_only)
{
return $http_response_header;
}
if ($save_in)
{
$fp2 = fopen($save_in, 'w' . ($binary ? 'b' : ''));
@fwrite($fp2, $content);
@fclose($fp2);
unset($content);
return true;
}
return $content;
}
}
return false;
}
/**
* Delete cache
* @param string $name
@@ -1018,9 +794,9 @@ function add_config_r($configs)
function update_config($name, $value, $escape = true, $group = false)
{
global $SQL, $dbprefix, $d_groups, $userinfo;
global $SQL, $dbprefix, $d_groups, $userinfo, $config;
$value = ($escape) ? $SQL->escape($value) : $value;
$value = $escape ? $SQL->escape($value) : $value;
$table = "{$dbprefix}config";
//what if this config is a group-configs related ?
@@ -1076,6 +852,8 @@ function delete_config($name)
{
delete_config($n);
}
return;
}
global $dbprefix, $SQL, $d_groups, $userinfo;
@@ -1115,7 +893,7 @@ function delete_config($name)
//
function update_olang($name, $lang = 'en', $value)
{
global $SQL, $dbprefix;
global $SQL, $dbprefix, $olang;
$update_query = [
@@ -1172,10 +950,13 @@ function delete_olang($words = '', $lang = 'en', $plg_id = 0)
global $dbprefix, $SQL;
if (is_array($words))
{
foreach ((array) $lang as $language)
{
foreach ($words as $w)
{
delete_olang($w, $lang);
delete_olang($w, $language);
}
}
return true;
@@ -1378,7 +1159,7 @@ function klj_clean_old($table, $for = 'all')
$query = [
'SELECT' => 'f.id, f.time',
'DELETE' => "`{$dbprefix}" . $table . '` f',
'FROM' => "`{$dbprefix}" . $table . '` f',
'ORDER BY' => 'f.id ASC',
'LIMIT' => '30',
];
@@ -1503,7 +1284,7 @@ function kleeja_log($text)
}
file_put_contents(
PATH . 'cache/kleeja_log.log',
__DIR__ . '/../cache/kleeja_log.log',
date_format(date_create(), 'Y-m-d h:i:s.ua') . ' | INFO | ' . $text . PHP_EOL,
FILE_APPEND | LOCK_EX
);
@@ -1603,12 +1384,12 @@ function user_can($acl_name, $group_id = 0)
function ig($name)
{
return isset($_GET[$name]) ? true : false;
return isset($_GET[$name]);
}
function ip($name)
{
return isset($_POST[$name]) ? true : false;
return isset($_POST[$name]);
}
function g($name, $type = 'str', $default = '')
@@ -1642,7 +1423,17 @@ function p($name, $type = 'str', $default = '')
*/
function add_to_serve_rules($rules, $unique_id = '')
{
$current_serve_content = file_get_contents(PATH . 'serve.php');
if (! file_exists(PATH . 'plugins_rules.php'))
{
if (! is_writable(PATH))
{
chmod(PATH, K_DIR_CHMOD);
}
file_put_contents(PATH . 'plugins_rules.php', '<?php return [' . PHP_EOL . '];');
}
$current_serve_content = file_get_contents(PATH . 'plugins_rules.php');
$rules = is_array($rules) ? implode(PHP_EOL, $rules) : $rules;
@@ -1651,29 +1442,19 @@ function add_to_serve_rules($rules, $unique_id = '')
$rules = '#start_' . $unique_id . PHP_EOL . $rules . PHP_EOL . '#end_' . $unique_id;
}
if (strpos($current_serve_content, '#end_kleeja_rewrites_rules#') !== false)
{
$current_serve_content = str_replace(
'#end_kleeja_rewrites_rules#',
'#end_kleeja_rewrites_rules#' . PHP_EOL . $rules,
$current_serve_content
);
}
else
{
$current_serve_content = preg_replace(
'/\$rules\s{0,4}=\s{0,4}array\(/',
'$rules = array(' . PHP_EOL . $rules,
'/return\s{0,4}\[/',
'return [' . PHP_EOL . $rules,
$current_serve_content
);
}
if (! is_writable(PATH . 'serve.php'))
if (! is_writable(PATH . 'plugins_rules.php'))
{
chmod(PATH . 'serve.php', K_FILE_CHMOD);
chmod(PATH . 'plugins_rules.php', K_FILE_CHMOD);
}
file_put_contents(PATH . 'serve.php', $current_serve_content);
file_put_contents(PATH . 'plugins_rules.php', $current_serve_content);
return true;
}
@@ -1686,7 +1467,7 @@ function add_to_serve_rules($rules, $unique_id = '')
*/
function remove_from_serve_rules($unique_id)
{
$file = PATH . 'serve.php';
$file = PATH . 'plugins_rules.php';
$current_serve_content = file_get_contents($file);
@@ -1701,9 +1482,9 @@ function remove_from_serve_rules($unique_id)
return false;
}
if (! is_writable(PATH . 'serve.php'))
if (! is_writable(PATH . 'plugins_rules.php'))
{
chmod(PATH . 'serve.php', K_FILE_CHMOD);
chmod(PATH . 'plugins_rules.php', K_FILE_CHMOD);
}
file_put_contents($file, $new_serve_content);

View File

@@ -189,7 +189,7 @@ function get_filter($item, $filter_type = false, $just_value = false, $get_by =
$result = $SQL->build($query);
$v = $SQL->fetch($result);
$SQL->free($result);
$SQL->freeresult($result);
if ($just_value)
{
@@ -242,7 +242,7 @@ function build_search_query($search)
return '';
}
global $SQL;
global $SQL, $dbprefix, $config;
$search['filename'] = ! isset($search['filename']) ? '' : $search['filename'];
$search['username'] = ! isset($search['username']) ? '' : $search['username'];
@@ -256,15 +256,42 @@ function build_search_query($search)
$search['ext'] = ! isset($search['ext']) ? '' : $search['ext'];
$search['user_ip'] = ! isset($search['user_ip']) ? '' : $search['user_ip'];
//if searched by a username
$usernamee = '';
if (! empty($search['username']) && (int) $config['user_system'] == 1)
{
$query = [
'SELECT' => 'u.id',
'FROM' => "{$dbprefix}users u",
'WHERE' => "u.name LIKE '%" . $SQL->escape($search['username']) . "%'"
];
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_usersids_in_build_search_query', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result = $SQL->build($query);
while ($row=$SQL->fetch_array($result))
{
$usernamee .= ($usernamee != '' ? ' OR ' : '') . 'f.user=' . $row['id'];
}
$SQL->freeresult($result);
if(! empty($usernamee))
{
$usernamee = 'AND (' . $usernamee . ')';
}
}
//build query
$file_namee = $search['filename'] != '' ? 'AND (f.real_filename LIKE \'%' . $SQL->escape($search['filename']) . '%\' OR f.name LIKE \'%' . $SQL->escape($search['filename']) . '%\')' : '';
$usernamee = $search['username'] != '' ? 'AND u.name LIKE \'%' . $SQL->escape($search['username']) . '%\'' : '';
$size_than = ' f.size ' . ($search['than']!=1 ? '<=' : '>=') . (intval($search['size']) * 1024) . ' ';
$size_than = ' f.size ' . ($search['than'] != 1 ? '<=' : '>=') . (intval($search['size']) * 1024) . ' ';
$ups_than = $search['ups'] != '' ? 'AND f.uploads ' . ($search['uthan']!=1 ? '<' : '>') . intval($search['ups']) . ' ' : '';
$rep_than = $search['rep'] != '' ? 'AND f.report ' . ($search['rthan']!=1 ? '<' : '>') . intval($search['rep']) . ' ' : '';
$lstd_than = $search['lastdown'] != '' ? 'AND f.last_down =' . (time()-(intval($search['lastdown']) * (24 * 60 * 60))) . ' ' : '';
$exte = $search['ext'] != '' ? "AND f.type IN ('" . implode("', '", @explode(',', $SQL->escape($search['ext']))) . "')" : '';
$ipp = $search['user_ip'] != '' ? 'AND f.user_ip LIKE \'%' . $SQL->escape($search['user_ip']) . '%\' ' : '';
return "$size_than $file_namee $ups_than $exte $rep_than $usernamee $lstd_than $exte $ipp";
}

View File

@@ -20,208 +20,3 @@ if (! defined('IN_COMMON'))
{
exit();
}
if (! function_exists('htmlspecialchars_decode'))
{
function htmlspecialchars_decode($string, $style=ENT_COMPAT)
{
$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $style));
if ($style === ENT_QUOTES)
{
$translation['&#039;'] = '\'';
}
return strtr($string, $translation);
}
}
//
//http://us2.php.net/manual/en/function.str-split.php#84891
if (! function_exists('str_split'))
{
function str_split($string, $string_length=1)
{
if (strlen($string) > $string_length || ! $string_length)
{
do
{
$c = strlen($string);
$parts[] = substr($string, 0, $string_length);
$string = substr($string, $string_length);
} while ($string !== false);
}
else
{
$parts = [$string];
}
return $parts;
}
}
//Custom base64_* functions
function kleeja_base64_encode($str = '')
{
return function_exists('base64_encode') ? base64_encode($str) : base64encode($str);
}
function kleeja_base64_decode($str = '')
{
return function_exists('base64_decode') ? base64_decode($str) : base64decode($str);
}
//http://www.php.net/manual/en/function.base64-encode.php#63270
function base64encode($string = '')
{
if (! function_exists('convert_binary_str'))
{
function convert_binary_str($string)
{
if (strlen($string) <= 0)
{
return;
}
$tmp = decbin(ord($string[0]));
$tmp = str_repeat('0', 8-strlen($tmp)) . $tmp;
return $tmp . convert_binary_str(substr($string, 1));
}
}
$binval = convert_binary_str($string);
$final = '';
$start = 0;
while ($start < strlen($binval))
{
if (strlen(substr($binval, $start)) < 6)
{
$binval .= str_repeat('0', 6-strlen(substr($binval, $start)));
}
$tmp = bindec(substr($binval, $start, 6));
if ($tmp < 26)
{
$final .= chr($tmp+65);
}
elseif ($tmp > 25 && $tmp < 52)
{
$final .= chr($tmp+71);
}
elseif ($tmp == 62)
{
$final .= '+';
}
elseif ($tmp == 63)
{
$final .= '/';
}
elseif (! $tmp)
{
$final .= 'A';
}
else
{
$final .= chr($tmp-4);
}
$start += 6;
}
if (strlen($final)%4>0)
{
$final .= str_repeat('=', 4-strlen($final)%4);
}
return $final;
}
function base64decode($str)
{
$len = strlen($str);
$ret = '';
$b64 = [];
$base64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
$len_base64 = strlen($base64);
for ($i = 0; $i < 256; $i++)
{
$b64[$i] = 0;
}
for ($i = 0; $i < $len_base64; $i++)
{
$b64[ord($base64[$i])] = $i;
}
for ($j=0;$j<$len;$j+=4)
{
for ($i = 0; $i < 4; $i++)
{
$c = ord($str[$j+$i]);
$a[$i] = $c;
$b[$i] = $b64[$c];
}
$o[0] = ($b[0] << 2) | ($b[1] >> 4);
$o[1] = ($b[1] << 4) | ($b[2] >> 2);
$o[2] = ($b[2] << 6) | $b[3];
if ($a[2] == ord('='))
{
$i = 1;
}
elseif ($a[3] == ord('='))
{
$i = 2;
}
else
{
$i = 3;
}
for ($k=0;$k<$i;$k++)
{
$ret .= chr((int) $o[$k] & 255);
}
if ($i < 3)
{
break;
}
}
return $ret;
}
if (! function_exists('filesize'))
{
function kleeja_filesize($filename)
{
$a = fopen($filename, 'r');
fseek($a, 0, SEEK_END);
$filesize = ftell($a);
fclose($a);
return $filesize;
}
}
else
{
function kleeja_filesize($filename)
{
return filesize($filename);
}
}
if (! function_exists('array_column'))
{
function array_column($array, $column_name)
{
return array_map(
function($element) use ($column_name) {
return $element[$column_name];
},
array_values($array)
);
}
}

View File

@@ -98,6 +98,7 @@ function Saaheader($title = '', $extra = '')
header('Pragma: no-cache');
header('x-frame-options: SAMEORIGIN');
header('x-xss-protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
echo $header;
flush();
@@ -117,15 +118,14 @@ function Saafooter()
if ($config['statfooter'] != 0 || defined('DEV_STAGE'))
{
$gzip = $config['gzip'] == '1' ? 'Enabled' : 'Disabled';
$hksys = ! defined('STOP_PLUGINS') ? 'Enabled' : 'Disabled';
$endtime = get_microtime();
$loadtime = number_format($endtime - $starttm, 4);
$queries_num= $SQL->query_num;
$queries_num = $SQL->query_num;
$time_sql = round($SQL->query_num / $loadtime);
$page_url = preg_replace(['/([\&\?]+)debug/i', '/&amp;/i'], ['', '&'], kleeja_get_page());
$link_dbg = user_can('enter_acp') && defined('DEV_STAGE') ? '[ <a href="' . str_replace('&', '&amp;', $page_url) . (strpos($page_url, '?') === false ? '?' : '&amp;') . 'debug">Debug Info ... </a> ]' : '';
$page_stats = "<strong>[</strong> GZIP : $gzip - Generation Time: $loadtime Sec - Queries: $queries_num - Hook System: $hksys <strong>]</strong> " . $link_dbg;
$page_stats = "<strong>[</strong> Generation Time: $loadtime Sec - Queries: $queries_num - Hook System: $hksys <strong>]</strong> " . $link_dbg;
}
$tpl->assign('page_stats', $page_stats);
@@ -267,7 +267,7 @@ function kleeja_debug()
$debug_output = '';
//get memory usage ; code of phpbb
//get memory usage
if (function_exists('memory_get_usage'))
{
if ($memory_usage = memory_get_usage())
@@ -295,7 +295,7 @@ function kleeja_debug()
{
foreach ($SQL->debugr as $key=>$val)
{
echo '<fieldset name="sql" dir="ltr" style="background:white"><legend><em>Query # [' . ($key+1) . '</em>]</legend> ';
echo '<fieldset name="sql" dir="ltr" style="background:white"><legend><em>Query # [' . ($key) . '</em>]</legend> ';
echo '<textarea style="font-family:Courier New,monospace;width:99%; background:#F4F4F4" rows="5" cols="10">' . $val[0] . '';
echo '</textarea> <br />';
echo 'Duration :' . $val[1] . '';
@@ -680,7 +680,10 @@ function kleeja_style_info($style_name)
}
else
{
$inf_r[$t[0]] = $t[1];
if (! empty($t[0]))
{
$inf_r[$t[0]] = empty($t[1]) ? '' : $t[1];
}
}
}
@@ -835,6 +838,8 @@ function kleeja_date($time, $human_time = true, $format = false)
{
global $lang, $config;
$time = intval($time);
if (! defined('TIME_FORMAT'))
{
define('TIME_FORMAT', 'd-m-Y h:i a'); // to be moved to configs later
@@ -842,6 +847,11 @@ function kleeja_date($time, $human_time = true, $format = false)
if (! empty($config['time_zone']) && strpos($config['time_zone'], '/') !== false)
{
if(strpos($config['time_zone'], 'Buraydah') !== false)
{
$config['time_zone'] = 'Asia/Riyadh';
}
$timezone_offset = timezone_offset_get(new DateTimeZone($config['time_zone']), new DateTime);
}
else
@@ -849,7 +859,7 @@ function kleeja_date($time, $human_time = true, $format = false)
$timezone_offset = intval($config['time_zone']) * 60 * 60;
}
if ((time() - $time > (86400 * 9)) || $format || ! $human_time)
if ((time() - $time) > (86400 * 9) || $format || ! $human_time)
{
$format = ! $format ? TIME_FORMAT : $format;
$time = $time + $timezone_offset;
@@ -884,7 +894,7 @@ function kleeja_date($time, $human_time = true, $format = false)
}
else
{
$return = $lang['W_PERIODS_' . $j];
$return = '1 ' . $lang['W_PERIODS_' . $j];
}
$return = $now > $time ? $return . ' ' . $lang['W_AGO']: $lang['W_FROM'] . ' ' . $return;

View File

@@ -20,33 +20,44 @@ define('SQL_LAYER', 'mysqli');
class KleejaDatabase
{
public $connect_id = null;
public $result;
/** @var mysqli */
private $connect_id = null;
/** @var mysqli_result */
private $result = null;
public $dbprefix = '';
private $dbname = '';
public $query_num = 0;
public $in_transaction = 0;
private $in_transaction = 0;
public $debugr = false;
public $show_errors = true;
private $show_errors = true;
/*
* initiate the class
* with basic data
/**
* connect
*
* @param string $host
* @param string $db_username
* @param string $db_password
* @param string $db_name
* @param string $dbprefix
*/
public function __construct($host, $db_username, $db_password, $db_name, $new_link = false)
public function __construct($host, $db_username, $db_password, $db_name, $dbprefix)
{
global $script_encoding;
$port = 3306;
$host .= strpos($host, ':') !== false ? '' : ':';
$this->host = substr($host, 0, strpos($host, ':'));
$this->port = (int) substr($host, strpos($host, ':')+1);
$this->db_username = $db_username;
$this->db_name = $db_name;
$this->db_password = 'hidden';
if (strpos($host, ':') !== false)
{
$host = substr($host, 0, strpos($host, ':'));
$port = (int) substr($host, strpos($host, ':')+1);
}
$this->connect_id = @mysqli_connect($this->host, $this->db_username, $db_password, $this->db_name, (! $this->port ? 3306 : $this->port ));
$this->dbprefix = $dbprefix;
$this->dbname = $db_name;
$this->connect_id = @mysqli_connect($host, $db_username, $db_password, $db_name, $port);
//no error
if (defined('MYSQL_NO_ERRORS'))
if (defined('SQL_NO_ERRORS') || defined('MYSQL_NO_ERRORS'))
{
$this->show_errors = false;
}
@@ -56,19 +67,18 @@ class KleejaDatabase
{
//loggin -> no database -> close connection
$this->close();
$this->error_msg('we can not connect to the server ...');
$this->error_msg('We can not connect to the server ...');
return false;
}
//loggin -> connecting
//connecting
kleeja_log('[Connected] : ' . kleeja_get_page());
if ((! preg_match('/utf/i', strtolower($script_encoding)) && ! defined('IN_LOGINPAGE') && ! defined('IN_ADMIN_LOGIN') && ! defined('DISABLE_INTR')) || (empty($script_encoding) || preg_match('/utf/i', strtolower($script_encoding)) || defined('DISABLE_INTR')))
if (! defined('DISABLE_MYSQL_UTF8'))
{
if (mysqli_set_charset($this->connect_id, 'utf8'))
{
//loggin -> set utf8
kleeja_log('[Set to UTF8] : --> ');
}
}
@@ -76,16 +86,24 @@ class KleejaDatabase
return $this->connect_id;
}
public function __destruct()
{
$this->close();
}
public function is_connected()
{
return ! (is_null($this->connect_id) || empty($this->connect_id));
return ! (is_resource($this->connect_id) || empty($this->connect_id));
}
// close the connection
public function close()
{
if ($this->connect_id)
if (! $this->is_connected())
{
return true;
}
// Commit any remaining transactions
if ($this->in_transaction)
{
@@ -95,12 +113,12 @@ class KleejaDatabase
//loggin -> close connection
kleeja_log('[Closing connection] : ' . kleeja_get_page());
return @mysqli_close($this->connect_id);
}
else
if(! is_resource($this->connect_id))
{
return false;
return true;
}
return @mysqli_close($this->connect_id);
}
// encoding functions
@@ -119,7 +137,7 @@ class KleejaDatabase
return mysqli_character_set_name($this->connect_id);
}
public function mysql_version()
public function version()
{
$vr = $this->query('SELECT VERSION() AS v');
$vs = $this->fetch_array($vr);
@@ -127,14 +145,18 @@ class KleejaDatabase
return preg_replace('/^([^-]+).*$/', '\\1', $vs);
}
/*
* the query func . its so important to do
* the quries and give results
/**
* execute a query
*
* @param string $query
* @param boolean $transaction
* @return bool
*/
public function query($query, $transaction = false)
{
//no connection
if (! $this->connect_id)
if (! $this->is_connected())
{
return false;
}
@@ -150,7 +172,7 @@ class KleejaDatabase
$srartum_sql = get_microtime();
////////////////
if ($transaction == 1 && ! $this->in_transaction)
if ($transaction && ! $this->in_transaction)
{
if (! mysqli_autocommit($this->connect_id, false))
{
@@ -178,7 +200,7 @@ class KleejaDatabase
}
else
{
if ( $transaction == 2 && $this->in_transaction )
if ($this->in_transaction)
{
$this->result = mysqli_commit($this->connect_id);
}
@@ -187,7 +209,7 @@ class KleejaDatabase
//is there any result
if ($this->result)
{
if ($transaction == 2 && $this->in_transaction)
if ($this->in_transaction)
{
$this->in_transaction = false;
@@ -212,12 +234,17 @@ class KleejaDatabase
}
}
// query build
/**
* build structured query ['SELECT' => ..., 'FROM' => ..., ...]
*
* @param array $query
* @return string
*/
public function build($query)
{
$sql = '';
if (isset($query['SELECT']))
if (isset($query['SELECT']) && isset($query['FROM']))
{
$sql = 'SELECT ' . $query['SELECT'] . ' FROM ' . $query['FROM'];
@@ -303,12 +330,12 @@ class KleejaDatabase
return $this->query($sql);
}
// free the memmory from the last results
public function free($query_id = 0)
{
return $this->freeresult($query_id);
}
/**
* free the memmory from the last results
*
* @param integer $query_id optional
* @return bool
*/
public function freeresult($query_id = 0)
{
if (! $query_id)
@@ -327,15 +354,24 @@ class KleejaDatabase
}
}
/*
* if the result is an arry ,
* this func is so important to order them as a array
/**
* fetch results (alias of fetch_array)
*
* @param mysqli_result $query_id
* @return array
*/
public function fetch($query_id = 0)
{
return $this->fetch_array($query_id);
}
/**
* fetch results
*
* @param mysqli_result $query_id
* @return array
*/
public function fetch_array($query_id = 0)
{
if (! $query_id)
@@ -346,9 +382,11 @@ class KleejaDatabase
return $query_id ? mysqli_fetch_array($query_id, MYSQLI_ASSOC) : false;
}
/*
* if we have a result and we have to know
* the number of it , this is a func ..
/**
* return number of rows of result (not efficient)
*
* @param mysqli_result $query_id
* @return int
*/
public function num_rows($query_id = 0)
{
@@ -361,13 +399,22 @@ class KleejaDatabase
}
// last id inserted in sql
/**
* return the id of latest inserted record
*
* @return int
*/
public function insert_id()
{
return $this->connect_id ? mysqli_insert_id($this->connect_id) : false;
return $this->is_connected() ? mysqli_insert_id($this->connect_id) : false;
}
// clean the qurery before insert it
/**
* extra escape
*
* @param string $msg
* @return string
*/
public function escape($msg)
{
$msg = htmlspecialchars($msg, ENT_QUOTES);
@@ -376,62 +423,76 @@ class KleejaDatabase
return $msg;
}
// real escape ..
/**
* @param string|array $msg
* escape
* @param string $msg
* @return int|string
*/
public function real_escape($msg)
{
if (is_array($msg) && ! $this->connect_id)
{
return $msg;
}
if (! $this->connect_id)
{
return 0;
}
//escaping _ made alot of problems
//return addcslashes(mysqli_real_escape_string($this->connect_id, $msg), '%_');
return mysqli_real_escape_string($this->connect_id, $msg);
}
// get affected records
public function affected()
{
return $this->connect_id ? mysqli_affected_rows($this->connect_id) : false;
}
// get the information of mysql server
public function server_info()
{
return 'MySQLi ' . $this->mysql_version;
}
// error message func
public function error_msg($msg)
{
global $dbprefix;
if (! $this->show_errors)
if (! $this->is_connected())
{
return false;
}
$error_no = $this->connect_id ? @mysqli_errno($this->connect_id) : @mysqli_connect_errno();
$error_msg = $this->connect_id ? @mysqli_error($this->connect_id) : @mysqli_connect_error();
return mysqli_real_escape_string($this->connect_id, $msg);
}
/**
* number of affected rows by latest action
*
* @return int
*/
public function affected()
{
return $this->is_connected() ? mysqli_affected_rows($this->connect_id) : false;
}
/**
* information
*
* @return string
*/
public function server_info()
{
return 'MySQLi ' . $this->version();
}
/**
* present error messages
*
* @param string $msg
* @return void
*/
private function error_msg($msg)
{
if (! $this->show_errors)
{
kleeja_log('MySQL: ' . $msg);
return false;
}
[$error_no, $error_msg] = $this->get_error();
$error_sql = @current($this->debugr[$this->query_num+1]);
//some ppl want hide their table names
if (! defined('DEV_STAGE'))
{
$error_sql = preg_replace("#\s{1,3}`*{$dbprefix}([a-z0-9]+)`*\s{1,3}#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_sql);
$error_msg = preg_replace("#{$this->db_name}.{$dbprefix}([a-z0-9]+)#e", "' <span style=\"color:blue\">' . substr('$1', 0, 1) . '</span> '", $error_msg);
$error_sql = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_sql);
$error_msg = preg_replace("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#ie", "' $1 <span style=\"color:blue\">' . substr('$2', 0, 1) . '</span> '", $error_msg);
$error_msg = preg_replace("#\s'([^']+)'@'([^']+)'#ie", "' <span style=\"color:blue\">hidden</span>@$2 '", $error_msg);
$error_sql = preg_replace_callback("#\s{1,3}`*{$this->dbprefix}([a-z0-9]+)`*\s{1,3}#", function($m) {
return ' <span style="color:blue">' . substr($m[1], 0, 1) . '</span> ';
}, $error_sql);
$error_msg = preg_replace_callback("#{$this->dbname}.{$this->dbprefix}([a-z0-9]+)#", function($m) {
return ' <span style="color:blue">' . substr($m[1], 0, 1) . '</span> ';
}, $error_msg);
$error_sql = preg_replace_callback("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#i", function($m) {
return $m[1] . ' <span style="color:blue">' . substr($m[2], 0, 1) . '</span> ';
}, $error_sql);
$error_msg = preg_replace_callback("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#i", function($m) {
return $m[1] . ' <span style="color:blue">' . substr($m[2], 0, 1) . '</span> ';
}, $error_msg);
$error_msg = preg_replace_callback("#\s'([^']+)'@'([^']+)'#i", function($m) {
return ' <span style="color:blue">hidden</span>@' . $m[2] . ' ';
}, $error_msg);
$error_sql = preg_replace("#password\s*=\s*'[^']+'#i", "password='<span style=\"color:blue\">hidden</span>'", $error_sql);
}
@@ -444,12 +505,12 @@ class KleejaDatabase
}
header('HTTP/1.1 500 Internal Server Error');
$error_message = '<html><head><title>ERROR IM MYSQL</title>';
$error_message = '<html><head><title>MYSQL ERROR</title>';
$error_message .= "<style>BODY{font-family:'Tahoma',serif;font-size:12px;}.error {}</style></head><body>";
$error_message .= '<br />';
$error_message .= '<div class="error">';
$error_message .= " <a href='#' onclick='window.location.reload( false );'>click to Refresh this page ...</a><br />";
$error_message .= '<h2>Sorry , There is an error in mysql ' . ($msg !='' ? ", error : $msg" : '') . '</h2>';
$error_message .= '<h2>Sorry , We encountered a MySQL error: ' . ($msg !='' ? $msg : '') . '</h2>';
if ($error_sql != '')
{
@@ -479,10 +540,14 @@ class KleejaDatabase
exit();
}
// return last error
/**
* return last error as [code, message]
*
* @return array
*/
public function get_error()
{
if ($this->connect_id)
if ($this->is_connected())
{
return [@mysqli_errno($this->connect_id), @mysqli_error($this->connect_id)];
}
@@ -491,6 +556,6 @@ class KleejaDatabase
return [@mysqli_connect_errno(), @mysqli_connect_error()];
}
}
}//end of class
}
endif;

View File

@@ -6,6 +6,7 @@
* @license http://www.kleeja.com/license
*
*/
//no for directly open
if (! defined('IN_COMMON'))
{
@@ -74,7 +75,7 @@ class Plugins
{
$this->installed_plugins[$row['plg_name']] = $row['plg_ver'];
}
$SQL->free($result);
$SQL->freeresult($result);
$this->load_enabled_plugins();

563
includes/sqlite.php Executable file
View File

@@ -0,0 +1,563 @@
<?php
/**
*
* @package Kleeja
* @copyright (c) 2007 Kleeja.com
* @license ./docs/license.txt
*
*/
//no for directly open
if (! defined('IN_COMMON'))
{
exit();
}
if (! defined('SQL_LAYER')):
define('SQL_LAYER', 'sqlite');
class KleejaDatabase
{
/** @var SQLITE3 */
private $connect_id = null;
/** @var SQLite3Result */
private $result = null;
public $dbprefix = '';
private $dbname = '';
public $query_num = 0;
private $in_transaction = 0;
public $debugr = false;
private $show_errors = true;
/**
* connect
*
* @param string $location path of sqlite database
* @param string $db_username not needed
* @param string $db_password not needed
* @param string $db_name not needed
* @param string $dbprefix tables prefix
*/
public function __construct($location, $db_username, $db_password, $db_name, $dbprefix)
{
try
{
$this->connect_id = new SQLite3(PATH . $db_name, SQLITE3_OPEN_READWRITE);
}
catch (Exception $e)
{
//...
}
$this->dbprefix = $dbprefix;
$this->dbname = $db_name;
//no error
if (defined('SQL_NO_ERRORS'))
{
$this->show_errors = false;
}
if (! $this->connect_id)
{
//loggin -> no database -> close connection
$this->close();
$this->error_msg('We can not connect to the sqlite database, check location or existence of the SQLite dirver ...');
return false;
}
//connecting
kleeja_log('[Connected] : ' . kleeja_get_page());
return $this->connect_id;
}
public function __destruct()
{
$this->close();
}
public function is_connected()
{
return ! (is_null($this->connect_id) || empty($this->connect_id));
}
// close the connection
public function close()
{
if (! $this->is_connected())
{
return true;
}
// Commit any remaining transactions
if ($this->in_transaction)
{
$this->query('COMMIT;');
}
//loggin -> close connection
kleeja_log('[Closing connection] : ' . kleeja_get_page());
if (! is_resource($this->connect_id))
{
return true;
}
return @mysqli_close($this->connect_id);
}
// encoding functions
public function set_utf8()
{
//$this->set_names('utf8');
}
public function set_names($charset)
{
}
public function client_encoding()
{
}
public function version()
{
return SQLite3::version();
}
/**
* execute a query
*
* @param string $query
* @param boolean $transaction
* @return bool
*/
public function query($query, $transaction = false)
{
//no connection
if (! $this->is_connected())
{
return false;
}
//
// Remove any pre-existing queries
//
unset($this->result);
if (strpos($query, 'CREATE TABLE') !== false || strpos($query, 'ALTER DATABASE') !== false)
{
$sqlite_types = [
'/AUTO_INCREMENT/i' => '',
'/VARCHAR\s?(\\([0-9]+\\))?/i' => 'TEXT',
'/COLLATE\s+([a-z0-9_]+)/i' => '',
'/(TINY|SMALL|MEDIUM|BIG)?INT\s?(\([0-9]+\))?\s?(UNSIGNED)?/i' => 'INTEGER ',
'/(TINY|MEDIUM|LONG)?TEXT/i' => 'TEXT',
'/KEY\s`?([a-z0-9_]+)`?\s\(`?([a-z0-9_]+)`?(\([0-9]+\))?\)\s?,?/i' => '',
'/\)(\s{0,4}ENGINE=([a-z0-9_]+))?(\s{0,4}DEFAULT)?(\s{0,4}CHARSET=([a-z0-9_]+))?(\s{0,4}COLLATE=([a-z0-9_]+))?(\s{0,4}AUTOINCREMENT)?(\s{0,4}=\s?1)?(\s{0,4};)?/i' => ')',
'/,\s+\)/' => ')',
'/INTEGER\s{0,4}NOT\s{0,4}NULL/i' => 'INTEGER',
];
//todo extract keys and add as CREATE INDEX index_name ON table (column);
foreach ($sqlite_types as $old_type => $new_type)
{
$query = preg_replace($old_type, $new_type, $query);
}
}
if (! empty($query))
{
//debug
$srartum_sql = get_microtime();
if ($transaction && ! $this->in_transaction)
{
$this->query('BEGIN;');
$this->in_transaction = true;
}
$this->result = @$this->connect_id->query($query);
//debug .. //////////////
$this->debugr[$this->query_num+1] = [$query, sprintf('%.5f', get_microtime() - $srartum_sql)];
////////////////
if (! $this->result)
{
$this->error_msg('Error In query');
}
else
{
//let's debug it
kleeja_log('[Query] : --> ' . $query);
}
}
else
{
if ($this->in_transaction)
{
$this->result = $this->connect_id->query('COMMIT;');
}
}
//is there any result
if ($this->result)
{
if ($this->in_transaction)
{
$this->in_transaction = false;
if (! $this->connect_id->query('COMMIT;'))
{
$this->connect_id->query('ROLLBACK;');
return false;
}
}
$this->query_num++;
return $this->result;
}
else
{
if ($this->in_transaction)
{
$this->connect_id->query('ROLLBACK;');
$this->in_transaction = false;
}
return false;
}
}
/**
* build structured query ['SELECT' => ..., 'FROM' => ..., ...]
*
* @param array $query
* @return string
*/
public function build($query)
{
$sql = '';
if (isset($query['SELECT']) && isset($query['FROM']))
{
$sql = 'SELECT ' . $query['SELECT'] . ' FROM ' . $query['FROM'];
if (isset($query['JOINS']))
{
foreach ($query['JOINS'] as $cur_join)
{
$sql .= ' ' . key($cur_join) . ' ' . current($cur_join) . ' ON ' . $cur_join['ON'];
}
}
if (! empty($query['WHERE']))
{
$sql .= ' WHERE ' . $query['WHERE'];
}
if (! empty($query['GROUP BY']))
{
$sql .= ' GROUP BY ' . $query['GROUP BY'];
}
if (! empty($query['HAVING']))
{
$sql .= ' HAVING ' . $query['HAVING'];
}
if (! empty($query['ORDER BY']))
{
$sql .= ' ORDER BY ' . $query['ORDER BY'];
}
if (! empty($query['LIMIT']))
{
$sql .= ' LIMIT ' . $query['LIMIT'];
}
}
elseif (isset($query['INSERT']))
{
$sql = 'INSERT INTO ' . $query['INTO'];
if (! empty($query['INSERT']))
{
$sql .= ' (' . $query['INSERT'] . ')';
}
$sql .= ' VALUES(' . $query['VALUES'] . ')';
}
elseif (isset($query['UPDATE']))
{
$sql = 'UPDATE ' . $query['UPDATE'] . ' SET ' . $query['SET'];
if (! empty($query['WHERE']))
{
$sql .= ' WHERE ' . $query['WHERE'];
}
}
elseif (isset($query['DELETE']))
{
$sql = 'DELETE FROM ' . $query['DELETE'];
if (! empty($query['WHERE']))
{
$sql .= ' WHERE ' . $query['WHERE'];
}
}
elseif (isset($query['REPLACE']))
{
$sql = 'REPLACE INTO ' . $query['INTO'];
if (! empty($query['REPLACE']))
{
$sql .= ' (' . $query['REPLACE'] . ')';
}
$sql .= ' VALUES(' . $query['VALUES'] . ')';
}
return $this->query($sql);
}
/**
* free the memmory from the last results
*
* @param SQLite3Result $query_id optional
* @return bool
*/
public function freeresult($query_id = 0)
{
if (! $query_id)
{
$query_id = $this->result;
}
if ($query_id)
{
$query_id->finalize();
return true;
}
else
{
return false;
}
}
/**
* fetch results (alias of fetch_array)
*
* @param SQLite3Result $query_id
* @return array
*/
public function fetch($query_id = 0)
{
return $this->fetch_array($query_id);
}
/**
* fetch results
*
* @param SQLite3Result $query_id
* @return array
*/
public function fetch_array($query_id = 0)
{
if (! $query_id)
{
$query_id = $this->result;
}
if ($query_id && $query_id->numColumns() > 0)
{
return $query_id->fetchArray(SQLITE3_ASSOC);
}
return false;
}
/**
* return number of rows of result (not efficient)
*
* @param SQLite3Result $query_id
* @return int
*/
public function num_rows($query_id = 0)
{
if (! $query_id)
{
$query_id = $this->result;
}
if ($query_id && $results = $query_id->numColumns())
{
return $results;
}
return false;
}
/**
* return the id of latest inserted record
*
* @return int
*/
public function insert_id()
{
return $this->is_connected() ? $this->connect_id->lastInsertRowID() : false;
}
/**
* extra escape
*
* @param string $msg
* @return string
*/
public function escape($msg)
{
$msg = htmlspecialchars($msg, ENT_QUOTES);
$msg = $this->real_escape($msg);
return $msg;
}
/**
* escape
* @param string $msg
* @return int|string
*/
public function real_escape($msg)
{
return SQLite3::escapeString($msg);
}
/**
* number of affected rows by latest action
*
* @return int
*/
public function affected()
{
return $this->is_connected() ? $this->connect_id->changes() : false;
}
/**
* information
*
* @return string
*/
public function server_info()
{
return 'SQLite3 ' . $this->version();
}
/**
* present error messages
*
* @param string $msg
* @return void
*/
private function error_msg($msg)
{
if (! $this->show_errors)
{
kleeja_log('SQLite3: ' . $msg);
return false;
}
[$error_no, $error_msg] = $this->get_error();
$error_sql = @current($this->debugr[$this->query_num+1]);
//some ppl want hide their table names
if (! defined('DEV_STAGE'))
{
$error_sql = preg_replace_callback("#\s{1,3}`*{$this->dbprefix}([a-z0-9]+)`*\s{1,3}#", function($m) {
return ' <span style="color:blue">' . substr($m[1], 0, 1) . '</span> ';
}, $error_sql);
$error_msg = preg_replace_callback("#{$this->dbname}.{$this->dbprefix}([a-z0-9]+)#", function($m) {
return ' <span style="color:blue">' . substr($m[1], 0, 1) . '</span> ';
}, $error_msg);
$error_sql = preg_replace_callback("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#i", function($m) {
return $m[1] . ' <span style="color:blue">' . substr($m[2], 0, 1) . '</span> ';
}, $error_sql);
$error_msg = preg_replace_callback("#\s{1,3}(from|update|into)\s{1,3}([a-z0-9]+)\s{1,3}#i", function($m) {
return $m[1] . ' <span style="color:blue">' . substr($m[2], 0, 1) . '</span> ';
}, $error_msg);
$error_msg = preg_replace_callback("#\s'([^']+)'@'([^']+)'#i", function($m) {
return ' <span style="color:blue">hidden</span>@' . $m[2] . ' ';
}, $error_msg);
$error_sql = preg_replace("#password\s*=\s*'[^']+'#i", "password='<span style=\"color:blue\">hidden</span>'", $error_sql);
}
//is this error related to updating?
$updating_related = false;
if (strpos($error_msg, 'Unknown column') !== false || strpos($error_msg, 'no such table') !== false)
{
$updating_related = true;
}
header('HTTP/1.1 500 Internal Server Error');
$error_message = '<html><head><title>MYSQL ERROR</title>';
$error_message .= "<style>BODY{font-family:'Tahoma',serif;font-size:12px;}.error {}</style></head><body>";
$error_message .= '<br />';
$error_message .= '<div class="error">';
$error_message .= " <a href='#' onclick='window.location.reload( false );'>click to Refresh this page ...</a><br />";
$error_message .= '<h2>Sorry , We encountered a MySQL error: ' . ($msg !='' ? $msg : '') . '</h2>';
if ($error_sql != '')
{
$error_message .= "<br />--[query]-------------------------- <br />$error_sql<br />---------------------------------<br /><br />";
}
$error_message .= "[$error_no : $error_msg] <br />";
if ($updating_related)
{
global $config;
$error_message .= '<br /><strong>Your Kleeja database might be old, try to update it now from: ' . rtrim($config['siteurl'], '/') . '/install</strong>';
$error_message .= "<br /><br><strong>If this error happened after installing a plugin, add <span style=\"background-color:#ccc; padding:2px\">define('STOP_PLUGINS', true);</span> to end of config.php file.</strong>";
}
$error_message .= "<br /><br /><strong>Script: Kleeja <br /><a href='http://www.kleeja.com'>Kleeja Website</a></strong>";
$error_message .= '</b></div>';
$error_message .= '</body></html>';
print $error_message;
//loggin -> error
kleeja_log('[SQL ERROR] : "' . $error_no . ' : ' . $error_msg . '" -->');
@$this->close();
exit();
}
/**
* return last error as [code, message]
*
* @return array
*/
public function get_error()
{
if ($this->connect_id)
{
return [$this->connect_id->lastErrorCode(), $this->connect_id->lastErrorMsg()];
}
else
{
return [0, 'uknown-error-not-connected'];
}
}
}
endif;

View File

@@ -24,6 +24,7 @@ class kleeja_style
/**
* Function to load a template file.
* @param $template_name
* @param null|mixed $style_path
*/
protected function _load_template($template_name, $style_path = null)
{
@@ -118,16 +119,29 @@ class kleeja_style
/**
* Function to parse the Template Tags
* @param mixed $html
* @param mixed $template_name
*/
protected function _parse($html, $template_name = '')
{
is_array($plugin_run_result = Plugins::getInstance()->run('style_parse_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$html = preg_replace_callback('/<IGNORE>(.*?)<\/IGNORE>/is', function($m) {
return '<STRREV>' . strrev($m[1]) . '</STRREV>';
}, $html);
$html = preg_replace(['#<([\?%])=?.*?\1>#s', '#<script\s+language\s*=\s*(["\']?)php\1\s*>.*?</script\s*>#s', '#<\?php(?:\r\n?|[ \n\t]).*?\?>#s'], '', $html);
$html = preg_replace_callback('/\(([{A-Z0-9_\.}\s!=<>]+)\?(.*):(.*)\)/iU', ['kleeja_style', '_iif_callback'], $html);
$html = preg_replace_callback('/\(([{A-Z0-9_\.}\s!=<>]+)\?(.*):(.*)\)/iU', function($m) {
return '<IF NAME="' . $m[1] . '">' . $m[2] . '<ELSE>' . $m[3] . '</IF>';
}, $html);
$html = preg_replace_callback('/<(IF|ELSEIF|UNLESS) (.+)>/iU', ['kleeja_style', '_if_callback'], $html);
$html = preg_replace_callback('/<LOOP\s+NAME\s*=\s*(\"|)+([a-z0-9_\.]{1,})+(\"|)\s*>/i', ['kleeja_style', '_loop_callback'], $html);
$html = preg_replace_callback('/<LOOP\s+NAME\s*=\s*(\"|)+([a-z0-9_\.]{1,})+(\"|)\s*>/i', function($m) {
return '<?php foreach($this->vars["' . (strpos($m[2], '.') !== false ? str_replace('.', '"]["', $m[2]) : $m[2]) . '"] as $key=>$value){ ?>';
}, $html);
$html = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_vars_callback'], $html);
$html = preg_replace_callback('/<STRREV>(.*?)<\/STRREV>/is', function($m) {
return strrev($m[1]);
}, $html);
$rep =
[
@@ -145,19 +159,6 @@ class kleeja_style
return preg_replace(array_keys($rep), array_values($rep), $html);
}
/**
* loop tag
* @param $matches
* @return string
*/
protected function _loop_callback($matches)
{
$var = strpos($matches[2], '.') !== false ? str_replace('.', '"]["', $matches[2]) : $matches[2];
return '<?php foreach($this->vars["' . $var . '"] as $key=>$value){ ?>';
}
/**
* if tag
* @param $matches
@@ -168,11 +169,18 @@ class kleeja_style
$atts = call_user_func(['kleeja_style', '_get_attributes'], $matches[0]);
$condition = '';
foreach (['NAME' => '', 'LOOP' => '', 'AND' => ' && ', 'OR' => ' || '] as $attribute=>$separator)
foreach ([
'NAME' => '', 'LOOP' => '', 'AND' => ' && ', 'OR' => ' || ', 'ISSET' => ' isset', 'EMPTY' => ' empty'
] as $attribute=>$separator)
{
if (! empty($atts[$attribute]))
if (isset($atts[$attribute]))
{
$condition .= $separator . $this->parse_condition($atts[$attribute], ! empty($atts['LOOP']));
$haveParentheses = in_array($attribute, ['ISSET', 'EMPTY']);
$condition .= $separator . ($haveParentheses ? '(' : '') .
$this->parse_condition($atts[$attribute], ! empty($atts['LOOP'])) .
($haveParentheses ? ')' : '')
;
}
}
@@ -181,22 +189,16 @@ class kleeja_style
: (strtoupper($matches[1]) == 'UNLESS' ? '<?php if(!(' . $condition . ')){ ?>' : '<?php }elseif(' . $condition . '){ ?>');
}
/**
* iif tag, if else /if
* @param $matches
* @return string
*/
protected function _iif_callback($matches)
{
return '<IF NAME="' . $matches[1] . '">' . $matches[2] . '<ELSE>' . $matches[3] . '</IF>';
}
protected function parse_condition($condition, $is_loop)
{
$char = [' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>'];
$reps = ['==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>'];
if(trim($condition) == '')
{
return '';
}
$con = str_replace('$this->vars', '[----this-vars----]', $condition);
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr))
@@ -253,8 +255,14 @@ class kleeja_style
preg_match(kleeja_style::reg('var'), $matches, $matches);
}
$var = ! empty($matches[2]) ? str_replace('.', '\'][\'', $matches[2]) : '';
return (! empty($matches[1]) && trim($matches[1]) == '{{') ? '$value[\'' . $var . '\']' : '$this->vars[\'' . $var . '\']';
$var = trim(! empty($matches[2]) ? str_replace('.', '\'][\'', $matches[2]) : '');
if(empty($var))
{
return '';
}
return ! empty($matches[1]) && trim($matches[1]) == '{{' ? '$value[\'' . $var . '\']' : '$this->vars[\'' . $var . '\']';
}
/**
@@ -276,7 +284,7 @@ class kleeja_style
protected function reg($var)
{
$vars = get_class_vars(__CLASS__);
return ($vars['reg'][$var]);
return $vars['reg'][$var];
}
@@ -287,7 +295,7 @@ class kleeja_style
*/
protected function _get_attributes($tag)
{
preg_match_all('/([a-z]+)="(.+)"/iU', $tag, $attribute);
preg_match_all('/([a-z]+)="(.+)?"/iU', $tag, $attribute);
$attributes = [];
@@ -295,15 +303,8 @@ class kleeja_style
{
$att = strtoupper($attribute[1][$i]);
if (preg_match('/NAME|LOOP/', $att))
{
$attributes[$att] = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_var_callback'], $attribute[2][$i]);
}
else
{
$attributes[$att] = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_var_callback_att'], $attribute[2][$i]);
}
}
return $attributes;
}
@@ -356,11 +357,11 @@ class kleeja_style
$eval_on = false;
eval('$eval_on = true;');
$parsed_html = trim($this->_parse($html));
$parsed_html = trim($this->_parse(stripcslashes($html)));
ob_start();
if($eval_on)
if ($eval_on)
{
eval(' ?' . '>' . $parsed_html . '<' . '?php ');
}
@@ -380,6 +381,7 @@ class kleeja_style
/**
* change name of template to be valid
* @param $name
* @param null|mixed $style_path
* @return mixed
*/
protected function re_name_tpl($name, $style_path = null)

View File

@@ -101,7 +101,7 @@ function imagecreatefrombmp($filename)
//read header
$header = fread($f, 54);
$header = unpack( 'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
$header = unpack('c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/' .
'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);

View File

@@ -18,6 +18,7 @@ if (! defined('IN_COMMON'))
/**
* checking the safety and validity of sub-extension of given file
*
* @param mixed $filename
*/
function ext_check_safe($filename)
{
@@ -49,6 +50,7 @@ function ext_check_safe($filename)
/**
* create htaccess files for uploading folder
* @param mixed $folder
*/
function generate_safety_htaccess($folder)
{
@@ -123,6 +125,10 @@ function make_folder($folder)
/**
* Change the file name depend on given decoding type
* @param mixed $filename
* @param mixed $i_loop
* @param mixed $ext
* @param mixed $decoding_type
*/
function change_filename_decoding($filename, $i_loop, $ext, $decoding_type = '')
{
@@ -151,7 +157,7 @@ function change_filename_decoding($filename, $i_loop, $ext, $decoding_type = '')
// exists before, change it a little
elseif ($decoding_type == 'exists')
{
$return = substr($filename, 0, -(strlen($ext)+1)) . '_' . substr(md5( microtime(true) . $i_loop), rand(0, 20), 5) . '.' . $ext;
$return = substr($filename, 0, -(strlen($ext)+1)) . '_' . substr(md5(microtime(true) . $i_loop), rand(0, 20), 5) . '.' . $ext;
}
//nothing
else
@@ -168,6 +174,7 @@ function change_filename_decoding($filename, $i_loop, $ext, $decoding_type = '')
/**
* Change the file name depend on used templates {rand:..} {date:..}
* @param mixed $filename
*/
function change_filename_templates($filename)
{
@@ -191,6 +198,9 @@ function change_filename_templates($filename)
/**
* check mime type of uploaded file
* @return bool
* @param mixed $given_file_mime
* @param mixed $file_ext
* @param mixed $file_path
*/
function check_mime_type($given_file_mime, $file_ext, $file_path)
{
@@ -246,7 +256,7 @@ function check_mime_type($given_file_mime, $file_ext, $file_path)
//if normal checks failed!
if (@kleeja_filesize($file_path) > 6*(1000*1024))
if (@filesize($file_path) > 6*(1000*1024))
{
return true;
}
@@ -276,6 +286,7 @@ function check_mime_type($given_file_mime, $file_ext, $file_path)
/**
* to prevent flooding at uploading
* @param mixed $user_id
*/
function user_is_flooding($user_id = '-1')
{

View File

@@ -1,74 +0,0 @@
<?php
/**
*
* @package Kleeja_up_helpers
* @copyright (c) 2007-2012 Kleeja.com
* @license ./docs/license.txt
*
*/
//no for directly open
if (! defined('IN_COMMON'))
{
exit();
}
//
// This helper is used to help in remote uploading
//
/**
* bring the file size from remote file; aka url
*/
function get_remote_file_size($url, $method = 'GET', $data = '', $redirect = 10)
{
$url = parse_url($url);
$fp = @fsockopen ($url['host'], (! empty($url['port']) ? (int) $url['port'] : 80), $errno, $errstr, 30);
if ($fp)
{
$path = (! empty($url['path']) ? $url['path'] : '/') . (! empty($url['query']) ? '?' . $url['query'] : '');
$header = "\r\nHost: " . $url['host'];
if ('post' == strtolower($method))
{
$header .= "\r\nContent-Length: " . strlen($data);
}
fputs ($fp, $method . ' ' . $path . ' HTTP/1.0' . $header . "\r\n\r\n" . ('post' == strtolower($method) ? $data : ''));
if (! feof($fp))
{
$scheme = fgets($fp);
list(, $code ) = explode(' ', $scheme);
$headers = ['Scheme' => $scheme];
}
while (! feof($fp))
{
$h = fgets($fp);
if ($h == "\r\n" OR $h == "\n")
{
break;
}
list($key, $value) = explode(':', $h, 2);
$headers[$key] = trim($value);
if ($code >= 300 AND $code < 400 AND strtolower($key) == 'location' AND $redirect > 0)
{
return get_remote_file_size($headers[$key], $method, $data, --$redirect);
}
}
$body = '';
// while ( !feof($fp) ) $body .= fgets($fp);
fclose($fp);
}
else
{
return (['error' => ['errno' => $errno, 'errstr' => $errstr]]);
}
return (string) $headers['Content-Length'];
}

View File

@@ -76,18 +76,18 @@ function helper_thumb($source_path, $ext, $dest_image, $dw, $dh)
switch ($ext)
{
case 'gif':
$source_gdim = imagecreatefromgif( $source_path );
$source_gdim = imagecreatefromgif($source_path);
break;
case 'jpg':
case 'jpeg':
$source_gdim = imagecreatefromjpeg( $source_path );
$source_gdim = imagecreatefromjpeg($source_path);
break;
case 'png':
$source_gdim = imagecreatefrompng( $source_path );
$source_gdim = imagecreatefrompng($source_path);
break;
@@ -98,7 +98,7 @@ function helper_thumb($source_path, $ext, $dest_image, $dw, $dh)
define('BMP_CLASS_INCLUDED', true);
}
$source_gdim = imagecreatefrombmp( $source_path );
$source_gdim = imagecreatefrombmp($source_path);
break;
}
@@ -123,7 +123,7 @@ function helper_thumb($source_path, $ext, $dest_image, $dw, $dh)
}
// Resize the image into a temporary GD image
$temp_gdim = imagecreatetruecolor( $temp_width, $temp_height );
$temp_gdim = imagecreatetruecolor($temp_width, $temp_height);
imagecopyresampled(
$temp_gdim,
@@ -189,6 +189,10 @@ function helper_thumb($source_path, $ext, $dest_image, $dw, $dh)
/**
* generating thumb from image using Imagick
*
* @param mixed $x
* @param mixed $y
* @param mixed $cx
* @param mixed $cy
*/
function scale_image_imagick($x, $y, $cx, $cy)
{

View File

@@ -24,8 +24,15 @@ if (! defined('IN_COMMON'))
*/
function helper_watermark($name, $ext)
{
$return = false;
is_array($plugin_run_result = Plugins::getInstance()->run('helper_watermark_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if ($return)
{
return;
}
//is this file really exsits ?
if (! file_exists($name))
{
@@ -146,9 +153,9 @@ function helper_watermark_imagick($name, $ext, $logo)
//how big are the images?
$iWidth = $im->getImageWidth();
$iHeight= $im->getImageHeight();
$iHeight = $im->getImageHeight();
$wWidth = $watermark->getImageWidth();
$wHeight= $watermark->getImageHeight();
$wHeight = $watermark->getImageHeight();
if ($iHeight < $wHeight || $iWidth < $wWidth)
{

View File

@@ -19,8 +19,6 @@ if (! defined('IN_COMMON'))
include_once dirname(__file__) . '/../up_helpers/others.php';
include_once dirname(__file__) . '/../up_helpers/thumbs.php';
include_once dirname(__file__) . '/../up_helpers/watermark.php';
include_once dirname(__file__) . '/../up_helpers/remote_uploading.php';
/*
* uploading class, the most important class in Kleeja
@@ -260,8 +258,8 @@ class defaultUploader implements KleejaUploader
$img_html_result .= get_up_tpl_box('image_thumb',
[
'b_title' => $lang['URL_F_THMB'],
'b_url_link'=> kleeja_get_link('image', $file_info),
'b_img_link'=> kleeja_get_link('thumb', $file_info)
'b_url_link' => kleeja_get_link('image', $file_info),
'b_img_link' => kleeja_get_link('thumb', $file_info)
]
);
@@ -276,7 +274,7 @@ class defaultUploader implements KleejaUploader
$img_html_result .= get_up_tpl_box('image',
[
'b_title' => $lang['URL_F_IMG'],
'b_bbc_title'=> $lang['URL_F_BBC'],
'b_bbc_title' => $lang['URL_F_BBC'],
'b_url_link' => kleeja_get_link('image', $file_info),
]
);
@@ -300,7 +298,7 @@ class defaultUploader implements KleejaUploader
$else_html_result = get_up_tpl_box('file',
[
'b_title' => $lang['URL_F_FILE'],
'b_bbc_title'=> $lang['URL_F_BBC'],
'b_bbc_title' => $lang['URL_F_BBC'],
'b_url_link' => kleeja_get_link('file', $file_info),
]
);
@@ -328,14 +326,10 @@ class defaultUploader implements KleejaUploader
* here happens the magic, call this on upload submit
* @param int $uploadType upload from files input or links
*/
public function upload($uploadType)
public function upload()
{
global $usrcp, $config, $lang;
// when $uploadType = 1, then we upload from _file input
// if $uploadType = 2, then we uploading from url which is disabled by default and is buggy
//upload to this folder
$current_uploading_folder = $config['foldername'];
@@ -366,15 +360,8 @@ class defaultUploader implements KleejaUploader
return;
}
//no uploading yet, or just go to index.php, so we have make a new session
if (! $uploadType)
{
unset($_SESSION['FIILES_NOT_DUPLI'], $_SESSION['FIILES_NOT_DUPLI_LINKS']);
}
// is captcha on, and there is uploading going on
if ($captcha_enabled && $uploadType)
if ($captcha_enabled)
{
//captcha is wrong
if (! kleeja_check_captcha())
@@ -394,60 +381,27 @@ class defaultUploader implements KleejaUploader
//detect flooding, TODO fix it or remove it
if ($uploadType == 1 && isset($_SESSION['FIILES_NOT_DUPLI']))
if (isset($_SESSION['FIILES_NOT_DUPLI']))
{
if (! empty($_SESSION['FIILES_NOT_DUPLI']) && $_SESSION['FIILES_NOT_DUPLI'] == sha1(serialize(array_column($_FILES, 'name'))))
{
unset($_SESSION['FIILES_NOT_DUPLI']);
// if(!ip('ajax'))
// {
// redirect('./');
// }
$this->addErrorMessage($lang['U_R_FLOODER']);
return;
}
}
if ($uploadType == 2 && isset($_SESSION['FIILES_NOT_DUPLI_LINKS']))
{
if ($_SESSION['FIILES_NOT_DUPLI_LINKS'] == sha1(serialize($_POST)))
{
unset($_SESSION['FIILES_NOT_DUPLI_LINKS']);
if (! ip('ajax'))
{
redirect('./');
}
$this->addErrorMessage($lang['U_R_FLOODER']);
return;
}
}
// flooding code, making sure every ok session is cleared
if ($uploadType == 1 && sizeof($_FILES) > 0)
if (sizeof($_FILES) > 0)
{
$_SESSION['FIILES_NOT_DUPLI'] = sha1(serialize(array_column($_FILES, 'name')));
}
elseif ($uploadType == 2)
{
$_SESSION['FIILES_NOT_DUPLI_LINKS'] = sha1(serialize($_POST));
}
//now close session to let user open any other page in Kleeja
session_write_close();
// do upload
switch ($uploadType)
{
//uploading from a _files input
default:
case 1:
if (! empty($_FILES['file']['tmp_name']))
{
$_FILES['file'][0] = $_FILES['file'];
@@ -460,7 +414,7 @@ class defaultUploader implements KleejaUploader
//no file!
if (empty($_FILES['file_' . $i . '_']['tmp_name']) && empty($_FILES['file'][$i]['tmp_name']))
{
if (is_null($_FILES['file_' . $i . '_']) && is_null($_FILES['file'][$i]))
if (! isset($_FILES['file_' . $i . '_'], $_FILES['file'][$i]))
{
continue;
}
@@ -527,28 +481,6 @@ class defaultUploader implements KleejaUploader
$this->uploadTypeFile($i, $current_uploading_folder, $current_user_id);
}
break;
//uploading from a url text-input
case 2:
//if not enabled, quit it
if ($config['www_url'] != 1)
{
break;
}
//loop text inputs
for ($i=0; $i<=$this->getUploadFieldsLimit(); $i++)
{
$this->uploadTypeUrl($i, $current_uploading_folder, $current_user_id);
}
break;
}
// well, no file uploaded, ask user to choose a file before submit
if ($this->total_uploaded_files == 0 && sizeof($this->messages) == 0)
@@ -648,7 +580,7 @@ class defaultUploader implements KleejaUploader
}
}
// bad chars in the filename
elseif (preg_match ("#[\\\/\:\*\?\<\>\|\"]#", $fileInfo['generatedFileName']))
elseif (preg_match("#[\\\/\:\*\?\<\>\|\"]#", $fileInfo['generatedFileName']))
{
$this->addErrorMessage(sprintf($lang['WRONG_F_NAME'], htmlspecialchars($_FILES['file_' . $fieldNumber . '_']['name'])));
}
@@ -689,134 +621,4 @@ class defaultUploader implements KleejaUploader
}
}
}
/**
* upload a file from a URL
* @param $fieldNumber
* @param $current_uploading_folder
* @param $current_user_id
*/
public function uploadTypeUrl($fieldNumber, $current_uploading_folder, $current_user_id)
{
global $config, $lang;
$fileInfo = [
'saveToFolder',
'originalFileName',
'generatedFileName',
'fileSize',
'currentUserId',
'fileExtension'
];
$fileInfo['saveToFolder'] = $current_uploading_folder;
$fileInfo['currentUserId'] = $current_user_id;
if (p('file_' . $fieldNumber . '_') == '' || p('file_' . $fieldNumber . '_') == $lang['PAST_URL_HERE'])
{
return;
}
// get file name
$fileInfo['originalFileName'] = basename(p('file_' . $fieldNumber . '_'));
// file extension, type
$fileExtensions = array_map('strtolower', explode('.', $fileInfo['originalFileName']));
if (sizeof($fileExtensions) > 1 && in_array($fileExtensions[sizeof($fileExtensions)-1], ['html', 'php', 'html']))
{
$fileInfo['fileExtension'] = strtolower($fileExtensions[sizeof($fileExtensions)-2]);
}
elseif (sizeof($fileExtensions) > 0)
{
$fileInfo['fileExtension'] = strtolower($fileExtensions[sizeof($fileExtensions)-1]);
}
else
{
$fileInfo['fileExtension'] = ''; //what to do?
}
// change to another filename depend on kleeja settings
$fileInfo['generatedFileName'] = change_filename_decoding($fileInfo['originalFileName'], $fieldNumber, $fileInfo['fileExtension']);
$fileInfo['generatedFileName'] = change_filename_templates(trim($config['prefixname']) . $fileInfo['generatedFileName']);
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_uploadTypeUrl_1st', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//forbbiden type ? quit it
if (! in_array(strtolower($fileInfo['fileExtension']), array_keys($this->getAllowedFileExtensions())))
{
if ($current_user_id == '-1')
{
$this->addErrorMessage(
sprintf($lang['FORBID_EXT'], $fileInfo['fileExtension']) .
'<br> <a href="' . ($config['mod_writer'] ? 'register.html' : 'ucp.php?go=register') . '">' .
$lang['REGISTER'] . '</a>'
);
}
// a member
else
{
$this->addErrorMessage(sprintf($lang['FORBID_EXT'], $fileInfo['fileExtension']));
}
}
// file exists before ? quit it
elseif (file_exists($current_uploading_folder . '/' . $fileInfo['generatedFileName']))
{
$this->addErrorMessage(sprintf($lang['SAME_FILE_EXIST'], htmlspecialchars($fileInfo['generatedFileName'])));
}
// no errors, ok, lets upload now
else
{
is_array($plugin_run_result = Plugins::getInstance()->run('defaultUploader_uploadTypeUrl_2nd', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
//no prefix ? http or even ftp, then add one
if (! in_array(strtolower(substr(p('file_' . $fieldNumber . '_'), 0, 4)), ['http', 'ftp:']))
{
$_POST['file_' . $fieldNumber . '_'] = 'http://' . p('file_' . $fieldNumber . '_');
}
//get size, if big quit it
$fileInfo['fileSize'] = get_remote_file_size(p('file_' . $fieldNumber . '_'));
if ($this->getAllowedFileExtensions()[$fileInfo['fileExtension']] > 0 && $fileInfo['fileSize'] >= $this->getAllowedFileExtensions()[$fileInfo['fileExtension']])
{
$this->addErrorMessage(sprintf(
$lang['SIZE_F_BIG'],
p('file_' . $fieldNumber . '_'),
readable_size($this->getAllowedFileExtensions()[$fileInfo['fileExtension']])
));
}
else
{
//get remote data, if no data quit it
$data = fetch_remote_file(
p('file_' . $fieldNumber . '_'),
$current_uploading_folder . '/' . $fileInfo['generatedFileName'],
15,
false,
2,
true
);
if ($data === false)
{
$this->addErrorMessage($lang['URL_CANT_GET']);
}
else
{
$this->saveToDatabase($fileInfo);
}
}
}
}
}

View File

@@ -17,20 +17,12 @@ if (! defined('IN_COMMON'))
class usrcp
{
// this function like a traffic sign :)
public function data ($name, $pass, $hashed = false, $expire = 86400, $loginadm = false)
public function data($name, $pass, $hashed = false, $expire = 86400, $loginadm = false)
{
global $config, $userinfo;
//return user system to normal
if (defined('DISABLE_INTR') || $config['user_system'] == '' || empty($config['user_system']))
{
$config['user_system'] = '1';
}
//expire
$expire = time() + ((int) $expire ? intval($expire) : 86400);
$name = trim($name);
$pass = trim($pass);
$return_now = $login_status = false;
@@ -41,33 +33,13 @@ class usrcp
return $login_status;
}
if ((int) $config['user_system'] != 1)
{
if (file_exists(PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php'))
{
include_once PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php';
$login_status = kleeja_auth_login(trim($name), trim($pass), $hashed, $expire, $loginadm);
return $login_status;
}
}
//normal
return $this->normal(trim($name), trim($pass), $hashed, $expire, $loginadm);
return $this->normal($name, $pass, $hashed, $expire, $loginadm);
}
//get username by id
public function usernamebyid($user_id)
{
global $config;
//return user system to normal
if (defined('DISABLE_INTR'))
{
$config['user_system'] = 1;
}
$return_now = $auth_status = false;
is_array($plugin_run_result = Plugins::getInstance()->run('auth_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -77,22 +49,13 @@ class usrcp
return $auth_status;
}
if ((int) $config['user_system'] != 1)
{
if (file_exists(PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php'))
{
include_once PATH . 'includes/auth_integration/' . trim($config['user_system']) . '.php';
return kleeja_auth_username($user_id);
}
}
//normal system
$u = $this->get_data('name', $user_id);
return $u['name'];
}
//now our table, normal user system
public function normal ($name, $pass, $hashed = false, $expire, $loginadm = false)
public function normal($name, $pass, $hashed = false, $expire, $loginadm = false)
{
global $SQL, $dbprefix, $config, $userinfo;
@@ -124,7 +87,8 @@ class usrcp
while ($row=$SQL->fetch_array($result))
{
if (empty($row['password']))
{ //more security
{
//more security
return false;
}
@@ -138,7 +102,7 @@ class usrcp
if ($row['password'] == $passmd5)
{
////new salt
$new_salt = substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$new_salt = substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
////new password hash
$new_password = $this->kleeja_hash_password(trim($pass) . $new_salt);
@@ -177,7 +141,7 @@ class usrcp
//all user fileds info
$userinfo = $row;
$user_y = kleeja_base64_encode(serialize(['id'=>$row['id'], 'name'=>$row['name'], 'mail'=>$row['mail'], 'last_visit'=>$row['last_visit']]));
$user_y = base64_encode(serialize(['id'=>$row['id'], 'name'=>$row['name'], 'mail'=>$row['mail'], 'last_visit'=>$row['last_visit']]));
if (! $hashed && ! $loginadm)
{
@@ -240,7 +204,7 @@ class usrcp
}
// user ids
public function id ()
public function id()
{
is_array($plugin_run_result = Plugins::getInstance()->run('id_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -248,7 +212,7 @@ class usrcp
}
// group ids
public function group_id ()
public function group_id()
{
is_array($plugin_run_result = Plugins::getInstance()->run('group_id_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -256,7 +220,7 @@ class usrcp
}
// user name
public function name ()
public function name()
{
is_array($plugin_run_result = Plugins::getInstance()->run('name_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -264,7 +228,7 @@ class usrcp
}
// user mail
public function mail ()
public function mail()
{
is_array($plugin_run_result = Plugins::getInstance()->run('mail_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -304,11 +268,6 @@ class usrcp
//clean usernames
public function cleanusername($uname)
{
if (! function_exists('kleeja_base64_decode'))
{
include_once PATH . 'includes/functions_alternative.php';
}
is_array($plugin_run_result = Plugins::getInstance()->run('cleanusername_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
static $arabic_t = [];
@@ -320,7 +279,7 @@ class usrcp
if (empty($arabic_t))
{
//Arabic chars must be stay in utf8 format, so we encoded them
$arabic_t = unserialize(kleeja_base64_decode('YToyOntpOjA7YToxMjp7aTowO3M6Mjoi2KMiO2k6MTtzOjI6ItilIjtpOjI7czoyOiLYpCI7aTozO3M6Mjoi2YAiO2k6NDtzOjI6Itm' .
$arabic_t = unserialize(base64_decode('YToyOntpOjA7YToxMjp7aTowO3M6Mjoi2KMiO2k6MTtzOjI6ItilIjtpOjI7czoyOiLYpCI7aTozO3M6Mjoi2YAiO2k6NDtzOjI6Itm' .
'LIjtpOjU7czoyOiLZjCI7aTo2O3M6Mjoi2Y8iO2k6NztzOjI6ItmOIjtpOjg7czoyOiLZkCI7aTo5O3M6Mjoi2ZIiO2k6MTA7czoyOiLYoiI7aToxMTtzOjI6ItimIjt9aToxO' .
'2E6MTI6e2k6MDtzOjI6ItinIjtpOjE7czoyOiLYpyI7aToyO3M6Mjoi2YgiO2k6MztzOjA6IiI7aTo0O3M6MDoiIjtpOjU7czowOiIiO2k6NjtzOjA6IiI7aTo3O3M6MDoiIjt' .
'pOjg7czowOiIiO2k6OTtzOjA6IiI7aToxMDtzOjI6ItinIjtpOjExO3M6Mjoi2YkiO319'));
@@ -369,10 +328,10 @@ class usrcp
//
if (defined('FORCE_COOKIES'))
{
$config['cookie_domain'] = (! empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((! empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : @getenv('SERVER_NAME'));
$config['cookie_domain'] = ! empty($_SERVER['HTTP_HOST']) ? strtolower($_SERVER['HTTP_HOST']) : (! empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : @getenv('SERVER_NAME'));
$config['cookie_domain'] = str_replace('www.', '.', substr($config['cookie_domain'], 0, strpos($config['cookie_domain'], ':')));
$config['cookie_path'] = '/';
$config['cookie_secure'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false;
$config['cookie_secure'] = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
}
// Enable sending of a P3P header
@@ -382,7 +341,7 @@ class usrcp
$rexpire = gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expire);
$domain = (! $config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain'];
header('Set-Cookie: ' . $name_data . (($expire) ? '; expires=' . $rexpire : '') . '; path=' . $config['cookie_path'] . $domain . ((! $config['cookie_secure']) ? '' : '; secure') . '; HttpOnly', false);
header('Set-Cookie: ' . $name_data . ($expire ? '; expires=' . $rexpire : '') . '; path=' . $config['cookie_path'] . $domain . (! $config['cookie_secure'] ? '' : '; secure') . '; HttpOnly', false);
}
//encrypt and decrypt any data with our function
@@ -413,7 +372,7 @@ class usrcp
switch ($type)
{
case 1:
$data = str_replace('=', '_', kleeja_base64_encode($data));
$data = str_replace('=', '_', base64_encode($data));
$data = strtr($data, $txt);
break;
@@ -422,7 +381,7 @@ class usrcp
$txtx = array_flip($txt);
$txtx = array_reverse($txtx, true);
$data = strtr($data, $txtx);
$data = kleeja_base64_decode(str_replace('_', '=', $data));
$data = base64_decode(str_replace('_', '=', $data));
break;
}
@@ -446,7 +405,7 @@ class usrcp
//return : mean return true or false, but if return is false will show msg
public function kleeja_check_user()
{
global $config, $SQL, $dbprefix, $userinfo;
global $config, $userinfo;
is_array($plugin_run_result = Plugins::getInstance()->run('kleeja_check_user_func_usr_class', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -466,9 +425,6 @@ class usrcp
//if not expire
if (($hashed_expire == sha1(md5($config['h_key'] . $hashed_password) . $expire_at)) && ($expire_at > time()))
{
// For better performance we will take the risks
// !defined('IN_DOWNLOAD')
//exit(print_r( @explode('|', $this->en_de_crypt($this->kleeja_get_cookie('ulogu'), 2))));
if (user_can('enter_acp', $group_id))
{
$user_data = $this->data($user_id, $hashed_password, true, $expire_at);
@@ -477,7 +433,7 @@ class usrcp
{
if (! empty($u_info))
{
$userinfo = unserialize(kleeja_base64_decode($u_info));
$userinfo = unserialize(base64_decode($u_info));
$userinfo['group_id'] = $group_id;
$userinfo['password'] = $hashed_password;
@@ -509,139 +465,4 @@ class usrcp
return false; //nothing
}
// convert from utf8 to cp1256 and vice versa
public function kleeja_utf8($str, $to_utf8 = true)
{
$utf8 = new kleeja_utf8;
if ($to_utf8)
{
//return iconv('CP1256', "UTF-8//IGNORE", $str);
return $utf8->to_utf8($str);
}
return $utf8->from_utf8($str);
//return iconv('UTF-8', "CP1256//IGNORE", $str);
}
}//end class
/**
* Deep modifieded by Kleeja team ...
* depend on class by Alexander Minkovsky (a_minkovsky@hotmail.com)
*/
class kleeja_utf8
{
public $ascMap = [];
public $utfMap = [];
//ignore the untranslated char, of you put true we will translate it to html tags
//it's same the action of //IGNORE in iconv
public $ignore = false;
//Constructor
public function __construct()
{
static $lines = [];
if (empty($lines))
{
$lines = explode("\n", preg_replace(['/#.*$/m', "/\n\n/"], '', file_get_contents(PATH . 'includes/CP1256.MAP')));
}
if (empty($this->ascMap))
{
foreach ($lines as $line)
{
$parts = explode('0x', $line);
if (sizeof($parts) == 3)
{
$this->ascMap[hexdec(trim($parts[1]))] = hexdec(trim($parts[2]));
}
}
$this->utfMap = array_flip($this->ascMap);
}
}
//Translate string ($str) to UTF-8 from given charset
public function to_utf8($str)
{
$chars = unpack('C*', $str);
$cnt = sizeof($chars);
for ($i=1;$i <= $cnt; ++$i)
{
$this->_charToUtf8($chars[$i]);
}
return implode('', $chars);
}
//Translate UTF-8 string to single byte string in the given charset
public function from_utf8($utf)
{
$chars = unpack('C*', $utf);
$cnt = sizeof($chars);
$res = ''; //No simple way to do it in place... concatenate char by char
for ($i=1;$i<=$cnt;$i++)
{
$res .= $this->_utf8ToChar($chars, $i);
}
return $res;
}
//Char to UTF-8 sequence
public function _charToUtf8(&$char)
{
$c = (int) $this->ascMap[$char];
if ($c < 0x80)
{
$char = chr($c);
}
elseif ($c<0x800)
{ // 2 bytes
$char = (chr(0xC0 | $c>>6) . chr(0x80 | $c & 0x3F));
}
elseif ($c<0x10000)
{ // 3 bytes
$char = (chr(0xE0 | $c>>12) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F));
}
elseif ($c<0x200000)
{ // 4 bytes
$char = (chr(0xF0 | $c>>18) . chr(0x80 | $c>>12 & 0x3F) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F));
}
}
//UTF-8 sequence to single byte character
public function _utf8ToChar(&$chars, &$idx)
{
if (($chars[$idx] >= 240) && ($chars[$idx] <= 255))
{// 4 bytes
$utf = (intval($chars[$idx]-240) << 18) + (intval($chars[++$idx]-128) << 12) + (intval($chars[++$idx]-128) << 6) + (intval($chars[++$idx]-128) << 0);
}
elseif (($chars[$idx] >= 224) && ($chars[$idx] <= 239))
{ // 3 bytes
$utf = (intval($chars[$idx]-224) << 12) + (intval($chars[++$idx]-128) << 6) + (intval($chars[++$idx]-128) << 0);
}
elseif (($chars[$idx] >= 192) && ($chars[$idx] <= 223))
{// 2 bytes
$utf = (intval($chars[$idx]-192) << 6) + (intval($chars[++$idx]-128) << 0);
}
else
{// 1 byte
$utf = $chars[$idx];
}
if (array_key_exists($utf, $this->utfMap))
{
return chr($this->utfMap[$utf]);
}
else
{
return $this->ignore ? '' : '&#' . $utf . ';';
}
}
}
//<-- EOF

View File

@@ -16,7 +16,7 @@ if (! defined('IN_COMMON'))
define('KLEEJA_VERSION', '3.0.2');
define('KLEEJA_VERSION', '3.1.0');
define('KLEEJA_DB_VERSION', '9');

View File

@@ -58,11 +58,11 @@ $uploader->setAllowedFileExtensions($d_groups[$userinfo['group_id']]['exts']);
$uploader->setUploadFieldsLimit($config['filesnum']);
$uploading_type = ip('submitr') ? 1 : (ip('submittxt') ? 2 : false);
if ($uploading_type)
if (ip('submitr'))
{
$uploader->upload($uploading_type);
$uploader->upload();
}
@@ -174,7 +174,7 @@ if ($show_online)
update_config('most_user_online_ever', $current_online_users . ':' . time());
}
$online_time = kleeja_date('d-m-Y h:i a', $online_time);
$online_time = kleeja_date($online_time, true, 'd-m-Y h:i a');
//before 1.8, styles computability

View File

@@ -56,7 +56,6 @@ $config_values[] = ['filesnum', '3', '<input type=\"text\" id=\"filesnum\" name=
$config_values[] = ['sec_down', '5', '<input type=\"text\" id=\"sec_down\" name=\"sec_down\" value=\"{con.sec_down}\" size=\"6\" style=\"text-align:center\" />', 23, 'groups', 0, 0];
$config_values[] = ['del_url_file', '1', '<label>{lang.YES}<input type=\"radio\" id=\"del_url_file\" name=\"del_url_file\" value=\"1\" <IF NAME=\"con.del_url_file==1\"> checked=\"checked\"</IF> /></label>\r\n <label>{lang.NO}<input type=\"radio\" id=\"del_url_file\" name=\"del_url_file\" value=\"0\" <IF NAME=\"con.del_url_file==0\"> checked=\"checked\"</IF> /></label>', 24, 'upload', 0, 0];
$config_values[] = ['safe_code', '0', '<label>{lang.YES}<input type=\"radio\" id=\"safe_code\" name=\"safe_code\" value=\"1\" <IF NAME=\"con.safe_code==1\"> checked=\"checked\"</IF> /></label>\r\n <label>{lang.NO}<input type=\"radio\" id=\"safe_code\" name=\"safe_code\" value=\"0\" <IF NAME=\"con.safe_code==0\"> checked=\"checked\"</IF> /></label>', 25, 'upload', 0, 0];
$config_values[] = ['www_url', '0', '<label>{lang.YES}<input type=\"radio\" id=\"www_url\" name=\"www_url\" value=\"1\" <IF NAME=\"con.www_url==1\"> checked=\"checked\"</IF> /></label>\r\n <label>{lang.NO}<input type=\"radio\" id=\"www_url\" name=\"www_url\" value=\"0\" <IF NAME=\"con.www_url==0\"> checked=\"checked\"</IF> /></label>', 26, 'upload', 0, 0];
$config_values[] = ['thumbs_imgs', '1', '<input type=\"text\" id=\"thmb_dim_w\" name=\"thmb_dim_w\" value=\"{thmb_dim_w}\" size=\"2\" style=\"text-align:center\" /> * <input type=\"text\" id=\"thmb_dim_h\" name=\"thmb_dim_h\" value=\"{thmb_dim_h}\" size=\"2\" style=\"text-align:center\" /> ', 27, 'upload', 0, 0];
$config_values[] = ['write_imgs', '0' , '<label>{lang.YES}<input type=\"radio\" id=\"write_imgs\" name=\"write_imgs\" value=\"1\" <IF NAME=\"con.write_imgs==1\"> checked=\"checked\"</IF> /></label>\r\n <label>{lang.NO}<input type=\"radio\" id=\"write_imgs\" name=\"write_imgs\" value=\"0\" <IF NAME=\"con.write_imgs==0\"> checked=\"checked\"</IF> /></label>\r\n <br /><img src=\"{STAMP_IMG_URL}\" alt=\"Seal photo\" style=\"margin-top:4px;border:1px groove #FF865E;\" />\r\n ', 28, 'groups', 0, 0];
$config_values[] = ['livexts', 'swf', '<input type=\"text\" id=\"livexts\" name=\"livexts\" value=\"{con.livexts}\" size=\"62\" style=\"direction:ltr\" />{lang.COMMA_X}', '29', 'upload', 0, 0];

View File

@@ -12,7 +12,7 @@
require PATH . 'includes/version.php';
//set mysql to show no errors
define('MYSQL_NO_ERRORS', true);
define('SQL_NO_ERRORS', true);
define('EVAL_IS_ON', is_eval_is_on());
@@ -114,26 +114,41 @@ function kleeja_eval($code)
* @param mixed $nm
* @param mixed $prf
*/
function do_config_export($srv, $usr, $pass, $nm, $prf)
function do_config_export($srv, $usr, $pass, $nm, $prf, $type = 'mysql')
{
$data = '<?php' . "\n\n" . '//fill these variables with your data' . "\n";
$data .= '//for more information about this file, visit: ' . "\n";
$data .= '//https://github.com/kleeja-official/kleeja/wiki/config.php-file' . "\n\n";
if(!empty($type) && $type != 'mysql')
{
if ($type == 'sqlite' && strpos($nm, '.') === false)
{
$nm = $nm . '.db';
}
$data .= '$dbtype = \'' . str_replace("'", "\'", $type) . "'; //database type \n";
}
$data .= '$dbserver = \'' . str_replace("'", "\'", $srv) . "'; //database server \n";
$data .= '$dbuser = \'' . str_replace("'", "\'", $usr) . "' ; // database user \n";
$data .= '$dbpass = \'' . str_replace("'", "\'", $pass) . "'; // database password \n";
$data .= '$dbname = \'' . str_replace("'", "\'", $nm) . "'; // database name \n";
$data .= '$dbprefix = \'' . str_replace("'", "\'", $prf) . "'; // if you use prefix for tables , fill it \n";
if (file_put_contents(PATH . 'config.php', $data, LOCK_EX) !== false)
if (is_writable(PATH))
{
if (@file_put_contents(PATH . 'config.php', $data, LOCK_EX) !== false)
{
return true;
}
}
if (defined('CLI') && CLI)
{
return true;
}
header('Content-Type: text/x-delimtext; name="config.php"');
header('Content-disposition: attachment; filename=config.php');
echo $data;
@@ -161,14 +176,19 @@ function inst_get_config($name)
if (empty($SQL))
{
global $dbserver, $dbuser, $dbpass, $dbname;
global $dbserver, $dbuser, $dbpass, $dbname, $dbtype;
if (! isset($dbserver))
if (! isset($dbname))
{
return false;
}
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
if(isset($dbtype) && $dbtype == 'sqlite')
{
@touch(PATH . $dbname);
}
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
}
if (empty($SQL))

View File

@@ -26,26 +26,24 @@ ALTER DATABASE `{$dbname}` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin
$install_sqls['call'] = "
CREATE TABLE `{$dbprefix}call` (
`id` int(10) NOT NULL auto_increment,
`id` int(10) NOT NULL auto_increment PRIMARY KEY,
`name` varchar(200) collate utf8_bin NOT NULL,
`text` varchar(350) collate utf8_bin NOT NULL,
`mail` varchar(350) collate utf8_bin NOT NULL,
`time` int(11) NOT NULL,
`ip` varchar(40) collate utf8_bin NOT NULL,
PRIMARY KEY (`id`)
`ip` varchar(40) collate utf8_bin NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
";
$install_sqls['reports'] = "
CREATE TABLE `{$dbprefix}reports` (
`id` int(10) NOT NULL auto_increment,
`id` int(10) NOT NULL auto_increment PRIMARY KEY,
`name` varchar(350) collate utf8_bin NOT NULL,
`mail` varchar(350) collate utf8_bin NOT NULL,
`url` varchar(250) collate utf8_bin NOT NULL,
`text` varchar(400) collate utf8_bin NOT NULL,
`time` int(11) NOT NULL,
`ip` varchar(40) collate utf8_bin NOT NULL,
PRIMARY KEY (`id`)
`ip` varchar(40) collate utf8_bin NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
";
@@ -77,7 +75,7 @@ CREATE TABLE `{$dbprefix}stats` (
$install_sqls['users'] = "
CREATE TABLE `{$dbprefix}users` (
`id` int(10) NOT NULL auto_increment,
`id` int(10) NOT NULL auto_increment PRIMARY KEY,
`name` varchar(300) collate utf8_bin NOT NULL,
`group_id` int(11) unsigned NOT NULL DEFAULT '3',
`password` varchar(200) collate utf8_bin NOT NULL,
@@ -91,7 +89,6 @@ CREATE TABLE `{$dbprefix}users` (
`show_my_filecp` tinyint(1) unsigned NOT NULL default '1',
`new_password` varchar(200) COLLATE utf8_bin NOT NULL DEFAULT '',
`hash_key` varchar(200) COLLATE utf8_bin NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `clean_name` (`clean_name`(300)),
KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
@@ -99,21 +96,20 @@ CREATE TABLE `{$dbprefix}users` (
$install_sqls['files'] = "
CREATE TABLE `{$dbprefix}files` (
`id` int(11) unsigned NOT NULL auto_increment,
`id` int(11) unsigned NOT NULL auto_increment PRIMARY KEY,
`last_down` int(11) unsigned NOT NULL DEFAULT '0',
`name` varchar(300) collate utf8_bin NOT NULL,
`real_filename` VARCHAR( 350 ) collate utf8_bin NOT NULL,
`name` varchar(300) collate utf8_bin NOT NULL DEFAULT '',
`real_filename` VARCHAR( 350 ) collate utf8_bin NOT NULL DEFAULT '',
`size` bigint(20) unsigned NOT NULL DEFAULT '0',
`uploads` int(11) unsigned NOT NULL DEFAULT '0',
`time` int(11) unsigned NOT NULL,
`time` int(11) unsigned NOT NULL DEFAULT '0',
`type` varchar(20) collate utf8_bin NOT NULL,
`folder` varchar(100) collate utf8_bin NOT NULL,
`report` int(11) unsigned NOT NULL DEFAULT '0',
`user` int(11) NOT NULL default '-1',
`code_del` varchar(150) collate utf8_bin NOT NULL,
`user_ip` VARCHAR( 250 ) NOT NULL,
`id_form` VARCHAR( 100 ) NOT NULL,
PRIMARY KEY (`id`),
`code_del` varchar(150) collate utf8_bin NOT NULL DEFAULT '',
`user_ip` VARCHAR( 250 ) NOT NULL DEFAULT '',
`id_form` VARCHAR( 100 ) NOT NULL DEFAULT 'id',
KEY `name` (`name`(300)),
KEY `user` (`user`),
KEY `code_del` (`code_del`(150)),
@@ -127,39 +123,25 @@ CREATE TABLE `{$dbprefix}files` (
$install_sqls['config'] = "
CREATE TABLE `{$dbprefix}config` (
`name` varchar(255) collate utf8_bin NOT NULL,
`value` varchar(255) collate utf8_bin NOT NULL,
`name` varchar(255) collate utf8_bin NOT NULL PRIMARY KEY,
`value` varchar(255) collate utf8_bin NOT NULL DEFAULT '',
`option` mediumtext collate utf8_bin NOT NULL,
`display_order` int(10) NOT NULL DEFAULT '1',
`type` varchar(20) NULL DEFAULT 'other',
`plg_id` int(11) NOT NULL DEFAULT '0',
`dynamic` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`name`),
KEY `type` (`type`),
KEY `plg_id` (`plg_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
";
// $install_sqls['hooks'] = "
// CREATE TABLE `{$dbprefix}hooks` (
// `hook_id` int(11) unsigned NOT NULL auto_increment,
// `plg_id` int(11) unsigned NOT NULL,
// `hook_name` varchar(255) collate utf8_bin NOT NULL,
// `hook_content` mediumtext collate utf8_bin NOT NULL,
// PRIMARY KEY (`hook_id`),
// KEY `plg_id` (`plg_id`)
// ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
// ";
$install_sqls['plugins'] = "
CREATE TABLE `{$dbprefix}plugins` (
`plg_id` int(11) unsigned NOT NULL auto_increment,
`plg_name` varchar(255) collate utf8_bin NOT NULL,
`plg_id` int(11) unsigned NOT NULL auto_increment PRIMARY KEY,
`plg_name` varchar(255) collate utf8_bin NOT NULL DEFAULT '',
`plg_ver` varchar(255) collate utf8_bin NOT NULL,
`plg_author` varchar(255) collate utf8_bin NOT NULL,
`plg_author` varchar(255) collate utf8_bin NOT NULL DEFAULT '',
`plg_dsc` mediumtext COLLATE utf8_bin NOT NULL,
`plg_icon` blob NOT NULL,
`plg_uninstall` mediumtext COLLATE utf8_bin NOT NULL,
@@ -167,16 +149,15 @@ CREATE TABLE `{$dbprefix}plugins` (
`plg_instructions` mediumtext COLLATE utf8_bin NOT NULL,
`plg_store` longtext COLLATE utf8_bin NOT NULL,
`plg_files` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`plg_id`),
KEY `plg_name` (`plg_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
";
$install_sqls['lang'] = "
CREATE TABLE `{$dbprefix}lang` (
`word` varchar(255) collate utf8_bin NOT NULL,
`trans` varchar(255) collate utf8_bin NOT NULL,
`lang_id` varchar(100) COLLATE utf8_bin NOT NULL,
`word` varchar(255) collate utf8_bin NOT NULL ,
`trans` varchar(255) collate utf8_bin NOT NULL DEFAULT '',
`lang_id` varchar(100) COLLATE utf8_bin NOT NULL DEFAULT 'en',
`plg_id` int(11) unsigned NOT NULL DEFAULT '0',
KEY `lang_id` (`lang_id`),
KEY `plg_id` (`plg_id`),
@@ -186,11 +167,10 @@ CREATE TABLE `{$dbprefix}lang` (
$install_sqls['groups'] = "
CREATE TABLE `{$dbprefix}groups` (
`group_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`group_id` int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
`group_name` varchar(255) COLLATE utf8_bin NOT NULL,
`group_is_default` tinyint(1) unsigned NOT NULL DEFAULT '0',
`group_is_essential` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`group_id`)
`group_is_essential` tinyint(1) unsigned NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
";
@@ -198,7 +178,7 @@ $install_sqls['groups_data'] = "
CREATE TABLE `{$dbprefix}groups_data` (
`group_id` int(11) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_bin NOT NULL,
`value` varchar(255) COLLATE utf8_bin NOT NULL,
`value` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
";
@@ -214,25 +194,23 @@ CREATE TABLE `{$dbprefix}groups_acl` (
$install_sqls['groups_exts'] = "
CREATE TABLE `{$dbprefix}groups_exts` (
`ext_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`ext_id` int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
`ext` varchar(20) COLLATE utf8_bin NOT NULL,
`group_id` int(11) unsigned NOT NULL DEFAULT '0',
`size` bigint(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`ext_id`),
KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1;
";
$install_sqls['filters'] = "
CREATE TABLE `{$dbprefix}filters` (
`filter_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`filter_id` int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
`filter_uid` varchar(30) COLLATE utf8_bin NOT NULL DEFAULT '',
`filter_type` varchar(20) COLLATE utf8_bin NOT NULL,
`filter_value` varchar(255) COLLATE utf8_bin NOT NULL,
`filter_time` int(11) unsigned NOT NULL DEFAULT '0',
`filter_user` int(11) unsigned NOT NULL DEFAULT '0',
`filter_status` varchar(50) COLLATE utf8_bin NOT NULL DEFAULT '',
PRIMARY KEY (`filter_id`),
KEY `filter_user` (`filter_user`),
KEY `filter_uid` (`filter_uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

View File

@@ -48,7 +48,15 @@ if (file_exists(PATH . 'config.php'))
include_once PATH . 'includes/functions.php';
include_once PATH . 'includes/mysqli.php';
if (isset($dbtype) && $dbtype == 'sqlite')
{
include PATH . 'includes/sqlite.php';
}
else
{
include PATH . 'includes/mysqli.php';
}
include_once 'includes/functions_install.php';

View File

@@ -30,7 +30,14 @@ include_once PATH . 'includes/functions_alternative.php';
include_once PATH . 'includes/functions.php';
include_once PATH . 'includes/mysqli.php';
if (isset($dbtype) && $dbtype == 'sqlite')
{
include PATH . 'includes/sqlite.php';
}
else
{
include PATH . 'includes/mysqli.php';
}
include_once 'includes/functions_install.php';
@@ -101,7 +108,7 @@ case 'f':
$check_ok = true;
$advices = $ziparchive_lib = false;
if(! class_exists( 'ZipArchive'))
if (! class_exists('ZipArchive'))
{
$ziparchive_lib = true;
}
@@ -121,10 +128,9 @@ case 'c':
if (ip('dbsubmit'))
{
//create config file, or export it to browser on failure
do_config_export(p('db_server'), p('db_user'), p('db_pass'), p('db_name'), p('db_prefix'));
do_config_export(p('db_server'), p('db_user'), p('db_pass'), p('db_name'), p('db_prefix'), p('db_type'));
}
$no_config = ! file_exists(PATH . 'config.php') || ig('force') ? false : true;
$writeable_path = is_writable(PATH) ? true : false;
@@ -137,10 +143,15 @@ case 'check':
$submit_disabled = $no_connection = $mysql_ver = false;
//config.php
if (! empty($dbname) && ! empty($dbuser))
if (! empty($dbname))
{
if (isset($dbtype) && $dbtype == 'sqlite')
{
@touch(PATH . $dbname);
}
//connect .. for check
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
if (! $SQL->is_connected())
@@ -149,9 +160,12 @@ case 'check':
}
else
{
if (! empty($SQL->mysql_version()) && version_compare($SQL->mysql_version(), MIN_MYSQL_VERSION, '<'))
if (defined('SQL_LAYER') && SQL_LAYER == 'mysqli')
{
$mysql_ver = $SQL->mysql_version();
if (! empty($SQL->version()) && version_compare($SQL->version(), MIN_MYSQL_VERSION, '<'))
{
$mysql_ver = $SQL->version();
}
}
}
}
@@ -174,11 +188,9 @@ case 'data' :
if (ip('datasubmit'))
{
//check data ...
if (empty(p('sitename')) || empty(p('siteurl')) || empty(p('sitemail'))
|| empty(p('username')) || empty(p('password')) || empty(p('password2')) || empty(p('email')) )
|| empty(p('username')) || empty(p('password')) || empty(p('password2')) || empty(p('email')))
{
echo $lang['EMPTY_FIELDS'];
echo $footer_inst;
@@ -204,13 +216,13 @@ case 'data' :
}
//connect .. for check
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
include_once PATH . 'includes/usr.php';
include_once PATH . 'includes/functions_alternative.php';
$usrcp = new usrcp;
$user_salt = substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_salt = substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_pass = $usrcp->kleeja_hash_password(p('password') . $user_salt);
$user_name = $SQL->escape(p('username'));
$user_mail = $SQL->escape(p('email'));

View File

@@ -25,7 +25,15 @@ include_once PATH . 'includes/plugins.php';
include_once PATH . 'includes/functions_display.php';
include_once PATH . 'includes/functions_alternative.php';
include_once PATH . 'includes/functions.php';
include_once PATH . 'includes/mysqli.php';
if (isset($dbtype) && $dbtype == 'sqlite')
{
include PATH . 'includes/sqlite.php';
}
else
{
include PATH . 'includes/mysqli.php';
}
include_once 'includes/functions_install.php';
@@ -49,16 +57,20 @@ else
exit('`config.php` was missing! so we created one for you, kindly edit the file with database information.');
}
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
if (! $SQL->is_connected())
{
exit('Can not connect to database, please make sure the data in `config.php` is correct!');
}
if (! empty($SQL->mysql_version()) && version_compare($SQL->mysql_version(), MIN_MYSQL_VERSION, '<'))
if (defined('SQL_LAYER') && SQL_LAYER == 'mysqli')
{
exit('The required MySQL version is `' . MIN_MYSQL_VERSION . '` and yours is `' . $SQL->mysql_version() . '`!');
if (! empty($SQL->version()) && version_compare($SQL->version(), MIN_MYSQL_VERSION, '<'))
{
exit('The required MySQL version is `' . MIN_MYSQL_VERSION . '` and yours is `' . $SQL->version() . '`!');
}
}
foreach (['cache', 'uploads', 'uploads/thumbs'] as $folder)
@@ -76,14 +88,14 @@ foreach (['cache', 'uploads', 'uploads/thumbs'] as $folder)
//install
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
include_once PATH . 'includes/usr.php';
include_once PATH . 'includes/functions_alternative.php';
$usrcp = new usrcp;
$password = ! empty($cli_options['password']) ? $cli_options['password'] : mt_rand();
$user_salt = substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_salt = substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_pass = $usrcp->kleeja_hash_password($password . $user_salt);
$user_name = $clean_name = 'admin';
$user_mail = $config_sitemail = 'admin@example.com';

View File

@@ -1,7 +1,7 @@
<div class="BoxInner"><div class="BoxTopImg"></div><div class="BoxBody"><div class="inner">
<div class="clr"></div>
{{if(empty($GLOBALS['dbname']) || empty($GLOBALS['dbuser'])): $GLOBALS['submit_disabled'] = true;}}
{{if(empty($GLOBALS['dbname'])): $GLOBALS['submit_disabled'] = true;}}
<div class="notice">
<p class="error2"><img src="style/images/k_info.png" class="img" alt=" " />{{echo $lang['INST_CHANG_CONFIG']}}</p>
</div>
@@ -11,7 +11,14 @@
{{if($GLOBALS['no_connection']): $GLOBALS['submit_disabled'] = true;}}
<div class="notice">
<p class="error2"><img src="style/images/k_info.png" class="img" alt=" " />{{echo $lang['INST_CONNCET_ERR']}}</p>
<p class="error2">
<img src="style/images/k_info.png" class="img" alt=" " />
{{echo $lang['INST_CONNCET_ERR']}}
{{if(! empty($GLOBALS['dbtype']) && $GLOBALS['dbtype'] == 'sqlite'):}}
<br>
{{echo sprintf($lang['INST_CONNCET_ERR_SQLITE'], $GLOBALS['dbname']);}}
{{endif;}}
</p>
</div>
{{endif}}

View File

@@ -2,28 +2,38 @@
<div class="clr"></div>
{{if(!$GLOBALS['no_config']):}}
<form method="post" action="{{echo './install.php?step=c&amp;' . getlang(1)}}" onsubmit="javascript:return formCheck(this, Array('db_server','db_user' ,'db_name'));">
<form method="post" action="{{echo './install.php?step=c&amp;' . getlang(1)}}">
<h2><img src="style/images/klj_info.png" class="img" alt="!" />{{echo $lang['DB_INFO']}}</h2>
<table class="TableConf" dir="{{echo $lang['DIR']}}">
<tr>
<td class="TdConf">{{echo $lang['DB_TYPE']}}</td>
<td class="TdInput">
<select name="db_type" id="db_type" style="text-align:left;direction:ltr">
<option value="mysql" selected>{{echo $lang['DB_TYPE_MYSQL']}}</option>
<option value="sqlite">{{echo $lang['DB_TYPE_SQLITE']}}</option>
</select>
</td>
</tr>
<tr>
<td class="TdConf">{{echo $lang['DB_SERVER']}}</td>
<td class="TdInput"><input name="db_server" type="text" value="localhost" class="InputConf" /></td>
<td class="TdInput"><input name="db_server" id="db_server" type="text" value="localhost" class="InputConf" /></td>
</tr>
<tr>
<td class="TdConf">{{echo $lang['DB_NAME']}}</td>
<td class="TdInput"><input name="db_name" type="text" class="InputConf" /></td>
<td class="TdInput"><input name="db_name" id="db_name" type="text" value="kleeja" class="InputConf" /></td>
</tr>
<tr>
<td class="TdConf">{{echo $lang['DB_USER']}}</td>
<td class="TdInput"><input name="db_user" type="text" class="InputConf" /></td>
<td class="TdInput"><input name="db_user" id="db_user" type="text" class="InputConf" /></td>
</tr>
<tr>
<td class="TdConf">{{echo $lang['DB_PASSWORD']}}</td>
<td class="TdInput"><input name="db_pass" type="text" class="InputConf" /></td>
<td class="TdInput"><input name="db_pass" id="db_pass" type="text" class="InputConf" /></td>
</tr>
<tr>
<td class="TdConf">{{echo $lang['DB_PREFIX']}}</td>
<td class="TdInput"><input name="db_prefix" type="text" value="klj_" class="InputConf" /></td>
<td class="TdInput"><input name="db_prefix" id="db_prefix" type="text" value="klj_" class="InputConf" />
</td>
</tr>
</table>
<div class="clr"></div>

View File

@@ -1,61 +1,61 @@
<div class="clr"></div></div><div class="ins_klj"></div>
<div class="clr"></div>
</div>
<div class="ins_klj"></div>
<!-- strart code java script -->
<script type="text/javascript" src="{{echo getjquerylink()}}"></script>
<script type="text/javascript">{{echo gettpl('javascript.js')}}</script>
<script type="text/javascript">
$(document).ready(function() {
$("#lang").msDropDown();
$("#toggleElement").click(function() {
$(document).ready(function () {
$("#toggleElement").click(function () {
$("#next").toggle(!$(this).attr('checked'));
});
$('input:checkbox:not([safari])').checkbox();
$('#sitemail').keydown( function(e){
if( $(this).val().length > 1) {
$('#sitemail').keydown(function (e) {
if ($(this).val().length > 1 && $('#email').val() == '') {
$('#email').val($(this).val());
}
});
});
/** By JavaScript Kit (http://javascriptkit.com) **/
function w_email(l){
$('#db_type').change(function(e) {
var state = $('#db_type').val() == 'sqlite';
$('#db_server').attr('disabled', state);
$('#db_user').attr('disabled', state);
$('#db_pass').attr('disabled', state);
});
});
function w_email(l) {
var m = document.getElementById(l);
if (m.value.indexOf("@") == - 1 || m.value.indexOf(".") == - 1 || m.value.length < 7 ) {
if (m.value.indexOf("@") == -1 || m.value.indexOf(".") == -1 || m.value.length < 7) {
alert("{{echo $lang['WRONG_EMAIL']}}");
m.focus();
}
}
function checkrequired(which){
}
function checkrequired(which) {
var pass = true;
if (document.images)
{
for (i=0;i<which.length;i++)
{
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required")
{
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s" && tempobj.selectedIndex==-1))
{
if (document.images) {
for (i = 0; i < which.length; i++) {
var tempobj = which.elements[i]
if (tempobj.name.substring(0, 8) == "required") {
if (((tempobj.type == "text" || tempobj.type == "textarea") && tempobj.value == '') || (tempobj.type
.toString().charAt(0) == "s" && tempobj.selectedIndex == -1)) {
pass = false;
break
}
}
}
}
if (!pass)
{
if (!pass) {
alert("{{echo $lang['VALIDATING_FORM_WRONG']}}");
return false;
}
else
{
} else {
return true;
}
}
/** http://www.dynamicdrive.com **/
function formCheck(formobj, fieldRequired){
}
if( document.getElementById('pass1').value != document.getElementById('pass2').value)
{
function formCheck(formobj, fieldRequired) {
if (document.getElementById('pass1').value != document.getElementById('pass2').value) {
alert("{{echo $lang['PASS_NEQ_PASS2']}}");
return false;
}
@@ -75,13 +75,10 @@ function formCheck(formobj, fieldRequired){
lang["password2"] = "{{echo $lang['PASSWORD2']}}";
lang["email"] = "{{echo $lang['EMAIL']}}";
for (var i = 0; i < fieldRequired.length; i++)
{
for (var i = 0; i < fieldRequired.length; i++) {
var obj = formobj.elements[fieldRequired[i]];
if (obj)
{
switch(obj.type)
{
if (obj) {
switch (obj.type) {
case "text":
case "textarea":
if (obj.value == "" || obj.value == null)
@@ -90,11 +87,9 @@ function formCheck(formobj, fieldRequired){
default:
}
if (obj.type == undefined)
{
if (obj.type == undefined) {
var blnchecked = false;
for (var j = 0; j < obj.length; j++)
{
for (var j = 0; j < obj.length; j++) {
if (obj[j].checked)
blnchecked = true;
}
@@ -107,41 +102,28 @@ function formCheck(formobj, fieldRequired){
if (alertMsg.length == l_Msg)
return true;
else
{
else {
alert(alertMsg);
return false;
}
}
}
function checkPass(){
//Store the password field objects into variables ...
function checkPass() {
var pass1 = document.getElementById('pass1');
var pass2 = document.getElementById('pass2');
//Store the Confimation Message Object ...
//var message = document.getElementById('confirmMessage');
//Set the colors we will be using ...
var goodColor = "#66cc66";
var badColor = "#ff6666";
//Compare the values in the password field
//and the confirmation field
if(pass1.value == pass2.value){
//The passwords match.
//Set the color to the good color and inform
//the user that they have entered the correct password
if(pass1.value != '' && pass2.value != '') {
if (pass1.value == pass2.value) {
pass1.style.backgroundColor = goodColor;
pass2.style.backgroundColor = goodColor;
//message.style.color = goodColor;
//message.innerHTML = "Passwords Match!"
}else{
//The passwords do not match.
//Set the color to the bad color and
//notify the user.
} else {
pass1.style.backgroundColor = badColor;
pass2.style.backgroundColor = badColor;
//message.style.color = badColor;
//message.innerHTML = "Passwords Do Not Match!"
}
}
}
</script>

File diff suppressed because one or more lines are too long

View File

@@ -28,13 +28,20 @@ include_once PATH . 'includes/plugins.php';
include_once PATH . 'includes/functions.php';
include_once PATH . 'includes/functions_alternative.php';
include_once PATH . 'includes/mysqli.php';
if (isset($dbtype) && $dbtype == 'sqlite')
{
include PATH . 'includes/sqlite.php';
}
else
{
include PATH . 'includes/mysqli.php';
}
include_once 'includes/functions_install.php';
include_once 'includes/update_schema.php';
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname, $dbprefix);
//
// fix missing db_version
@@ -137,6 +144,7 @@ case 'update_now':
}
delete_cache('', true);
echo gettpl('update_end.html');
break;

View File

@@ -18,8 +18,8 @@ return [
'PREFIXNAME' => 'بادئة أسماء الملفات <small>(مثلا : kleeja_ وستضاف قبل اسم كل ملف مرفوع, يمكن استخدام ايضا {rand:4} و {date:d_Y})</small>',
'FILESNUM' => 'عدد حقول ملفات التحميل',
'FILESNUM_SHOW' => 'عرض حقول حقول التحميل كلها',
'SITECLOSE' => 'إغلاق المركز',
'CLOSEMSG' => 'رسالة الإغلاق',
'SITECLOSE' => 'وضع الصيانة',
'CLOSEMSG' => 'رسالة وضع الصيانة',
'DECODE' => 'تغيير إسم الملف <small>(لاحظ : عند عرض الملف سيظهر اسمه الاصلي, اما هذا فللحماية والتنظيم)</small>',
'SEC_DOWN' => 'عدد الثواني قبل بدء التحميل',
'STATFOOTER' => 'إحصائيات الصفحة بالفوتر',
@@ -27,7 +27,6 @@ return [
'GOOGLEANALYTICS' => '<a href="http://www.google.com/analytics" target="_kleeja"><span style="color:orange">Google</span> Analytics</a>',
'WELCOME_MSG' => 'كلمة الترحيب',
'USER_SYSTEM' => 'نظام العضوية <small>(لاحظ: تغييرها قد يمنعك من الدخول مالم تتبع الشروحات)</small>',
'TOTAL_SIZE' => 'أقصى حجم كلي للمركز <small>(ميقا بايت)</small>',
'THUMBS_IMGS' => 'أبعاد مصغرات الصور (عرض x إرتفاع)',
'WRITE_IMGS' => 'تفعيل ختم الصور',
@@ -40,7 +39,6 @@ return [
'IDFF_IMG' => 'إسم الملف (example.com/do.php?imgf=filename.png)',
'IDFD_IMG' => 'رابط مباشر (example.com/uploads/filename.png)',
'DEL_URL_FILE' => 'تفعيل رابط الحذف المباشر',
'WWW_URL' => 'تفعيل التحميل من رابط',
'ALLOW_STAT_PG' => 'تفعيل صفحة الإحصائيات',
'ALLOW_ONLINE' => 'تفعيل عرض المتواجدون الآن',
'DEL_F_DAY' => 'حذف الملفات الخاملة بعد × يوم - صفر للتعطيل',
@@ -48,7 +46,6 @@ return [
'MOD_WRITER_EX' => '<b style="color:#0B55C4">روابط كـ HTML ..</b>',
'NUMFIELD_S' => 'رجاءاً .. الحقول الرقمية .. يجب أن تكون رقمية!',
'CONFIGS_UPDATED' => 'تم تحديت الإعدادات بنجاح',
'E_EXTS' => 'ملاحظة : الأحجام تضبط بالكليوبايت .',
'UPDATED_EXTS' => 'تم تحديث الإمتدادات بنجاح',
'EXT_DELETED' => 'تم حذف الامتداد بنجاح.',
@@ -90,8 +87,8 @@ return [
'R_REPAIR' => 'صيانة',
'R_LGOUTCP' => 'مسح جلسة الإدارة',
'R_BAN' => 'التحكم بالحظر',
'BAN_EXP1' => 'قم بتحرير الآيبيات المحظورة وإضافة الجديد من هنا..',
'BAN_EXP2' => 'إستخدم رمز النجمة (*)لاستبدال الارقام ..إذا كنت تريد الحظر الشامل ..وأستخدم الفاصل (|) للفصل بين الآيبيات',
'BAN_EXP1' => 'تستطيع حظر مستخدمين/زوار عبر الأي بي أو اسم المستخدم الخاص بهم.',
'BAN_EXP2' => 'لحظر مدى آيبيات استخدم النجمة (*) مثلاً: 116.10.191.*',
'UPDATE_BAN' => 'حفظ تعديلات الحظر',
'BAN_UPDATED' => 'تم تحديث قائمة الحظر بنجاح..',
'R_RULES' => 'شروط الخدمة',
@@ -113,7 +110,6 @@ return [
'EXTRA_UPDATED' => 'تم تحديث الإضافات القوالبية',
'R_STYLES' => 'الستايلات',
'NO_TPL_SHOOSED' => 'لم تقم بإختيار قالب!',
'R_PLUGINS' => 'إضافات برمجية',
'ADD_NEW_PLUGIN' => 'أضف إضافة برمجية جديدة',
'ITEM_DELETED' => 'لقد تم حذف "%s" بنجاح...',
@@ -139,7 +135,6 @@ return [
'CONFIG_WRITEABLE' => 'ملف config.php قابل للكتابة حالياً ونوصي وبشدة تغيير التصريح له لـ 640 أو على الأقل 644.',
'USERS_NOT_NORMAL_SYS' => 'نظام العضويات الحالي ليس النظام العادي ، أي أن الأعضاء الحاليين لا يمكن تحريرهم من هنا بل من السكربت الذي تم ربط كليجا به، هؤلا الأعضاء يتبعون لنظام العضويات العادي.',
'DIMENSIONS_THMB' => 'أبعاد المصغرات',
'ADMIN_DELETE_FILE_OK' => 'تم حذف كافة ملفات العضو',
'ADMIN_DELETE_FILES' => 'حذف كل ملفات العضوية',
@@ -161,7 +156,7 @@ return [
'CONFIG_KLJ_MENUS_GENERAL' => 'خيارات عامة',
'CONFIG_KLJ_MENUS_ALL' => 'عرض كل الخيارات',
'CONFIG_KLJ_MENUS_UPLOAD' => 'اعدادات التحميل',
'CONFIG_KLJ_MENUS_INTERFACE'=> 'خيارات الواجهة والتصميم',
'CONFIG_KLJ_MENUS_INTERFACE' => 'خيارات الواجهة والتصميم',
'CONFIG_KLJ_MENUS_ADVANCED' => 'خيارات متقدمة',
'DELF_CAUTION' => '<small class="delf_caution">تحذير : هذه الخاصية قد تكون خطرة عند وضع ارقام صغيرة أو عند إستخدام الروابط المباشرة.</small>',
'PACKAGE_N_CMPT_KLJ' => 'هذه الإضافة/الستايل غيره متوافقة مع إصدار كليجا الذي تستخدمه ! .',
@@ -190,7 +185,6 @@ return [
'USERSECTOUPLOAD' => 'عدد الثواني بين كل عملية رفع',
'ADM_UNWANTED_FILES' => 'يبدوا انك قمت بالترقية من نسخة سابقة وبسبب اختلاف اسماء بعض الملفات ستلاحظ وجود ازرار متكررة بلوحة التحكم . <br /> لحل المشكلة قم بإزالة كافة الملفات في المسار "includes/adm" واعادة رفعها من جديد. ايضا قم بحذف ملف admin.php من المجلد الرئيسي اذا وجد.',
'HTML_URLS_ENABLED_NO_HTCC' => 'لقد قمت بتفعيل روابط الهتمل ولكنك نسيت أن تقوم بإعادة تسمية الملف htaccess.txt في مجلد كليجا الرئيسي ليصبح ".htaccess". اذا لم تفهم شيئاً من هذا الكلام قم بالسؤال في الدعم الفني لكليجا او قم بتعطيل روابط الهتمل .',
'PLUGIN_CONFIRM_ADD' => 'انتبه, الاضافات هي تعديلات برمجية على كليجا و قد تكون ضارة أحياناً , لذا ان كنت غير متأكد من مصدر الإضافة ولم تقم بتحميلها من موقع كليجا فالافضل ان تراجع نفسك الآن . ',
'LOADING' => 'جاري التنفيذ',
'WELCOME' => 'مرحباً',
@@ -254,7 +248,6 @@ return [
'EXTRACT_ZIP_FAILED' => 'صادفتنا مشكلة أثناء فك الأرشيف! تأكد من أنه ملف zip صالح، وأن مجلد "%s" قابل للكتابة.',
'NO_PROBLEM_AFTER_ZIP' => 'لقد تم فك الملف بنجاح وهو جاهز للتفعيل.',
'SESSION_ENDED' => 'انتهت الجلسة، هل تريد تسجل الدخول من جديد؟',
//3.0.3
'CUSTOMIZATION' => 'تخصيص',
'SHOW' => 'عرض',
'HIDE' => 'إخفاء',
@@ -268,7 +261,7 @@ return [
'PACKAGE_REMOTE_FILE_MISSING' => 'حزمة "%s" ليست موجودة على متجر كليجا الخارجي!',
'STORE_SERVER_ERROR' => 'واجهنا خطأ أثناء الإتصال بخادم متجر كليجا الخارجي...',
'INSTALLED_PLUGINS' => 'الإضافات المثبتة',
'LOCAL_PLUGINS' => 'الإضافات المحلية',
'LOCAL_PLUGINS' => 'الإضافات المحلية (غير مثبتة)',
'KLEEJA_STORE' => 'متجر كليجا',
'KLJ_VER_NO_PLUGIN' => 'هذه الإضافة/الستايل يمكنها العمل على إصدار كليجا %1$s حتى إصدار %2$s.',
'VERSION' => 'الإصدار',

View File

@@ -11,7 +11,7 @@ return [
'HOME' => 'البداية',
'INDEX' => 'الرئيسية',
'SITE_CLOSED' => 'الموقع مغلق !',
'SITE_CLOSED' => 'الموقع مغلق للصيانة.',
'STOP_FOR_SIZE' => 'متوقف حالياً !',
'SIZES_EXCCEDED' => 'الحجم الكلي للمركز استنفذ .. سوف نعود قريباً',
'SAFE_CODE' => 'تفعيل الكود الأمني في التحميل',
@@ -159,7 +159,7 @@ return [
'URL_CANT_GET' => 'خطأ في جلب الملف من الرابط',
'ADMINCP' => 'مركز التحكم',
'GO_BACK_BROWSER' => 'رجوع للخلف',
'U_R_BANNED' => 'لقد تم حظر الآي بي هذا..',
'U_R_BANNED' => 'لقد تم حظر الآي بي/العضوية ..',
'U_R_FLOODER' => 'لقد قمت بتخطي عدد مرات عرض الصفحة بالوقت المحدد..',
'YES' => 'نعم',
'NO' => 'لا',
@@ -191,9 +191,6 @@ return [
'NOT_SAFE_FILE' => 'نظام كليجا اكتشف أن الملف "%s" غير آمن ويحتوي على أكواد خبيثه .. !!',
'ARE_YOU_SURE_DO_THIS' => 'هل أنت متأكد من القيام بهذه العملية؟',
'SITE_FOR_MEMBER_ONLY' => 'المركز للأعضاء فقط ، قم بالتسجيل أو بالدخول حتى تتمكن من التحميل.',
'AUTH_INTEGRATION_N_UTF8_T' => '%s ليست utf8',
'AUTH_INTEGRATION_N_UTF8' => '%s يجب أن يكون ترميز قاعدة البيانات الخاصة به utf8 لكي يتم الربط مع كليجا!.',
'SCRIPT_AUTH_PATH_WRONG' => 'مسار السكربت %s الذي تم ربط عضويات كليجا معه خاطئ ,قم بضبطه',
'SHOW_MY_FILECP' => 'السماح بعرض ملفاتي',
'PASS_CHANGE' => 'تغيير كلمة المرور',
'EDIT_U_AVATER' => 'تغيير الصورة الرمزية',
@@ -221,7 +218,7 @@ return [
'ALL_FILES' => 'عدد جميع الملفات',
'ALL_IMAGES' => 'عدد جميع الصور',
'WAIT_LOADING' => 'فضلاً انتظر جاري رفع الملفات .....',
'NOTICECLOSED' => 'تنبيه : المركز مغلق',
'NOTICECLOSED' => 'تنبيه : المركز في وضع الصيانة',
'UNKNOWN' => 'غير معروف',
'WE_UPDATING_KLEEJA_NOW' => 'الموقع مغلق للتطوير والترقية لاخر نسخة , لذا يرجى الصبر ...',
'ERROR_TRY_AGAIN' => 'خطأ , حاول مجدداً.',
@@ -282,5 +279,4 @@ return [
'EMAIL_CHANGE_REQ_PASS' => 'لتغيير بريدك الإلكتروني يجب أن تقوم بكتابة كلمة مرورك الحالية.',
'DRAG_AND_DROP' => 'جر وأسقط ملف هنا للرفع&hellip;',
'OR_MANUAL_SELECT' => 'أو قم بالضغط هنا <em>لإختيار</em> ملف يدوياً..',
];

View File

@@ -17,7 +17,7 @@ return [
'INST_ADMIN_INFO' => 'أدخل بيانات مدير المركز',
'INST_CHANG_CONFIG' => 'بعض البيانات المهمة ناقصة إملأ ملف config.php',
'INST_CONNCET_ERR' => 'لا يمكن الإتصال ...',
'INST_CONNCET_ERR_SQLITE' => 'تأكد من وجود ملف في مجلد كليجا الرئيسي بأسم: %s.',
'INST_NO_WRTABLE' => 'مجلد غير قابل للكتابة .. يحتاج تصريح 777',
'INST_GOOD_GO' => 'تم التأكد من المتغييرات والإتصال والتراخيص .. تابع',
'INST_MSGINS' => 'يمكنك تحميل ماتشاء وفق المسموح به .. شكراُ لزيارتك',
@@ -57,8 +57,8 @@ return [
'DB_INFO' => 'أدخل معلومات قاعدة البيانات',
'DB_SERVER' => 'الخادم',
'DB_TYPE' => 'نوع قاعدة البيانات',
'DB_TYPE_MYSQL' => 'MySQL القياسي',
'DB_TYPE_MYSQLI' => 'MySQL المطور',
'DB_TYPE_MYSQL' => 'MySQL',
'DB_TYPE_SQLITE' => 'SQLite',
'DB_USER' => 'اسم المستخدم لقاعدة البيانات',
'DB_PASSWORD' => 'كلمة المرور لقاعدة البيانات',
'DB_NAME' => 'إسم قاعدة البيانات',

View File

@@ -18,8 +18,8 @@ return [
'PREFIXNAME' => 'Files name prefix <small>(you can also use {rand:4} , {date:d_Y})</small>',
'FILESNUM' => 'Number of upload input fields',
'FILESNUM_SHOW' => 'Show all upload inputs',
'SITECLOSE' => 'Shutdown service',
'CLOSEMSG' => 'Shutdown message',
'SITECLOSE' => 'Maintenance Mode',
'CLOSEMSG' => 'Maintenance mode message',
'DECODE' => 'Change file name',
'SEC_DOWN' => 'Waiting period <small>(in Seconds, before download button appears)</small>',
'STATFOOTER' => 'Page statistics in footer',
@@ -39,7 +39,6 @@ return [
'IDFF_IMG' => 'File name (example.com/do.php?imgf=filename.png)',
'IDFD_IMG' => 'Direct (example.com/uploads/filename.png)',
'DEL_URL_FILE' => 'Enable file deletion URL feature',
'WWW_URL' => 'Enable uploading from URL',
'ALLOW_STAT_PG' => 'Enable statistics page',
'ALLOW_ONLINE' => 'Enable Who is Online',
'MOD_WRITER' => 'Mod Rewrite',
@@ -47,7 +46,6 @@ return [
'DEL_F_DAY' => 'Auto Delete undownloaded files (days) (0 = disabled)',
'NUMFIELD_S' => 'You can only use numbers with some fields !!',
'CONFIGS_UPDATED' => 'Settings updated successfully.',
'EXT_DELETED' => 'The extension deleted successfully.',
'E_EXTS' => 'Note : Sizes are measured in kilobytes.',
'UPDATED_EXTS' => 'Extensions updated successfully.',
@@ -56,7 +54,6 @@ return [
'U_REPORT_ON' => 'For your report about ',
'BY_EMAIL' => 'By email ',
'ADMIN_REPLIED' => 'Admin Reply',
'IS_SEND_MAIL' => 'Reply has been sent.',
'REPORTS_UPDATED' => 'Reports have been updated.',
'REPLY_CALL' => 'Reply to this message',
@@ -89,8 +86,8 @@ return [
'R_REPAIR' => 'Maintenance',
'R_LGOUTCP' => 'Clear Session',
'R_BAN' => 'Ban Control',
'BAN_EXP1' => 'Edit the banned IPs and add new ones here ..',
'BAN_EXP2' => 'Use the star (*) symbol to replace numbers if you want a total ban.... and use the (|) to separate the IPs',
'BAN_EXP1' => 'You can ban users/guests by their IPs or usernames.',
'BAN_EXP2' => 'To block range of IPs, use star (*) symbol i.e. 116.10.191.*',
'UPDATE_BAN' => 'Save Changes',
'BAN_UPDATED' => 'Changes saved successfully.',
'R_RULES' => 'Terms',
@@ -111,14 +108,10 @@ return [
'UPDATE_EXTRA' => 'Update template',
'EXTRA_UPDATED' => 'Template additions updated successfully',
'R_STYLES' => 'Styles',
'NO_TPL_SHOOSED' => 'You did not select a template!',
'R_PLUGINS' => 'Plugins',
'ADD_NEW_PLUGIN' => 'Add plugin',
'ITEM_DELETED' => '%s has been deleted successfully...',
'ITEM_DELETED' => 'We have deleted "%s" successfully...',
'PLGUIN_DISABLED_ENABLED' => 'Plugin Enabled / Disabled',
'NO_PLUGINS' => 'No available plugins found...',
'NO_STYLES' => 'No available styles found...',
@@ -131,9 +124,7 @@ return [
'U_USE_PRE_RE' => 'You are using a Pre-release version, Click <a href="https://github.com/kleeja-official/kleeja/issues">here</a> to report any bugs or exploits.',
'STYLE_IS_DEFAULT' => 'Default style',
'MAKE_AS_DEFAULT' => 'Set as default',
'STYLE_NOW_IS_DEFAULT' => 'The style "%s" was set as default',
'UPDATE_NOW_S' => 'You are using an old version of Kleeja. Update Now. Your current version is %1$s and the latest one is %2$s',
'ADD_NEW_EXT' => 'Add a new extension',
'ADD_NEW_EXT_EXP' => 'Type a file extension to add it to this group (for example: doc)',
@@ -163,7 +154,7 @@ return [
'CONFIG_KLJ_MENUS_GENERAL' => 'General settings',
'CONFIG_KLJ_MENUS_ALL' => 'Display all the settings',
'CONFIG_KLJ_MENUS_UPLOAD' => 'Upload settings',
'CONFIG_KLJ_MENUS_INTERFACE'=> 'Interface and design settings',
'CONFIG_KLJ_MENUS_INTERFACE' => 'Interface and design settings',
'CONFIG_KLJ_MENUS_ADVANCED' => 'Advanced settings',
'DELF_CAUTION' => '<small class="delf_caution">Caution: might be dangerous when using small numbers or using direct form of URLS.</small>',
'PACKAGE_N_CMPT_KLJ' => 'This plugin/style is not compatible with your current version of Kleeja.',
@@ -203,7 +194,6 @@ return [
'DELETE_PROCESS_IN_WORK' => 'Currently, the delete process is executing ...',
'SHOW_FROM_24H' => 'Show past 24 hours',
'THUMB_DIS_LONGTIME' => 'Thumbs are disabled, this will force Kleeja to resize every images to be small here, and cost you time and bandwidth!. Enable thumbs now.',
'R_GROUPS' => 'Groups Management',
'ESSENTIAL_GROUPS' => 'Fundamental Groups',
'CUSTOM_GROUPS' => 'User-defined Groups',
@@ -228,7 +218,6 @@ return [
'DEFAULT_GROUP' => 'The default group',
'G_USERS_MOVE_TO' => 'Move the group users to',
'TAKEN_NAMES' => 'This name is taken. Choose another name',
'GROUP_DELETED' => 'Group "%1$s" has been deleted and its user moved to group "%2$s".',
'NO_MOVE_SAME_GRP' => 'You can not move the users to the same group!.',
'DEFAULT_GRP_NO_DEL' => 'You can not delete this group becuase it is the current default group, change the default group then try to delete it!.',
@@ -256,7 +245,6 @@ return [
'EXTRACT_ZIP_FAILED' => 'We encounter a problem while extracting this archive file, make sure it\'s a valid zip file, and that "%s" folder is writable',
'NO_PROBLEM_AFTER_ZIP' => 'The file has been extracted successfully and it\'s ready to be enabled',
'SESSION_ENDED' => 'Session has ended, do you want to login again?',
//3.0.3
'CUSTOMIZATION' => 'Customization',
'SHOW' => 'Show',
'HIDE' => 'Hide',
@@ -270,7 +258,7 @@ return [
'PACKAGE_REMOTE_FILE_MISSING' => 'Package of "%s" is not on Kleeja remote server!',
'STORE_SERVER_ERROR' => 'We encountered an error while connecting to the kleeja store remote server ...',
'INSTALLED_PLUGINS' => 'Installed Plugins',
'LOCAL_PLUGINS' => 'Local Plugins',
'LOCAL_PLUGINS' => 'Local Plugins (Not Installed)',
'KLEEJA_STORE' => 'Kleeja Store',
'KLJ_VER_NO_PLUGIN' => 'This plugin/style can works on Kleeja version %1$s up to version %2$s.',
'VERSION' => 'Version',

View File

@@ -10,7 +10,7 @@ return [
'HOME' => 'Home',
'INDEX' => 'Homepage',
'SITE_CLOSED' => 'The website is closed.',
'SITE_CLOSED' => 'The website is under maintenance.',
'STOP_FOR_SIZE' => 'The service is suspended.',
'SIZES_EXCCEDED' => 'We have ran out of space ... we will be back soon.',
'SAFE_CODE' => 'Enable safety code for downloads',
@@ -156,7 +156,7 @@ return [
'ADMINCP' => 'Control Panel',
'GO_BACK_BROWSER' => 'Go back',
'U_R_BANNED' => 'Your IP has been banned.',
'U_R_BANNED' => 'Your IP/membership has been banned.',
'U_R_FLOODER' => 'it&#039;s anti-flood system ...',
'YES' => 'Yes',
'NO' => 'No',
@@ -187,9 +187,6 @@ return [
'NOT_SAFE_FILE' => 'Kleeja found that the File "%s" is not safe!',
'ARE_YOU_SURE_DO_THIS' => 'Are you sure you want to do this?',
'SITE_FOR_MEMBER_ONLY' => 'This center is only for members, register or login to upload your files.',
'AUTH_INTEGRATION_N_UTF8_T' => '%s is not utf8',
'AUTH_INTEGRATION_N_UTF8' => '%s database must be utf8 to be integrated with Kleeja !.',
'SCRIPT_AUTH_PATH_WRONG' => 'Path of %s is not valid, change it now.',
'SHOW_MY_FILECP' => 'Show my files',
'PASS_CHANGE' => 'Change password',
'EDIT_U_AVATER' => 'ُEdit your avatar',
@@ -223,7 +220,7 @@ return [
'NO_FILE_USER' => 'No files were found in the account!',
'SHOWFILESBYIP' => 'Show files by IP',
'WAIT_LOADING' => 'Please wait, the files are being uploaded to the server...',
'NOTICECLOSED' => 'Note: website is closed',
'NOTICECLOSED' => 'Note: website is in maintenance mode!',
'UNKNOWN' => 'Unknown',
'WE_UPDATING_KLEEJA_NOW' => 'Closed for maintenance, Check back soon...',
'ERROR_TRY_AGAIN' => 'Error, try again.',

View File

@@ -8,7 +8,7 @@
return [
'DIR' => 'ltr',
'INST_INSTALL_WIZARD' => 'Kleeja installing wizard',
'INST_INSTALL_CLEAN_VER'=> 'New Installation',
'INST_INSTALL_CLEAN_VER' => 'New Installation',
'INST_UPDATE_P_VER' => 'Update ',
'INST_AGR_LICENSE' => 'I agree to terms and agreements',
'INST_NEXT' => 'Next',
@@ -17,6 +17,7 @@ return [
'INST_ADMIN_INFO' => 'Admin Info',
'INST_CHANG_CONFIG' => 'Missing requirements ... make sure you have edited the config.php file.',
'INST_CONNCET_ERR' => 'Cannot connect ..',
'INST_CONNCET_ERR_SQLITE' => 'Make sure that there is a file in Kleeja root folder called: %s.',
'INST_NO_WRTABLE' => 'The directory is not writable',
'INST_GOOD_GO' => 'Everything seems to be OK .... continue',
'INST_MSGINS' => 'Welcome to our uploading service, here you can upload anything as long as it does not violate our terms.',
@@ -57,8 +58,8 @@ return [
'DB_INFO' => 'Enter the database information ..!',
'DB_SERVER' => 'Host',
'DB_TYPE' => 'Database type',
'DB_TYPE_MYSQL' => 'MySQL Standard',
'DB_TYPE_MYSQLI' => 'MySQL Improved',
'DB_TYPE_MYSQL' => 'MySQL',
'DB_TYPE_SQLITE' => 'MySQL Improved',
'DB_USER' => 'Database Username',
'DB_PASSWORD' => 'Database Password',
'DB_NAME' => 'Database Name',

View File

@@ -37,13 +37,16 @@ $rules = [
'^fileuser[_-]([0-9]+)-([0-9]+).html$' => ['file' => 'ucp.php', 'args' => 'go=fileuser&id=$1&page=$2'],
// #for future plugins
'^go-(.*).html$' => ['file' => 'go.php', 'args' => 'go=$1'],
//--------->
//don't remove the next line ever.
//end_kleeja_rewrites_rules#
//<---------
];
if (file_exists('plugins_rules.php'))
{
$plugins_rules = include_once 'plugins_rules.php';
$rules = array_merge($rules, $plugins_rules);
}
$request_uri = trim(strtok($_SERVER['REQUEST_URI'], '?'), '/');

View File

@@ -1,6 +1,6 @@
<div class="mt-3 mb-5">
<h2>{title}</h2>
<h2 style="word-wrap:break-word;">{title}</h2>
</div>
@@ -11,9 +11,9 @@
<!-- <p class="text-center"><strong>{lang.FILE_INFO}</strong></p> -->
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between">
<li class="list-group-item d-flex justify-content-between flex-column">
<span class="text-secondary">{lang.FILENAME}</span>
<div class="list-group-item-text">{name}</div>
<div class="list-group-item-text break-all" style="word-wrap:break-word!important;">{name}</div>
</li>
<li class="list-group-item d-flex justify-content-between">
<span class="text-secondary">{lang.FILETYPE}</span>

View File

@@ -15,9 +15,13 @@
</div>
<div style="font-size:12px;display:block !important;background:#ECECEC !important;margin:5px; padding:2px 3px; position:fixed;bottom:0;left:1%;z-index:99999;text-align:center;">
Powered by <a style="display:inline !important;color:#666 !important;" href="https://www.kleeja.com/" onclick="window.open(this.href,'_blank');return false;" title ="Kleeja">Kleeja</a>
</div>
<div
style="padding:1px;font-size:11px;display:block !important;background:#f7f7f7 !important; color:#999 !important;
margin:3px; position:fixed;bottom:0;left:1%;z-index:99999;text-align:center;">
Powered by
<a style="display:inline !important;color:#999 !important;" href="https://www.kleeja.com/"
onclick="window.open(this.href,'_blank');return false;" title="Kleeja">Kleeja</a>
</div>
<IF NAME="page_stats">
<!-- footer stats -->
@@ -55,12 +59,11 @@ $(document).ready(function(){
});
<IF NAME="config.www_url == 0">
if(numfiles == 0){
alert('{lang.NO_FILE_SELECTED}');
return false;
}
</IF>
$('#loadbox').css('display', 'block');
$('#uploader').css('display', 'none');

View File

@@ -43,11 +43,6 @@
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#fileUpload" role="tab">{lang.DOWNLOAD_F}</a>
</li>
<IF NAME="config.www_url == 1">
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#linkUpload" role="tab">{lang.DOWNLOAD_T}</a>
</li>
</IF>
</ul>
</div>
<div class="card-body tab-content">
@@ -67,7 +62,7 @@
</IF>
<!-- files upload tab -->
<!-- files upload -->
<div class="tab-pane active" id="fileUpload" role="tabpanel">
<LOOP NAME=FILES_NUM_LOOP>
@@ -92,25 +87,6 @@
</div>
</div>
<IF NAME="config.www_url == 1">
<!-- links upload tab -->
<div class="tab-pane" id="linkUpload" role="tabpanel">
<LOOP NAME=FILES_NUM_LOOP>
<input class="url form-control mb-2" type="text" name="file_{{i}}_" style="{{show}}" size="70" placeholder="{lang.PAST_URL_HERE}">
</LOOP>
<div>
<br>
<div class="agree text-muted"><small>{terms_msg}</small></div>
<input type="submit" id="submittxt" name="submittxt" value="{lang.DOWNLOAD_T}" class="btn btn-outline-primary">
</div>
</div>
</IF>
</div>
</div>
@@ -123,8 +99,6 @@
<br>
<img src="{STYLE_PATH}images/loading.gif" alt="{lang.LOADING}" />
</div>
</div>
@@ -145,7 +119,4 @@
</IF>
</div>
</IF>
</div>

View File

@@ -36,9 +36,10 @@
</div>
<!-- @end-footer -->
<div style="font-size:12px;display:block !important;background:#ECECEC !important;margin:5px; padding:2px 3px; position:fixed;bottom:0;left:1%;z-index:99999;text-align:center;">
<div
style="padding:1px;font-size:11px;display:block !important;background:#f7f7f7 !important; color:#888 !important; margin:3px; position:fixed;bottom:0;left:1%;z-index:99999;text-align:center;">
Powered by
<a style="display:inline !important;color:#666 !important;" href="https://www.kleeja.com/" onclick="window.open(this.href,'_blank');return false;"
<a style="display:inline !important;color:#888 !important;" href="https://www.kleeja.com/" onclick="window.open(this.href,'_blank');return false;"
title="Kleeja">Kleeja</a>
</div>
@@ -58,12 +59,10 @@ $(document).ready(function(){
}
});
<IF NAME="config.www_url == 0">
if(numfiles == 0){
alert('{lang.NO_FILE_SELECTED}');
return false;
}
</IF>
$('#loadbox').css('display', 'block');
$('#uploader').css('display', 'none');

View File

@@ -32,14 +32,7 @@
<li title="{lang.DOWNLOAD_F}">{lang.DOWNLOAD_F}</li>
<!-- @First-Tab -->
<!-- Second-Tab -->
<IF NAME="config.www_url">
<li title="{lang.DOWNLOAD_T}">{lang.DOWNLOAD_T}</li>
</IF>
<!-- @Second-Tab -->
<!--you-can-add-another-tab-here-->
</ul>
<!-- First-Box -->
@@ -57,23 +50,6 @@
</div>
<!-- @First-Box -->
<!-- Second-Box -->
<IF NAME="config.www_url">
<div class="tabcon" title="{lang.DOWNLOAD_T}">
<div class="go_up">
<!-- upload URL -->
<LOOP NAME=FILES_NUM_LOOP>
<input class="url" type="text" name="file_{{i}}_" style="{{show}}" size="70" value="{lang.PAST_URL_HERE}" />
</LOOP>
<div class="agree"><span>{terms_msg}</span></div>
<div class="bn_up"><input type="submit" id="submittxt" name="submittxt" value="{lang.DOWNLOAD_T}" /> </div>
<div class="clr"></div>
<!-- @upload URL -->
</div>
</div>
</IF>
<!-- @Second-Box -->
<!--you-can-add-another-box-here-->
</div>

91
ucp.php
View File

@@ -35,7 +35,7 @@ switch (g('go'))
$stylee = 'login';
$titlee = $lang['LOGIN'];
$action = 'ucp.php?go=login' . (ig('return') ? '&amp;return=' . g('return') : '');
$forget_pass_link = ! empty($forgetpass_script_path) && (int) $config['user_system'] != 1 ? $forgetpass_script_path : 'ucp.php?go=get_pass';
$forget_pass_link = 'ucp.php?go=get_pass';
$H_FORM_KEYS = kleeja_add_form_key('login');
//no error yet
$ERRORS = false;
@@ -131,33 +131,9 @@ switch (g('go'))
kleeja_info($lang['REGISTER_CLOSED'], $lang['PLACE_NO_YOU']);
}
elseif ($config['user_system'] != '1')
{
is_array($plugin_run_result = Plugins::getInstance()->run('register_not_default_sys', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if (! empty($register_script_path))
{
$goto_forum_link = $register_script_path;
}
else
{
if (isset($script_path))
{
$goto_forum_link = ($config['user_system'] == 'api') ? dirname($script_path) : $script_path;
if ($config['user_system'] == 'phpbb' || ($config['user_system'] == 'api' && strpos($script_path, 'phpbb') !== false))
{
$goto_forum_link .= '/ucp.php?mode=register';
}
elseif ($config['user_system'] == 'vb' || ($config['user_system'] == 'api' && strpos($script_path, 'vb') !== false))
{
$goto_forum_link .= '/register.php';
}
}
else
{
$goto_forum_link = '...';
}
}
is_array($plugin_run_result = Plugins::getInstance()->run('register_not_default_sys', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
kleeja_info('<a href="' . $goto_forum_link . '" title="' . $lang['REGISTER'] . '" target="_blank">' . $lang['REGISTER'] . '</a>', $lang['REGISTER']);
}
@@ -232,10 +208,10 @@ switch (g('go'))
if (empty($ERRORS))
{
$name = (string) $SQL->escape(trim(p('lname')));
$user_salt = (string) substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_salt = (string) substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$pass = (string) $usrcp->kleeja_hash_password($SQL->escape(trim(p('lpass'))) . $user_salt);
$mail = (string) strtolower(trim($SQL->escape(p('lmail'))));
$session_id = (string) session_id();
$session_id = (string) constant('KJ_SESSION');
$clean_name = (string) $usrcp->cleanusername($name);
$insert_query = [
@@ -306,7 +282,7 @@ switch (g('go'))
$H_FORM_KEYS = kleeja_add_form_key('fileuser');
$user_id_get = ig('id') ? g('id', 'int') : false;
$user_id = (! $user_id_get && $usrcp->id()) ? $usrcp->id() : $user_id_get;
$user_id = ! $user_id_get && $usrcp->id() ? $usrcp->id() : $user_id_get;
$user_himself = $usrcp->id() == $user_id;
$action = $config['siteurl'] . 'ucp.php?go=fileuser' . (ig('page') ? '&amp;page=' . g('page', 'int') : '');
@@ -340,7 +316,7 @@ switch (g('go'))
$data_user = $config['user_system'] == 1 ? $usrcp->get_data('name, show_my_filecp', $user_id) : ['name' => $usrcp->usernamebyid($user_id), 'show_my_filecp' => '1'];
//if there is no username, then there is no user at all
if (! $data_user['name'])
if (empty($data_user['name']))
{
kleeja_err($lang['NOT_EXSIT_USER'], $lang['PLACE_NO_YOU']);
}
@@ -371,7 +347,7 @@ switch (g('go'))
$linkgoto = $config['siteurl'] . (
$config['mod_writer']
? 'fileuser-' . $user_id . ($currentPage > 1 && $currentPage <= $total_pages ? '-' . $currentPage : '') . '.html'
: 'ucp.php?go=fileuser' . ( ig('id') ? ( g('id', 'int') == $usrcp->id() ? '' : '&amp;id=' . g('id') ) : null )
: 'ucp.php?go=fileuser' . (ig('id') ? (g('id', 'int') == $usrcp->id() ? '' : '&amp;id=' . g('id')) : null)
);
$page_nums = $Pager->print_nums(str_replace('.html', '', $linkgoto));
@@ -382,6 +358,7 @@ switch (g('go'))
{
$data_user['name'] = $usrcp->usernamebyid($user_id);
}
$user_name = ! $data_user['name'] ? false : $data_user['name'];
//set page title
@@ -430,7 +407,7 @@ switch (g('go'))
'href' => $url,
'size' => readable_size($row['size']),
'time' => ! empty($row['time']) ? kleeja_date($row['time']) : '...',
'thumb_link'=> $is_image ? $url_thumb : $url_fileuser,
'thumb_link' => $is_image ? $url_thumb : $url_fileuser,
'is_image' => $is_image,
];
@@ -449,12 +426,12 @@ switch (g('go'))
if ($_POST['del_' . $row['id']])
{
//delete from folder ..
@kleeja_unlink($row['folder'] . '/' . $row['name'] );
@kleeja_unlink($row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists($row['folder'] . '/thumbs/' . $row['name'] ))
if (file_exists($row['folder'] . '/thumbs/' . $row['name']))
{
@kleeja_unlink($row['folder'] . '/thumbs/' . $row['name'] );
@kleeja_unlink($row['folder'] . '/thumbs/' . $row['name']);
}
$ids[] = $row['id'];
@@ -479,12 +456,12 @@ switch (g('go'))
//delete all files
foreach ($arr as $row)
{
@kleeja_unlink($row['folder'] . '/' . $row['name'] );
@kleeja_unlink($row['folder'] . '/' . $row['name']);
//delete thumb
if (file_exists($row['folder'] . '/thumbs/' . $row['name'] ))
if (file_exists($row['folder'] . '/thumbs/' . $row['name']))
{
@kleeja_unlink($row['folder'] . '/thumbs/' . $row['name'] );
@kleeja_unlink($row['folder'] . '/thumbs/' . $row['name']);
}
$ids[] = $row['id'];
@@ -604,36 +581,13 @@ switch (g('go'))
$name = $usrcp->name();
$mail = $usrcp->mail();
extract($usrcp->get_data('show_my_filecp, password_salt'));
$data_forum = (int) $config['user_system'] == 1 ? true : false;
$data_forum = (int) $config['user_system'] == 1;
$link_avater = sprintf($lang['EDIT_U_AVATER_LINK'], '<a target="_blank" href="http://www.gravatar.com/">', '</a>');
$H_FORM_KEYS = kleeja_add_form_key('profile');
//no error yet
$ERRORS = false;
if (! empty($profile_script_path))
{
$goto_forum_link = $profile_script_path;
}
else
{
if (isset($script_path))
{
$goto_forum_link = ($config['user_system'] == 'api') ? dirname($script_path) : $script_path;
if ($config['user_system'] == 'phpbb' || ($config['user_system'] == 'api' && strpos(strtolower($script_path), 'phpbb') !== false))
{
$goto_forum_link .= '/ucp.php?i=164';
}
elseif ($config['user_system'] == 'vb' || ($config['user_system'] == 'api' && strpos(strtolower($script_path), 'vb') !== false))
{
$goto_forum_link .= '/profile.php?do=editprofile';
}
}
else
{
$goto_forum_link = '...';
}
}
//_post
$t_pppass_old = p('pppass_old');
@@ -701,7 +655,7 @@ switch (g('go'))
//no errors , do it
if (empty($ERRORS))
{
$user_salt = substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_salt = substr(base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$mail = $new_mail ? "mail='" . $SQL->escape(strtolower(trim(p('pmail')))) . "'" : '';
$showmyfile = p('show_my_filecp', 'int') != $show_my_filecp ? ($mail == '' ? '': ',') . "show_my_filecp='" . p('show_my_filecp', 'int') . "'" : '';
$pass = ! empty(p('ppass_new')) ? ($showmyfile != '' || $mail != '' ? ',' : '') . "password='" . $usrcp->kleeja_hash_password($SQL->escape(p('ppass_new')) . $user_salt) .
@@ -742,7 +696,10 @@ switch (g('go'))
//if not default system, let's give him a link for integrated script
if ((int) $config['user_system'] != 1)
{
$text = '<a href="' . (! empty($forgetpass_script_path) ? $forgetpass_script_path : $script_path) . '">' . $lang['LOST_PASS_FORUM'] . '</a>';
$forgetpass_link = '...';
is_array($plugin_run_result = Plugins::getInstance()->run('get_pass_resetpass_link', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$text = '<a href="' . $forgetpass_link . '">' . $lang['LOST_PASS_FORUM'] . '</a>';
kleeja_info($text, $lang['PLACE_NO_YOU']);
}
@@ -778,7 +735,7 @@ switch (g('go'))
$npass = $npass['new_password'];
//password now will be same as new password
$update_query = [
'UPDATE'=> "{$dbprefix}users",
'UPDATE' => "{$dbprefix}users",
'SET' => "password = '" . $npass . "', new_password = '', hash_key = ''",
'WHERE' => 'id=' . $u_id,
];
@@ -850,7 +807,7 @@ switch (g('go'))
if (empty($ERRORS))
{
$query = [
'SELECT'=> 'u.*',
'SELECT' => 'u.*',
'FROM' => "{$dbprefix}users u",
'WHERE' => "u.mail='" . $SQL->escape(strtolower(trim(p('rmail')))) . "'"
];
@@ -877,7 +834,7 @@ switch (g('go'))
$message = "\n " . $lang['WELCOME'] . ' ' . $row['name'] . "\r\n " . sprintf($lang['GET_LOSTPASS_MSG'], $activation_link, $newpass) . "\r\n\r\n kleeja.com";
$update_query = [
'UPDATE'=> "{$dbprefix}users",
'UPDATE' => "{$dbprefix}users",
'SET' => "new_password = '" . $SQL->escape($pass) . "', hash_key = '" . $hash_key . "'",
'WHERE' => 'id=' . $row['id'],
];