From 5a74a7205680115a4aab11d13ed0aadc961b7a9e Mon Sep 17 00:00:00 2001 From: Mitan Omar Date: Sun, 19 May 2019 03:16:44 +0200 Subject: [PATCH 1/2] change the method of update the number of download update the number of download when the user is not the owner and not in admin panel --- do.php | 63 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/do.php b/do.php index 8b928ab..a00fd4f 100755 --- a/do.php +++ b/do.php @@ -280,7 +280,7 @@ elseif (ig('down') || ig('downf') || $livexts = explode(',', $config['livexts']); //get info file - $query = ['SELECT' => 'f.id, f.name, f.real_filename, f.folder, f.type, f.size, f.time', + $query = ['SELECT' => 'f.id, f.name, f.real_filename, f.folder, f.type, f.size, f.time , f.user', 'FROM' => "{$dbprefix}files f", 'WHERE' => $is_id_filename ? "f.name='" . $filename . "'" . (ig('downexf') ? " AND f.type IN ('" . implode("', '", $livexts) . "')" : '') : 'f.id=' . $id . (ig('downex') ? " AND f.type IN ('" . implode("', '", $livexts) . "')" : ''), @@ -312,6 +312,7 @@ elseif (ig('down') || ig('downf') || $f = $row['folder']; $ftime = $row['time']; $d_size = $row['size']; + $u = $row['user']; //img or not @@ -333,29 +334,45 @@ 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'])) { - //updates number of uploads .. - $update_query = [ - 'UPDATE' => "{$dbprefix}files", - 'SET' => 'uploads=uploads+1, last_down=' . time(), - 'WHERE' => $is_id_filename ? "name='" . $filename . "'" : 'id=' . $id, - ]; - - is_array($plugin_run_result = Plugins::getInstance()->run('qr_update_no_uploads_down', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook - $SQL->build($update_query); - - // - //Define as old vistor - //if this vistor has other views then add this view too - //old vistor just for 1 day - // - if ($usrcp->kleeja_get_cookie('oldvistor')) + if ( + ( // not in admin panel + (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['ADMINLOGIN_T']) || $_SESSION['ADMINLOGIN_T'] < time()) + ) + && !( + $usrcp->name() + && + $usrcp->id() == $u ) //the user is login and the owner of the file + /** + * if the user is a guest , or not the owner or not admin then update the number of downloads + */ + ) { - $usrcp->kleeja_set_cookie('oldvistor', $usrcp->kleeja_get_cookie('oldvistor') . $ii . ',', time() + 86400); - } - else - { - //first time - $usrcp->kleeja_set_cookie('oldvistor', ',' . $ii . ',', time() + 86400); + //updates number of uploads .. + $update_query = [ + 'UPDATE' => "{$dbprefix}files", + 'SET' => 'uploads=uploads+1, last_down=' . time(), + 'WHERE' => $is_id_filename ? "name='" . $filename . "'" : 'id=' . $id, + ]; + + is_array($plugin_run_result = Plugins::getInstance()->run('qr_update_no_uploads_down', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook + $SQL->build($update_query); + + // + //Define as old vistor + //if this vistor has other views then add this view too + //old vistor just for 1 day + // + if ($usrcp->kleeja_get_cookie('oldvistor')) + { + $usrcp->kleeja_set_cookie('oldvistor', $usrcp->kleeja_get_cookie('oldvistor') . $ii . ',', time() + 86400); + } + else + { + //first time + $usrcp->kleeja_set_cookie('oldvistor', ',' . $ii . ',', time() + 86400); + } } } } From 1365433c290fd170b2469cda37420485bb5a2a90 Mon Sep 17 00:00:00 2001 From: Mitan Omar Date: Mon, 20 May 2019 01:46:20 +0200 Subject: [PATCH 2/2] Update do.php --- do.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/do.php b/do.php index a00fd4f..d644674 100755 --- a/do.php +++ b/do.php @@ -280,7 +280,7 @@ elseif (ig('down') || ig('downf') || $livexts = explode(',', $config['livexts']); //get info file - $query = ['SELECT' => 'f.id, f.name, f.real_filename, f.folder, f.type, f.size, f.time , f.user', + $query = ['SELECT' => 'f.id, f.name, f.real_filename, f.folder, f.type, f.size, f.time', 'FROM' => "{$dbprefix}files f", 'WHERE' => $is_id_filename ? "f.name='" . $filename . "'" . (ig('downexf') ? " AND f.type IN ('" . implode("', '", $livexts) . "')" : '') : 'f.id=' . $id . (ig('downex') ? " AND f.type IN ('" . implode("', '", $livexts) . "')" : ''), @@ -312,7 +312,6 @@ elseif (ig('down') || ig('downf') || $f = $row['folder']; $ftime = $row['time']; $d_size = $row['size']; - $u = $row['user']; //img or not @@ -334,20 +333,7 @@ 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 ( - ( // not in admin panel - (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['ADMINLOGIN_T']) || $_SESSION['ADMINLOGIN_T'] < time()) - ) - && !( - $usrcp->name() - && - $usrcp->id() == $u ) //the user is login and the owner of the file - /** - * if the user is a guest , or not the owner or not admin then update the number of downloads - */ - ) + if ($usrcp->group_id() != 1) { //updates number of uploads .. $update_query = [