<?php
/**
* Module functions library of BugFree system.
*
* BugFree is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* BugFree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BugFree; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.bugfree.org.cn
* @package BugFree
* @version $Id$
*/
//------------------------- BASE FUNCTIONS -----------------------------------//
/**
* Get Current Mode
*
* @author Yupeng Lee<leeyupeng@gmail.com>
*/
function baseGetTestMode()
{
if($_SESSION['TestMode'] == '')
{
$_SESSION['TestMode'] = 'Bug';
}
return $_SESSION['TestMode'];
}
/*================================User Function Start=================================*/
/**
* Judge valid user.
*
* @author Chunsheng Wang <wwccss@263.net>
* @global array the BugFree config array.
* @global object the object of ADO class created in SetupBug.inc.php.
* @param string $TestUserName the user name used to login BugFree system.
* @param string $TestUserPWD the user password used to login BugFree system.
*/
function baseJudgeUser($TestUserName = '',$TestUserPWD = '')
{
global $_CFG;
$DBName = !empty($_CFG['UserDB']) ? 'MyUserDB' : 'MyDB';
global $$DBName;
$TestUserPWD = baseEncryptUserPWD($TestUserPWD);
$Where = "{$_CFG[UserTable][UserName]} = '{$TestUserName}' AND {$_CFG[UserTable][UserPassword]} = '{$TestUserPWD}'";
if($DBName == 'MyDB')
{
$Where .= " AND IsDroped = '0'";
}
$TestUserInfo = dbGetRow($_CFG[UserTable][TableName], "{$_CFG[UserTable][UserName]} AS UserName, {$_CFG[UserTable][RealName]} AS RealName, {$_CFG[UserTable][Email]} AS Email"
, $Where , $$DBName);
return $TestUserInfo;
}
/**
* Encrypt the password according to the EncryptType defined in Config.inc.php.
*
* @author Chunsheng Wang <wwccss@263.net>
* @global array config vars of BugFree system.
* @param string $TestUserPWD the password before encrypting.
* @return string encrypted password.
*/
function baseEncryptUserPWD($TestUserPWD)
{
global $_CFG;
if($_CFG['UserTable']['EncryptType'] == 'md5')
{
$TestUserPWD = md5($TestUserPWD);
}
elseif($_CFG['UserTable']['EncryptType'] == 'mysqlpassword')
{
$TestUserPWD = "PASSWORD('{$TestUserPWD}')";
}
else
{
$TestUserPWD = $TestUserPWD;
}
return $TestUserPWD;
}
/**
* Judge User Login Status
*
* @author Yupeng Lee<leeyupeng@gmail.com>
* @
*/
function baseJudgeUserLogin()
{
return true;
}
/**
* Judge Adminuser Login Status
*
* @author Yupeng Lee<leeyupeng@gmail.com>
*
*/
function baseJudgeAdminUserLogin()
{
global $_CFG;
if(baseJudgeIsAdmin($_SESSION['TestUserName']))
{
return true;
}
else
{
die('Permission Denenied');
}
}
/**
* Judge is admin
*
* @author Yupeng Lee<leeyupeng@gmail.com>
*
*/
function baseJudgeIsAdmin($UserName)
{
global $_CFG;
$UserName = strtolower($UserName);
if(in_array($UserName, $_CFG['AdminUser']))
{
return true;
}
return false;
}
/**
* Get the User's A C L.
*
* @author Yupeng Lee <leeyupeng@163.com>
* @param string $TestUserName UserName.
* @return string User's ACL.
*/
function baseGetUserACL($TestUserName)
{
$ProjectList = testGetValidProjectList();
$UserACL = array();
$ProjectACL = array();
if(baseJudgeIsAdmin($TestUserName))
{
$ProjectACL = array_keys($ProjectList);
}
else
{
$GroupACL = testGetGroupList("GroupUser LIKE '%,{$TestUserName},%'");
$ProjectACL = array();
foreach($GroupACL as $GroupInfo)
{
$ProjectACL += $GroupInfo['GroupProjectList'];
}
$ProjectACL = array_keys($ProjectACL);
}
foreach($ProjectACL as $ProjectID)
{
if($ProjectList[$ProjectID])
{
$UserACL[$ProjectID] = 'All';
}
}
return $UserACL;
}
/**
* Get query string from group query post in SearchBug.php/SearchCase.php/SearchResult.php
*
* @author Yupeng Lee<leeyupeng@gmail.com>
*/
function baseGetGroupQueryStr($PostQueryArray)
{
global $_CFG;
$FirstQueryGroup = array();
$SecondQureyGroup = array();
$FieldName = 'Field';
$OperatorName = 'Operator';
$ValueName = 'Value';
$AndOrName = 'AndOr';
for($I=0; $I<$_CFG['QueryFieldNumber']; $I++)
{
$WhereStr = ' ';
if(ucfirst($PostQueryArray[$AndOrName.$I]) == 'And')
{
$WhereStr .= '1 AND ';
}
elseif(ucfirst($PostQueryArray[$AndOrName.$I]) == 'Or')
{
$WhereStr .= '1 OR ';
}
$TempQueryStr = baseGetFieldQueryStr($PostQueryArray[$FieldName.$I], $PostQueryArray[$OperatorName.$I], $PostQueryArray[$ValueName.$I]);
if($TempQueryStr == '')
{
$WhereStr = '';
}
else
{
$WhereStr .= $TempQueryStr;
}
if($WhereStr != '')
{
$I%2 == 0 ? $FirstQueryGroup[] = $WhereStr : $SecondQureyGroup[] = $WhereStr;
}
}
$FirstQueryStr = join('AND', $FirstQueryGroup);
$SecondQueryStr = join('AND', $SecondQureyGroup);
$FirstQueryStr == '' ? $FirstQueryStr = '1' : '';
$SecondQueryStr == '' ? $SecondQueryStr = '1' : '';
$QueryStr = '(' . $FirstQueryStr . ') ' . $PostQueryArray['AndOrGroup'] . ' (' . $SecondQueryStr . ')';
return $QueryStr;
}
function baseGetFieldQueryStr($FieldName, $OperatorName, $FieldValue)
{
$QueryStr = '';
if($FieldValue == '')
{
return $QueryStr;
}
if(ucfirst($FieldValue) == 'Null')
{
$FieldValue = '';
}
if($OperatorName == 'LIKE')
{
$QueryStr = "LIKE '%{$FieldValue}%' ";
}
elseif($OperatorName == 'UNDER')
{
$QueryStr = "LIKE '{$FieldValue}%' ";
}
elseif($OperatorName == '!=')
{
$QueryStr = "NOT " . dbCreateIN($FieldValue) . " ";
}
elseif($OperatorName == '=')
{
if(eregi('date', $FieldName))
{
$QueryStr = sysStrToDateSql($FieldValue);
}
else
{
$QueryStr = $OperatorName . " '{$FieldValue}' ";
}
}
else
{
$QueryStr = $OperatorName . " '{$FieldValue}' ";
}
$QueryStr = $FieldName . ' ' . $QueryStr;
return $QueryStr;
}
/**
* Get user list which are not droped
*
* @author Yupeng Lee<leeyupeng@gmail.com>
*/
function testGetUserList($Where = '', $OrderBy = 'RealName ASC', $Limit = '', $ListKey = 'UserName')
{
global $_CFG;
$DBName = !empty($_CFG['UserDB']) ? 'MyUserDB' : 'MyDB';
global $$DBName;
global $_CFG;
//$Columns = "{$_CFG[UserTable][UserName]} AS UserName, CONCAT(UPPER(LEFT({$_CFG[User
大黄鸭duck.
- 粉丝: 6772
- 资源: 1万+
最新资源
- 基于java的数字化农家乐管理平台设计与实现.docx
- 基于java的旅游管理系统设计与实现.docx
- 基于java的微乐校园设计与实现.docx
- 基于java的小型医院医疗设备管理系统设计与实现.docx
- 基于java的小型企业客户关系管理系统设计与实现.docx
- STM32高频注入 STM32平台的高频注入,keil版本 高速阶段磁链观测,电机控制,高频注入 包括原理图,源代码 已移植量产使用,具有极高的参考价值
- 基于java的在线考试系统设计与实现.docx
- MATLAB 实现基于WOA(鲸鱼优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- Matlab实现基于PCA+DBO+K-means的数据聚类可视化的详细项目实例(含完整的程序,GUI设计和代码详解)
- STM32以太网串口透传,串口透传通信 STM32以太网CAN透传 STM32串口CAN透传 采用STM32作为主控,W5500以太网 包括CAN通信透传,485通信透传 USB转串口,OBD协议 包
- 鸢尾花数据集可视化代码
- MATLAB 实现基于ELM(极限学习机)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- · 功能说明:代码实现了基于YOLO模型的摔倒行为实时检测,当连续检测到摔倒的帧数超过设定阈值时触发报警 · · 过程说明:通过摄像头获取视频流帧数据,利用YOLO模型进行目标检测,统计摔倒行
- 单片机开发的高精度电压表,电流表, 可实现AD 采样基准电压,采样电阻,放大电路,显示 ADC 采样采用高精度四通道XPT 2046 基准电压采用4311增加量程 采样电阻0603并联电阻 放
- MATLAB 实现基于粒子群优化(PSO)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- javascript在链表的末尾插入一个节点,在末尾插入涉及遍历整个列表,直到我们到达最后一个节点
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈