Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //setup the page
- initMenu();
- setBg();
- $('#quickReplyContent').wysiwym(Wysiwym.BBCode, {
- helpEnabled: false,
- helpToggle: false,
- });
- //get user information
- var usrToken = getCookie("token");
- if(usrToken != false)
- {
- var usrData = usrToken.split(".");
- var usrId = usrData[2];
- var oldUser = oldUserCheck(usrId);
- if(oldUser == 1)
- {
- var passChange = true;
- }
- else
- {
- var passChange = false;
- }
- var user = getUser(usrId);
- }
- else
- {
- $('#userLoggedIn').hide();
- $('#userLoggedOut').show();
- }
- if(passChange == true)
- openModal('passChange', 350, 'Alert!');
- //events
- $('#loginBtn').click(function(e) {
- e.preventDefault();
- openModal('login_box', 450, 'Login');
- });
- $('#registerBtn').click(function(e) {
- e.preventDefault();
- openModal('register_form_box', 650, 'Registration');
- });
- $('#searchBtn').click(function(e){
- e.preventDefault();
- searchToggle();
- });
- $('#newTopicBtn').click(function(e) {
- e.preventDefault();
- if(usrId != 0)
- {
- openModal('newTopic', 650, 'New Topic');
- }
- else
- {
- openModal('notAMember', 650, 'Alert!');
- }
- });
- $('#quickReplyLink').click(function(e){
- e.preventDefault();
- if( $('#quickReplyBox').is(':visible') )
- $('#quickReplyBox').fadeOut();
- else
- $('#quickReplyBox').fadeIn();
- });
- //form bindings
- $('a[name=usrLogout]').click(function(){
- var data = 'mode=logout';
- $("#confirmLogout").dialog({
- modal: true,
- width: 350,
- title: "Logout?",
- resizable: false,
- show: 'fade',
- hide: 'fade',
- buttons: {
- "Confirm": function() {
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'good')
- {
- $('#logoutResponse').css("display","none");
- $('#logoutResponse').html('You have succesffully been logged out.');
- $('#logoutResponse').fadeIn(1000);
- var usrInfoStr = '<a href="#" class="headerNav loginBtn">Login</a>' +
- ' <a href="#" class="headerNav registerBtn">Register</a>';
- $('#userInfo').html('');
- $('#userInfo').html(usrInfoStr);
- if( $("#admLink").length > 0 )
- {
- $('#admLink').html('');
- }
- setTimeout(function(){
- $('#confirmLogout').dialog("close");
- }, 3000);
- }
- }
- });
- },
- Cancel: function() {
- $("#confirmLogout").dialog( "close" );
- }
- }
- });
- $('.ui-widget-overlay').hide().fadeIn();
- });
- $('#prefsEmail').bind('submit', function() {
- var error = '';
- var email = $('input[name=newEmail]').val();
- var confirm_email = $('input[name=newEmailConfirm]').val();
- if(email == '')
- {
- error = error + '<br />No email entered!';
- }
- if(email != '')
- {
- if(email != confirm_email)
- {
- error = error + '<br />The email addresses do not match!';
- }
- }
- if(error != '')
- {
- $('#emailError').css("display","none");
- $('#emailError').html(error);
- $('#emailError').fadeIn(1000);
- }
- else
- {
- var data = 'mode=prefsEmailUpdate&email=' + encodeURIComponent(email) + '&u=' + userId;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'edited')
- {
- $('#emailError').css("display", "none");
- $('#emailError').html("You have successfully updated your email address.");
- $('#emailError').fadeIn(1000);
- }
- }
- });
- }
- });
- $('#prefsPassword').bind('submit', function() {
- var error = '';
- var pass = $('input[name=newPass]').val();
- var confirm_pass = $('input[name=newPassConfirm]').val();
- if(pass == '')
- {
- error = error + '<br />No email entered!';
- }
- if(pass != '')
- {
- if(pass != confirm_pass)
- {
- error = error + '<br />The email addresses do not match!';
- }
- }
- if(error != '')
- {
- $('#passError').css("display","none");
- $('#passError').html(error);
- $('#passError').fadeIn(1000);
- }
- else
- {
- var data = 'mode=prefsPassUpdate&pass=' + encodeURIComponent(pass) + '&u=' + userId;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'edited')
- {
- $('#passError').css("display", "none");
- $('#passError').html("You have successfully updated your password.");
- $('#passError').fadeIn(1000);
- }
- }
- });
- }
- });
- $('#prefsGeneral').bind('submit', function() {
- var tz = $('input[name=timezone]').val();
- var dateformat = $('input[name=dateformat]').val();
- var sort = $('input[name=sort]').val();
- var topic_sort = $('input[name=topic_sort]').val();
- var data = 'prefsGeneralUpdate&tz=' + encodeURIComponent(tz) + '&dateformat=' + encodeURIComponent(dateformat) + '&sort=' + encodeURIComponent(sort) + '&topic_sort=' + encodeURIComponent(topic_sort) + '&u=' + userId;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'edited')
- {
- $('#prefsGeneralError').css("display", "none");
- $('#prefsGeneralError').html("You have successfully updated your General Preferences.");
- $('#prefsGeneralError').fadeIn(1000);
- }
- }
- });
- });
- $('#prefsUserInfo').bind('submit', function() {
- var value = {};
- $.each($('#prefsUserInfo').serializeArray(), function(i, field) {
- if(field.name == 'userSig' || field.name == 'userWeb')
- {
- value[field.name] = encodeURIComponent(stripHTML(field.value));
- }
- else
- {
- value[field.name] = encodeURIComponent(stripSpecial(stripHTML(field.value)));
- }
- });
- var data = 'mode=prefsInfoUpdate&loc=' + value['userLocation'] + '&occ=' + value['userOcc'] + '&icq=' + value['userICQ'] + '&aim=' + value['userAIM'] + '&yim=' + value['userYIM'] + '&msnm=' + value['userMSNM'] + '&jabber=' + value['userJabber'] + '&skype=' + value['userSkype'] + '&web=' + value['userWeb'] + '&interests=' + value['userInterests'] + '&sig=' + value['userSig'] + '&u=' + userId;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'edited')
- {
- $('#prefsInfoError').css("display", "none");
- $('#prefsInfoError').html("You have successfully updated your User Information.");
- $('#prefsInfoError').fadeIn(1000);
- }
- }
- });
- });
- $('#postEditForm').bind('submit', function() {
- var error = '';
- var postSubject = $('input[name=editPostSubject]').val();
- var postContent = $('textarea[name=editPostContent]').val();
- var postId = $('input[name=editPostId]').val();
- if(postContent == '' || postContent.length < 2)
- {
- error = error + '<br />You must enter a longer post.';
- }
- if(error != '')
- {
- $('#postEditError').css("display","none");
- $('#postEditError').html(error);
- $('#postEditError').fadeIn(1000);
- }
- else
- {
- var data = 'mode=editPostUpdate&postSubject=' + encodeURIComponent(postSubject) + '&postContent=' + encodeURIComponent(postContent) + '&postId=' + postId;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'edited')
- {
- $('#postEditError').css("display", "none");
- $('#postEditError').html("You have successfully edited the post.");
- $('#postEditError').fadeIn(1000);
- setTimeout(function(){
- $('#editFormBox').dialog("close");
- }, 3000);
- }
- }
- });
- }
- });
- $('#quickReply').bind('submit', function() {
- var error = '';
- var postSubject = $('input[name=quickReplySubject]').val();
- var postContent = $('textarea[name=quickReplyContent]').val();
- var postCategory = $('input[name=quickReplyCategory]').val();
- var postTopic = $('input[name=quickReplyTopic]').val();
- if(postContent == '' || postContent.length < 2)
- {
- error = error + '<br />You must enter a longer post.';
- }
- if(postCategory == '' || postTopic == '' || postCategory == null || postTopic == null)
- {
- error = error + '<br />There was a fatal error while submitting your post. Please try again later';
- }
- if(error != '')
- {
- $('#quickReplyError').css("display","none");
- $('#quickReplyError').html(error);
- $('#quickReplyError').fadeIn(1000);
- }
- else
- {
- var data = 'mode=newPost&postSubject=' + encodeURIComponent(postSubject) + '&postContent=' + encodeURIComponent(postContent) + '&postCat=' + postCategory + '&postTopic=' + postTopic + '&u=' + usrId;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'added')
- {
- $('#newTopicError').css("display", "none");
- $('#newTopicError').html("You have added your reply.");
- $('#newTopicError').fadeIn(1000);
- setTimeout(function(){
- $('#newTopic').dialog("close");
- }, 3000);
- }
- }
- });
- }
- });
- $('#newTopic_form').bind('submit', function() {
- var error = '';
- var topicTitle = $('input[name=newTopicTitle]').val();
- var topicBody = $('textarea[name=newTopicBody]').val();
- if(topicTitle == '' || topicTitle.length < 2)
- {
- error = error + '<br />You must enter a longer title.';
- }
- if(topicBody == '' || topicBody.length < 2)
- {
- error = error + '<br />You must enter a longer topic.';
- }
- if(error != '')
- {
- $('#newTopicError').css("display","none");
- $('#newTopicError').html(error);
- $('#newTopicError').fadeIn(1000);
- }
- else
- {
- var catID = getParameterByName('id');
- var data = 'mode=newTopic&cat_id=' + catID + '&title=' + encodeURIComponent(topicTitle) + '&content=' + encodeURIComponent(topicBody) + '&u=' + usrId;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'added')
- {
- $('#newTopicError').css("display", "none");
- $('#newTopicError').html("You have added your topic.");
- $('#newTopicError').fadeIn(1000);
- setTimeout(function(){
- $('#newTopic').dialog("close");
- }, 3000);
- }
- }
- });
- }
- return false;
- });
- $('#register_form').bind('submit', function() {
- var error = '';
- var min_age = 18;
- var username = $('input[name=register_name]').val();
- var pass = $('input[name=register_pass]').val();
- var confirm_pass = $('input[name=register_confirm_pass]').val();
- var email = $('input[name=register_email]').val();
- var confirm_email = $('input[name=register_confirm_email]').val();
- var antibot = $('input[name=register_antibot]').val();
- var tz = $('input[name=timezone]').val();
- antibot = antibot.toLowerCase();
- if(antibot != "trb")
- {
- error = error + '<br />You must fill in the antibot question.';
- }
- if(username == '' || username.length < 2)
- {
- error = error + '<br />Your username is too short. Minimum of 2 characters, please.';
- }
- if(pass == '' || pass.length < 2)
- {
- error = error + '<br />Your password is too short. Minimum of 2 characters, please.';
- }
- if(pass != confirm_pass)
- {
- error = error + '<br />The passwords you entered did not match.';
- }
- if(email == '')
- {
- error = error + '<br />You must enter an email address.';
- }
- if(email != confirm_email)
- {
- error = error + '<br />The email addresses you entered did not match.';
- }
- if(error != '')
- {
- $('#register_error').css("display","none");
- $('#register_error').html(error);
- $('#register_error').fadeIn(1000);
- }
- else
- {
- var data = 'mode=register&username=' + encodeURIComponent(username) + '&password=' + encodeURIComponent(pass) + '&email=' + encodeURIComponent(email) + '&tz=' + tz;
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'emailBad')
- {
- $('#register_error').css("display","none");
- $('#register_error').html('The email address you entered is already in use.');
- $('#register_error').fadeIn(1000);
- setTimeout(function(){
- $('#register_form_box').dialog("close");
- }, 3000);
- }
- if(data.response == 'usernameBad')
- {
- $('#register_error').css("display","none");
- $('#register_error').html('The username you entered is already in use.');
- $('#register_error').fadeIn(1000);
- setTimeout(function(){
- $('#register_form_box').dialog("close");
- }, 3000);
- }
- if(data.response == 'good')
- {
- $('#register_error').css("display","none");
- $('#register_error').html('Congratulations, you have successfully registered your account.<br />You can safely close this window, now.');
- $('#register_error').fadeIn(1000);
- $('#userLoggedOut').hide();
- $('#userLoggedIn').html('Logged in as: <strong><a href="member/' + data.user_name_clean + '">' + data.username + '</a></strong> <a href="javascript:usrToolToggle();" id="usrToolDrop"><img src="./css/images/down_arrow.png" /></a>' +
- ' <a href="#" class="headerNav searchBtn">Search</a>').show();
- setTimeout(function(){
- $('#register_form_box').dialog("close");
- }, 3000);
- }
- }
- });
- }
- return false;
- });
- $('#login_form').bind('submit', function() {
- var error = '';
- var username = $('input[name=login_name]').val();
- var pass = $('input[name=login_pass]').val();
- var usernameClean = username.replace(" ", "_").toLowerCase();
- if(username == '')
- {
- error = error + '<br />Please enter your username.';
- }
- if(pass == '')
- {
- error = error + '<br />Please enter your password.';
- }
- if(error != '')
- {
- $('#login_error').css("display","none");
- $('#login_error').html(error);
- $('#login_error').fadeIn(1000);
- setTimeout(function(){
- $('#login_box').dialog("close");
- }, 3000);
- }
- else
- {
- var data = 'mode=login&username=' + encodeURIComponent(usernameClean) + '&password=' + encodeURIComponent(pass);
- $.ajax({
- url: "data.php",
- type: "POST",
- dataType: "json",
- data: data,
- cache: false,
- success: function(data) {
- if(data.response == 'noUser')
- {
- $('#login_error').css("display","none");
- $('#login_error').html('No user was found by that name.');
- $('#login_error').fadeIn(1000);
- setTimeout(function(){
- $('#login_box').dialog("close");
- }, 3000);
- }
- if(data.response == 'wrongPass')
- {
- $('#login_error').css("display","none");
- $('#login_error').html('That password is incorrect.');
- $('#login_error').fadeIn(1000);
- setTimeout(function(){
- $('#login_box').dialog("close");
- }, 3000);
- }
- if(data.response == 'good')
- {
- $('#login_error').css("display","none");
- $('#login_error').html('Congratulations, you have successfully logged into your account.<br />You can safely close this window, now.');
- $('#login_error').fadeIn(1000);
- $('#userLoggedOut').hide();
- $('#userLoggedIn').html('Logged in as: <strong><a href="member/' + data.user_name_clean + '">' + data.username + '</a></strong> <a href="javascript:usrToolToggle();" id="usrToolDrop"><img src="./css/images/down_arrow.png" /></a>' +
- ' <a href="#" class="headerNav searchBtn">Search</a>').show();
- if(data.user_type == 1)
- {
- var admLinkStr = '<div id="admLink" style="clear:both;margin:0 auto;text-align:center;">' +
- '<a href="admin.php">Admin Control Panel</a>' +
- '</div>';
- $('#footer').after(admLinkStr);
- }
- setTimeout(function(){
- $('#login_box').dialog("close");
- }, 3000);
- }
- }
- });
- }
- return false;
- });
Add Comment
Please, Sign In to add comment