Example #1
0
}
//检测操作系统类型
if (!isset($GLOBALS['OS_WIN'])) {
    $GLOBALS['OS_WIN'] = stristr(PHP_OS, 'WIN') !== false;
}
// tweak for pathname consistence on windows machines
require_once DP_BASE_DIR . '/includes/main_functions.php';
require_once DP_BASE_DIR . '/includes/db_adodb.php';
require_once DP_BASE_DIR . '/includes/db_connect.php';
require_once DP_BASE_DIR . '/classes/ui.class.php';
require_once DP_BASE_DIR . '/classes/permissions.class.php';
require_once DP_BASE_DIR . '/includes/session.php';
// don't output anything. Usefull for fileviewer.php, gantt.php, etc.
$suppressHeaders = dPgetParam($_GET, 'suppressHeaders', false);
// manage the session variable(s)
dPsessionStart(array('AppUI'));
// write the HTML headers
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// always modified
header('Cache-Control: no-cache, must-revalidate, no-store, post-check=0, pre-check=0');
// HTTP/1.1
header('Pragma: no-cache');
// HTTP/1.0
// check if session has previously been initialised
if (!isset($_SESSION['AppUI']) || isset($_GET['logout'])) {
    if (isset($_GET['logout']) && isset($_SESSION['AppUI']->user_id)) {
        $AppUI =& $_SESSION['AppUI'];
        $user_id = $AppUI->user_id;
        addHistory('login', $AppUI->user_id, 'logout', $AppUI->user_first_name . ' ' . $AppUI->user_last_name);
Example #2
0
    You should have received a copy of the GNU General Public License
    along with dotProject; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

The full text of the GPL is in the COPYING file.
*/
//file viewer
require_once 'base.php';
require_once DP_BASE_DIR . '/includes/config.php';
require_once DP_BASE_DIR . '/includes/main_functions.php';
require_once DP_BASE_DIR . '/classes/ui.class.php';
require_once DP_BASE_DIR . '/includes/db_adodb.php';
require_once DP_BASE_DIR . '/includes/db_connect.php';
require_once DP_BASE_DIR . '/includes/session.php';
$loginFromPage = 'fileviewer.php';
dPsessionStart();
// check if session has previously been initialised
// if no ask for logging and do redirect
if (!isset($_SESSION['AppUI']) || isset($_GET['logout'])) {
    $_SESSION['AppUI'] = new CAppUI();
    $AppUI =& $_SESSION['AppUI'];
    $AppUI->checkStyle();
    require_once $AppUI->getSystemClass('dp');
    require_once DP_BASE_DIR . '/misc/debug.php';
    if ($AppUI->doLogin()) {
        $AppUI->loadPrefs(0);
    }
    // check if the user is trying to log in
    if (isset($_REQUEST['login'])) {
        $username = dPgetCleanParam($_POST, 'username', '');
        $password = dPgetCleanParam($_POST, 'password', '');
/**
 * Log the user into the application
 *
 * @param UserAuth array $user_auth -- Set user_name and password (password needs to be
 *      in the right encoding for the type of authentication the user is setup for.  
 * @param String $application -- The name of the application you are logging in from.  (Currently unused).
 * @return Array(session_id, error) -- session_id is the id of the session that was
 *      created.  Error is set if there was any error during creation.
 */
function login($user_auth, $application = 'test')
{
    $error = new SoapError();
    $success = false;
    $user_auth["user_name"] = addslashes($user_auth["user_name"]);
    $user_auth["password"] = addslashes($user_auth["password"]);
    $_POST['login'] = '******';
    $_REQUEST['login'] = '******';
    if (isset($user_auth["user_name"]) || isset($user_auth["password"])) {
        dPsessionStart(array('AppUI'));
        $AppUI = new CAppUI();
        $ok = $AppUI->login($user_auth["user_name"], $user_auth["password"]);
        if (!$ok) {
            $error->set_error('invalid_login');
            return array('id' => -1, 'error' => $error->get_soap_array());
            $AppUI->setMsg('Login Failed');
        } else {
            //Register login in user_acces_log
            $AppUI->registerLogin();
            addHistory('login', $AppUI->user_id, 'login', $AppUI->user_first_name . ' ' . $AppUI->user_last_name);
            $_SESSION['AppUI'] = $AppUI;
            $success = true;
        }
    }
    if ($success) {
        $_SESSION['is_valid_session'] = true;
        $_SESSION['type'] = 'user';
        return array('id' => session_id(), 'error' => $error);
    }
    $error->set_error('invalid_login');
    return array('id' => -1, 'error' => $error);
}