query( 'INSERT INTO contributor (name, default_image) VALUES ("' . mysqli_real_escape_string($mtdb->link, $username) . '", "'.$username.'.png")' ); $user = get_userdatabylogin( $username ); $userid = $user->id; $info.='
User Account Created
'; adminlog("User '".$username."' created.", MTS_USER, MTA_ADD); $user_old = $user; } else { $userid = (int) $_POST['edit']; $user_old = $user = get_userdatabyid( $userid ); } $user->nameplate = $_POST['nickname']; $user->default_image = $user_old->default_image; $user->default_link = $_POST['rant-link']; $user->email = $_POST['email']; if( !empty($_POST['password_new1']) && !empty($_POST['password_new2']) ) { if( $_POST['password_new1'] !== $_POST['password_new2'] ) { $error.='New passwords do not match.
'; } else { /* password change */ if( ! $mtdb->getOne( 'SELECT id FROM contributor WHERE id = "' . (int)$user->id . '" AND (password = SHA1("' . mysqli_real_escape_string($mtdb->link, $_POST['password_old']) . '") OR password = "")' )) { $error.='Specified password is incorrect.
'; } else { /* Password match */ $user->password = $_POST['password_new1']; change_password( $user ); $info.='Password successfully changed.
'; } } } function handle_upload( &$user ) { global $info,$error; if( !$_FILES['rant_image'] ) return; if( '' == $_FILES['rant_image']['name'] ) return; if( UPLOAD_ERR_NO_FILE == $_FILES['rant_image']['error'] ) return; if( 0 == $_FILES['rant_image']['size'] ) return; $info.='Tried to upload an image.
'; // Uploading new rant image $imagedata = getimagesize($_FILES['rant_image']['tmp_name']); if( 300 !== $imagedata[0] ) { $error.='Image wrong width: '.$imagedata[0].'
'; return; } if( 245 !== $imagedata[1]) { $error.='Image wrong height: '.$imagedata[1].'
'; return; } switch( $_FILES['rant_image']['type'] ) { case 'image/jpeg': case 'image/jpg': $ext = 'jpg'; break; case 'image/gif': $ext = 'gif'; break; case 'image/png': $ext = 'png'; break; case 'image/bmp': $ext = 'bmp'; break; case 'image/tiff': $ext = 'tiff'; break; default: $error.='Unknown image extension. Upload refused.
'; return; } $destination_path = $user->name.'.'.$ext; if( !is_uploaded_file( $_FILES['rant_image']['tmp_name'] )) { $error.='Something went wrong while retrieving the uploaded image.
'; return; } if( move_uploaded_file($_FILES['rant_image']['tmp_name'], RANTIMG.$destination_path) ) { // TODO: SITE_PATH_ABS .'/'. SITE_RANT ? // great $user->default_image = $destination_path; $info.='New rant image uploaded.
'; } else { $error.='Something went wrong while storing the uploaded image.
'; adminlog("File system error while uploading rant image.", MTS_USER, MTA_MODIFY, E_WARNING); } } handle_upload( $user ); save_userdata( $user ); $info.='Changes to user profile information were saved successfully.
'; adminlog("Profile updated for user ".$user->name.".", MTS_USER, MTA_UPDATE); } else { $userid = (int) $_GET['edit']; $user = get_userdatabyid( $userid ); } if( !$user ) $error.='The specified user does not exist.
'; adminhead('Edit User Profile'); adminmenu('users.php'); if( $user ) { ?>