Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        frontend
5
 * @package         account
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: AccountSignup.php 2070 2014-01-03 01:21:42Z darkviper $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/account/AccountSignup.php $
14
 * @lastmodified    $Date: 2014-01-03 02:21:42 +0100 (Fri, 03 Jan 2014) $
15
 *
16
 */
17

    
18
 require_once(WB_PATH."/framework/class.frontend.php");
19

    
20
 class AccountSignup
21
 {
22

    
23
	 const SIGNUP_DEBUG = false;
24

    
25
	 static public $oWbInstance = null;
26

    
27
     static public function getWbInstance()
28
     {
29
          if( $oWbInstance = null ) {
30
              $oWbInstance = new frontend();
31
          }
32
     }
33

    
34
	/**
35
	 * get systemadnistrator e-mail
36
	 *
37
	 * @return string
38
	 */
39
	static public function emailAdmin()
40
	{
41
        $retval = '';
42
		$sql  = 'SELECT `email` FROM `'.TABLE_PREFIX.'users` ';
43
		$sql .= 'WHERE `user_id`=\'1\' ';
44
        $retval = WbDatabase::getInstance()->get_one($sql);
45
		return $retval;
46
	}
47

    
48
	/**
49
	 * get user e-mail
50
	 *
51
	 * @return string
52
	 */
53
	static public function emailUser($iUserId=1)
54
	{
55
        $retval = '';
56
		$sql  = 'SELECT `email` FROM `'.TABLE_PREFIX.'users` ';
57
		$sql .= 'WHERE `user_id`=\''.$iUserId.'\' ';
58
        $retval = WbDatabase::getInstance()->get_one($sql);
59
		return $retval;
60
	}
61

    
62
	 /**
63
	  * hidden last two blocks from user ip
64
	  *
65
	  * @return string
66
	  */
67
	 static public function ObfuscateIp()
68
	 {
69
	    $sClientIp = (isset($_SERVER['REMOTE_ADDR']))
70
	                         ? $_SERVER['REMOTE_ADDR'] : '000.000.000.000';
71
	    $iClientIp = ip2long($sClientIp);
72
	    $sClientIp = long2ip(($iClientIp & ~65535));
73
	    return $sClientIp;
74
	}
75

    
76
	static public function deleteOutdatedConfirmations()
77
	{
78
		$sql = 'DELETE FROM `'.TABLE_PREFIX.'users` WHERE `confirm_timeout` BETWEEN 1 AND '.time();
79
		WbDatabase::getInstance()->query($sql);
80
	}
81

    
82
	/**
83
	 * AccountSignup::checkPassWordConfirmCode()
84
	 *
85
	 * @param string $sPassword
86
	 * @param string $sConfirmCode
87
	 * @return boolean
88
	 */
89
	static public function checkPassWordConfirmCode( $sPassword, $sConfirmCode )
90
	{
91
        $retVal = 0;
92
		if( preg_match('/[0-9a-f]{32}/i', $sConfirmCode) ) {
93
			$sql = 'SELECT `user_id` FROM `'.TABLE_PREFIX.'users` '
94
			     . 'WHERE `password`=\''.md5($sPassword).'\' '
95
			     .       'AND `confirm_code`=\''.$sConfirmCode.'\'';
96
			if( $retVal = WbDatabase::getInstance()->get_one($sql)) {
97
				return $retVal;
98
			}
99
		}
100
		return $retVal;
101
	}
102

    
103
	/**
104
	 * AccountSignup::GetBowserLanguage()
105
	 *
106
	 * @param string $defaultLanguage
107
	 * @return string upper 2 digits
108
	 */
109
	static public function GetBowserLanguage( $defaultLanguage ='en' )
110
	{
111
		$sAutoLanguage = strtoupper($defaultLanguage); // default, if no information from client available
112
		if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
113
			if(preg_match('/([a-z]{2})(?:-[a-z]{2})*/i', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']), $matches)) {
114
				$sAutoLanguage = strtoupper($matches[1]);
115
			}
116
		}
117
		return $sAutoLanguage;
118
	}
119

    
120
	static public function saveNewConfirmation($sConfirmCode) {
121
		$sql = 'UPDATE `'.TABLE_PREFIX.'users` '
122
		     . 'SET `active`=1, '
123
//		     .     '`groups_id`='.DEFAULT_GROUP.', '
124
		     .     '`confirm_code`=\'\', '
125
		     .     '`confirm_timeout`=0 '
126
		     . 'WHERE `confirm_code`=\''.$sConfirmCode.'\'';
127
		WbDatabase::getInstance()->query($sql);
128
	}
129

    
130
	static public function spamSecure($sVal) {
131
		return preg_replace('/(\n+|\r+|%0A|%0D)/i', '', $sVal);
132
	}
133

    
134
}
(1-1/22)