Annotation of /trunk/user.php
Parent Directory
|
Revision Log
Revision 14 - (view) (download)
| 1 : | pith7 | 7 | <?php |
| 2 : | /** | ||
| 3 : | * FlexCP User Management | ||
| 4 : | * | ||
| 5 : | * Displays stuff. | ||
| 6 : | * | ||
| 7 : | * @author PiTh7 <friedfrogs888@yahoo.com> | ||
| 8 : | * @filesource | ||
| 9 : | * @license MIT | ||
| 10 : | * @package FlexCP | ||
| 11 : | */ | ||
| 12 : | include('config.php'); | ||
| 13 : | |||
| 14 : | session_set_cookie_params(time()+3600 ,'/',COOKIE_DOMAIN); | ||
| 15 : | session_start(); | ||
| 16 : | |||
| 17 : | include('adodb/adodb.inc.php'); | ||
| 18 : | include('Savant3.php'); | ||
| 19 : | |||
| 20 : | require_once(LIBD.'domxmlfix.php'); | ||
| 21 : | require_once(LIBD.'llsd.php'); | ||
| 22 : | require_once(LIBD.'input.php'); | ||
| 23 : | require_once(LIBD.'output.php'); | ||
| 24 : | require_once(LIBD.'user.php'); | ||
| 25 : | require_once(LIBD.'db.php'); | ||
| 26 : | require_once(LIBD.'grid.php'); | ||
| 27 : | require_once(LIBD.'captcha.php'); | ||
| 28 : | |||
| 29 : | DB::Connect(); | ||
| 30 : | User::Init(); | ||
| 31 : | |||
| 32 : | switch (REST::FetchIndex(0)) | ||
| 33 : | { | ||
| 34 : | case 'register': | ||
| 35 : | User::Init(); | ||
| 36 : | // If already registered, don't bother. | ||
| 37 : | if(User::CheckAuth(GRP_BASIC)) | ||
| 38 : | Output::Redirect(THISURL.'user.php/'); | ||
| 39 : | |||
| 40 : | Output::$cpage='user/register'; | ||
| 41 : | Output::Flush(); | ||
| 42 : | break; | ||
| 43 : | case 'login': | ||
| 44 : | Output::$cpage='user/login'; | ||
| 45 : | User::Init(); | ||
| 46 : | if(User::CheckAuth(GRP_BASIC)) | ||
| 47 : | Output::Redirect(THISURL.'user.php/'); | ||
| 48 : | if(strlen($_POST['txtUsername'])>0) | ||
| 49 : | User::CheckLogin(); | ||
| 50 : | Output::Flush(); | ||
| 51 : | break; | ||
| 52 : | case 'logout': | ||
| 53 : | User::Logout(); | ||
| 54 : | break; | ||
| 55 : | default: | ||
| 56 : | User::Init(); | ||
| 57 : | if(!User::CheckAuth(GRP_BASIC)) | ||
| 58 : | Output::Redirect(THISURL.'user.php/login/'); | ||
| 59 : | |||
| 60 : | Output::$cpage='user/dashboard'; | ||
| 61 : | Output::Flush(); | ||
| 62 : | break; | ||
| 63 : | pith7 | 12 | |
| 64 : | |||
| 65 : | pith7 | 7 | case 'profile': |
| 66 : | User::Init(); | ||
| 67 : | if(!User::CheckAuth(GRP_BASIC)) | ||
| 68 : | Output::Redirect(THISURL.'user.php/login/'); | ||
| 69 : | if(POST::WasUsed()) | ||
| 70 : | { | ||
| 71 : | $u=&User::$Data; | ||
| 72 : | $sex = POST::GetEString('radSex'); | ||
| 73 : | $realname = POST::GetEString('txtRealName'); | ||
| 74 : | $email = POST::GetEString('txtEmail'); | ||
| 75 : | $u->AIM = POST::GetEString('txtAIM',true); | ||
| 76 : | $u->ICQ = POST::GetEString('txtICQ',true); | ||
| 77 : | $u->MSN = POST::GetEString('txtMSN',true); | ||
| 78 : | $u->Skype = POST::GetEString('txtSkype',true); | ||
| 79 : | $u->SteamID = POST::GetEString('txtSteamID',true); | ||
| 80 : | |||
| 81 : | pith7 | 14 | $u->Avatar = POST::GetEString('txtAvatar',true); |
| 82 : | |||
| 83 : | $imgsize=getimagesize($u->Avatar); | ||
| 84 : | |||
| 85 : | echo $imgsize['mime']; | ||
| 86 : | |||
| 87 : | if($imgsize[0]>150 || $imgsize[0]>150) | ||
| 88 : | Output::HardError('Image specified for your avatar must be, at most, 200px by 200px.'); | ||
| 89 : | |||
| 90 : | |||
| 91 : | if( | ||
| 92 : | $imgsize['mime'] == 'image/jpeg' || | ||
| 93 : | $imgsize['mime'] == 'image/png' || | ||
| 94 : | $imgsize['mime'] == 'image/gif' || | ||
| 95 : | strlen($u->Avatar)>0 | ||
| 96 : | ) | ||
| 97 : | pith7 | 7 | { |
| 98 : | pith7 | 14 | |
| 99 : | $pass = ''; | ||
| 100 : | |||
| 101 : | if($sex!='M' AND $sex=='F') | ||
| 102 : | pith7 | 7 | { |
| 103 : | pith7 | 14 | $sex=User::$Gender; |
| 104 : | Output::AddError('Please use the radiobutton control on your profile to set your gender. Gender change reverted.'); | ||
| 105 : | pith7 | 7 | } |
| 106 : | pith7 | 14 | |
| 107 : | $p=POST::FetchIndex('txtOldPass'); | ||
| 108 : | $pass=''; | ||
| 109 : | if(User::HashPass($u->ID,$p)==$u->Passhash) | ||
| 110 : | { | ||
| 111 : | $p1=Post::FetchIndex('txtPChange1'); | ||
| 112 : | $p2=Post::FetchIndex('txtPChange2'); | ||
| 113 : | if(strlen($p1)>6 and strlen($p2)>6) | ||
| 114 : | { | ||
| 115 : | if($p1==$p2) | ||
| 116 : | $pass=$p1; | ||
| 117 : | else | ||
| 118 : | Output::HardError('Password mismatch.'); | ||
| 119 : | } | ||
| 120 : | } | ||
| 121 : | |||
| 122 : | $u->RealName=$realname; | ||
| 123 : | $u->Gender=$sex; | ||
| 124 : | //$u->DOB=POST::GetDate('datDOB'); | ||
| 125 : | |||
| 126 : | if($pass!='') | ||
| 127 : | $u->ChangePassword($pass); | ||
| 128 : | |||
| 129 : | if(!Input::CheckEmail($email)) | ||
| 130 : | { | ||
| 131 : | Output::HardError('Email entered is invalid.'); | ||
| 132 : | } | ||
| 133 : | $u->ChangeEmail($email); | ||
| 134 : | $u->Update(); | ||
| 135 : | |||
| 136 : | Output::$cpage='user/profile'; | ||
| 137 : | Output::Redirect(THISURL.'user.php/profile'); | ||
| 138 : | pith7 | 7 | } |
| 139 : | } | ||
| 140 : | Output::$cpage='user/profile'; | ||
| 141 : | Output::Flush(); | ||
| 142 : | break; | ||
| 143 : | case 'alts': | ||
| 144 : | User::Init(); | ||
| 145 : | if(!User::CheckAuth(GRP_BASIC)) | ||
| 146 : | Output::Redirect(THISURL.'user.php/login/'); | ||
| 147 : | |||
| 148 : | if(REST::FetchIndex(1)=='del') | ||
| 149 : | { | ||
| 150 : | if(UUID::IsValid(REST::FetchIndex(2))) | ||
| 151 : | { | ||
| 152 : | if(intval(REST::FetchIndex(3))>0) | ||
| 153 : | { | ||
| 154 : | $id=REST::GetUUID(2); | ||
| 155 : | $rs=DB::Execute("SELECT COUNT(*) FROM ".ADODB_PREFIX."UserAlts WHERE altUUID='$id' AND usrID=".User::$ID); | ||
| 156 : | $rec=$rs->FetchRow(); | ||
| 157 : | if(intval($rec[0])==0) Output::HardError("You cannot delete the specified alt, as you do not own it."); | ||
| 158 : | |||
| 159 : | DB::Execute("DELETE FROM ".ADODB_PREFIX."UserAlts WHERE altUUID='$id' AND usrID=".User::$ID." LIMIT 1"); | ||
| 160 : | Avatar::Find($id)->Delete(); | ||
| 161 : | Agent::Find($id)->Delete(); | ||
| 162 : | |||
| 163 : | Output::Redirect(THISURL.'user.php/alts',"Specified alt deleted."); | ||
| 164 : | } else { | ||
| 165 : | $id=REST::GetUUID(2); | ||
| 166 : | Output::Confirm("Are you sure you wish to delete this alt?",THISURL."user.php/alts/del/$id/1/",THISURL.'user.php/alts/'); | ||
| 167 : | } | ||
| 168 : | } | ||
| 169 : | } else if (REST::FetchIndex(1)=='mod' && UUID::IsValid(REST::FetchIndex(2))) | ||
| 170 : | { | ||
| 171 : | $id=REST::GetUUID(2); | ||
| 172 : | |||
| 173 : | $rs=DB::Execute("SELECT COUNT(*) FROM ".ADODB_PREFIX."UserAlts WHERE altUUID='$id' AND usrID=".User::$ID); | ||
| 174 : | list($numalts)=$rs->FetchRow(); | ||
| 175 : | |||
| 176 : | if($numalts==0) | ||
| 177 : | Output::HardError("You cannot modify the specified alt, as you do not own it."); | ||
| 178 : | |||
| 179 : | $rid=POST::GetUUID('selHomeRegion'); | ||
| 180 : | $r=Region::Find($rid); | ||
| 181 : | |||
| 182 : | if(!$r) | ||
| 183 : | Output::HardError('Region '.$rid.'not found.'); | ||
| 184 : | |||
| 185 : | $a=Avatar::Find($id); | ||
| 186 : | $a->ChangeHomeRegion($rid); | ||
| 187 : | |||
| 188 : | Output::Redirect(THISURL.'user.php/alts',"{$a->First} {$a->Last}'s home region changed to {$r->Name} successfully."); | ||
| 189 : | pith7 | 10 | } else if (REST::FetchIndex(1)=='pass' && UUID::IsValid(REST::FetchIndex(2))) |
| 190 : | { | ||
| 191 : | Output::$cpage='user/alt_pass'; | ||
| 192 : | Output::Flush(); | ||
| 193 : | pith7 | 7 | } |
| 194 : | Output::$cpage='user/alts'; | ||
| 195 : | Output::Flush(); | ||
| 196 : | break; | ||
| 197 : | case 'money': | ||
| 198 : | User::Init(); | ||
| 199 : | if(!User::CheckAuth(GRP_BASIC)) | ||
| 200 : | Output::Redirect(THISURL.'user.php/login/'); | ||
| 201 : | |||
| 202 : | Output::$cpage='user/money'; | ||
| 203 : | Output::Flush(); | ||
| 204 : | pith7 | 10 | break; |
| 205 : | pith7 | 7 | } |
| 206 : | die(''); | ||
| 207 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

