XoopsModules25x /
xoopstube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Module: XoopsTube |
||
| 5 | * |
||
| 6 | * You may not change or alter any portion of this comment or credits |
||
| 7 | * of supporting developers from this source code or any supporting source code |
||
| 8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | * |
||
| 10 | * PHP version 5 |
||
| 11 | * |
||
| 12 | * @category Module |
||
| 13 | * @package Xoopstube |
||
| 14 | * @author XOOPS Development Team |
||
| 15 | * @copyright 2001-2016 XOOPS Project (http://xoops.org) |
||
| 16 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
| 17 | * @link http://xoops.org/ |
||
| 18 | * @since 1.0.6 |
||
| 19 | * |
||
| 20 | * @param int $cid |
||
| 21 | * @param string $permType |
||
| 22 | * @param bool $redirect |
||
| 23 | * |
||
| 24 | * @return bool |
||
| 25 | */ |
||
| 26 | |||
| 27 | View Code Duplication | function xtubeCheckSearchGroups($cid = 0, $permType = 'XTubeCatPerm', $redirect = false) |
|
|
0 ignored issues
–
show
|
|||
| 28 | { |
||
| 29 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 30 | // $modulePath = dirname(__DIR__); |
||
| 31 | |||
| 32 | $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
| 33 | $gpermHandler = xoops_getHandler('groupperm'); |
||
| 34 | |||
| 35 | $moduleHandler = xoops_getHandler('module'); |
||
| 36 | $module = $moduleHandler->getByDirname($moduleDirName); |
||
| 37 | |||
| 38 | if (!$gpermHandler->checkRight($permType, $cid, $groups, $module->getVar('mid'))) { |
||
| 39 | if (false === $redirect) { |
||
| 40 | return false; |
||
| 41 | } else { |
||
| 42 | redirect_header('index.php', 3, _NOPERM); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | unset($module); |
||
| 46 | |||
| 47 | return true; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param $queryarray |
||
| 52 | * @param $andor |
||
| 53 | * @param $limit |
||
| 54 | * @param $offset |
||
| 55 | * @param $userid |
||
| 56 | * |
||
| 57 | * @return array |
||
| 58 | */ |
||
| 59 | function xtubeSearch($queryarray, $andor, $limit, $offset, $userid) |
||
|
0 ignored issues
–
show
xtubeSearch uses the super-global variable $GLOBALS which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
Loading history...
|
|||
| 60 | { |
||
| 61 | $sql = 'SELECT cid, pid FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat'); |
||
| 62 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
| 63 | while (false !== ($_search_group_check = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 64 | $_search_check_array[$_search_group_check['cid']] = $_search_group_check; |
||
| 65 | } |
||
| 66 | |||
| 67 | $sql = 'SELECT lid, cid, title, submitter, published, description FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos'); |
||
| 68 | $sql .= ' WHERE published > 0 AND published <= ' . time() . ' AND ( expired = 0 OR expired > ' . time() . ') AND offline = 0 AND cid > 0'; |
||
| 69 | |||
| 70 | if ($userid !== 0) { |
||
| 71 | $sql .= ' AND submitter=' . $userid . ' '; |
||
| 72 | } |
||
| 73 | |||
| 74 | // because count() returns 1 even if a supplied variable |
||
| 75 | // is not an array, we must check if $querryarray is really an array |
||
| 76 | if (is_array($queryarray) && $count = count($queryarray)) { |
||
| 77 | $sql .= " AND ((title LIKE LOWER('%$queryarray[0]%') OR LOWER(description) LIKE LOWER('%$queryarray[0]%'))"; |
||
| 78 | for ($i = 1; $i < $count; ++$i) { |
||
| 79 | $sql .= " $andor "; |
||
| 80 | $sql .= "(title LIKE LOWER('%$queryarray[$i]%') OR LOWER(description) LIKE LOWER('%$queryarray[$i]%'))"; |
||
| 81 | } |
||
| 82 | $sql .= ') '; |
||
| 83 | } |
||
| 84 | $sql .= 'ORDER BY published DESC'; |
||
| 85 | $result = $GLOBALS['xoopsDB']->query($sql, $limit, $offset); |
||
| 86 | $ret = array(); |
||
| 87 | $i = 0; |
||
| 88 | |||
| 89 | while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 90 | // Following is commented out because it can cause a conflict with View Account function (userinfo.php) |
||
| 91 | // if ( false == xtubeCheckSearchGroups( $myrow['cid'] ) ) { |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 92 | // continue; |
||
| 93 | // } |
||
| 94 | $ret[$i]['image'] = 'assets/images/size2.gif'; |
||
| 95 | $ret[$i]['link'] = 'singlevideo.php?cid=' . $myrow['cid'] . '&lid=' . $myrow['lid']; |
||
| 96 | $ret[$i]['title'] = $myrow['title']; |
||
| 97 | $ret[$i]['time'] = $myrow['published']; |
||
| 98 | $ret[$i]['uid'] = $myrow['submitter']; |
||
| 99 | ++$i; |
||
| 100 | } |
||
| 101 | unset($_search_check_array); |
||
| 102 | |||
| 103 | return $ret; |
||
| 104 | } |
||
| 105 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: