Admin Life Errors, Fixes, and Encounters

26Feb/10Off

jquery ajaxform validation preview save and edit buttons

My goal was to have a page where a user can edit, save, and preview whatever he's working on using jquery and ajaxForm.

The problem is that after after you preview, the save doesn't work anymore because the validation submit handler can't be reinialized.

Original Code

<code>
HTML code....
<form action="ajax/check.php" method="post" enctype="multipart/form-data" name="signup" id="signup">
<div id="edit_company">
<input name="name" type="text" id="name" value="" />
<textarea name="description" cols="45" rows="6" id="description"></textarea>
</div>
<div id="preview_company" style="display:none;" >
<center>
<img src='images/loading.gif' alt='loading...' /> <br />
Loding Please Wait...
</center>
</div>
<div id="preview_company_buttons" style="display:none; text-align:center; padding-top:10px;" >
<input type="submit" name="save" id="save" value="Save" />
<input type="submit" name="edit" id="edit" value="Edit" />
</div>
</form>
HTML code....
<script type="text/javascript">
$(document).ready(function() {

$.ajaxSetup ({
cache: false
});

var options = {
target: '#company_upgrade'   // target element(s) to be updated with server response
};

$("#save").validate({
rules: {
name: "required",    // simple rule, converted to {required: true}
description: {
required: true
}
},
messages: {
name: "&nbsp;&nbsp;<strong>Required</strong>",
description: "&nbsp;&nbsp;<strong>Required</strong>"
},
submitHandler: function() {
$('#preview_company').hide('fast');
$('#edit_company').hide('fast');
setTimeout("$('#company_upgrade').show('slow')", 500);
$('#signup').ajaxForm({target: '#company_upgrade'});
}
});

$("#preview").validate({
rules: {
name: "required",    // simple rule, converted to {required: true}
description: {
required: true
}
},
messages: {
name: "&nbsp;&nbsp;<strong>Required</strong>",
description: "&nbsp;&nbsp;<strong>Required</strong>"
},
submitHandler: function() {
$('#edit_company').hide('fast');
setTimeout("$('#preview_company').show('slow')", 500);
setTimeout("$('#preview_company_buttons').show('slow')", 1000);
$('#signup').ajaxForm({target: '#preview_company'});  // bind form using 'ajaxForm'
}
});

// hides the slickbox on clicking the noted link
$('#edit').click(function() {
$('#preview_company').hide('fast');
$('#preview_company_buttons').hide('fast');
setTimeout("$('#edit_company').show('slow')", 500);
return false;
});

});
</script>
HTML code....
</code>

The new code fixes the the issue by putting the validation in an if condition.

<code>
HTML code....
<form action="ajax/check.php" method="post" enctype="multipart/form-data" name="signup" id="signup">
<div id="edit_company">
<input name="name" type="text" id="name" value="" />
<textarea name="description" cols="45" rows="6" id="description"></textarea>
</div>
<div id="preview_company" style="display:none;" >
<center>
<img src='images/loading.gif' alt='loading...' /> <br />
Loding Please Wait...
</center>
</div>
<div id="preview_company_buttons" style="display:none; text-align:center; padding-top:10px;" >
<input type="submit" name="save" id="save" value="Save" />
<input type="submit" name="edit" id="edit" value="Edit" />
</div>
</form>
HTML code....
<script type="text/javascript">
$(document).ready(function() {

$.ajaxSetup ({
cache: false
});

var options = {
target: '#company_upgrade'   // target element(s) to be updated with server response
};

var val_save = {
rules: {
name: "required",    // simple rule, converted to {required: true}
description: {
required: true
}
},
messages: {
name: "&nbsp;&nbsp;<strong>Required</strong>",
description: "&nbsp;&nbsp;<strong>Required</strong>"
}
};

// hides the slickbox on clicking the noted link
$('#save').click(function() {
if ( $("#signup").validate(val_save).form() ) {
$('#preview_company').hide('fast');
$('#edit_company').hide('fast');
setTimeout("$('#company_upgrade').show('slow')", 500);
$('#signup').ajaxForm({target: '#company_upgrade'});
}

});

// hides the slickbox on clicking the noted link
$('#preview').click(function() {
if ( $("#signup").validate(val_save).form() ) {
$('#edit_company').hide('fast');
setTimeout("$('#preview_company').show('slow')", 500);
setTimeout("$('#preview_company_buttons').show('slow')", 1000);
$('#signup').ajaxForm({target: '#preview_company'});  // bind form using 'ajaxForm'
}
});

// hides the slickbox on clicking the noted link
$('#edit').click(function() {
$('#preview_company').hide('fast');
$('#preview_company_buttons').hide('fast');
setTimeout("$('#edit_company').show('slow')", 500);
return false;
});
});
</script>
HTML code....
</code>

Filed under: Code, CSS, Errors, HTML No Comments
24Feb/10Off

freebsd color directory listing

Want color in your directory listings?  Use "ls -G".  "ls -F" is also useful,
and they can be combined as "ls -FG".

Filed under: Errors No Comments
23Feb/10Off

svn cleanup not working

svn cleanup always gives the same cleanup error.

svn: In directory 'www/site/html/images'
svn: Error processing command 'committed' in 'www/site/html/images'
svn: Working copy 'www/site/html/' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)

sometimes you have to go into the directory and run the cleanup from inside there for it to work.

In my case, inside images directory I ran svn cleanup. Then went up 1 directory and ran svn cleanup agan. Repeated the last step until everything was working again.

Filed under: Errors, subversion No Comments
22Feb/10Off

Windows was unable to find a certificate to log you on to the network

"Windows was unable to find a certificate to log you on to the network [SSID]"

This is caused by having "EEE 802.1x authentication for this network" checked off. To fix this problem

Goto Start --> Programs --> Accessories --> Communications --> Network Connections --> Right-click your Connection and select Properties --> Click on the Authentication tab --> Disable / uncheck the option IEEE 802.1x authentication for this network. Now, try to connect to your Wireless network

Filed under: Errors No Comments
10Feb/10Off

vi search and replace ^M

To easily search and replace the ^M (new line) character in vi use the following command. Make sure your in command mode and not input mode when you do it.

:%s/^M$//g

to get the proper ^M in vi you'll need to do CTRL-v CTRL-M and that should display ^M

Filed under: commands, Errors, Unix No Comments
9Feb/10Off

repair outlook using a free program

If you can't open your PST or you suspect that your .pst or .ost data file is corrupt, you can use the Inbox Repair tool (Scanpst.exe), to diagnose and repair errors in the file.

  1. Quit Microsoft Outlook if it's running.
  2. Double-click Scanpst.exe, located at drive:\Program Files\Common Files\System\MSMAPI\LocaleID folder - where LocaleID is the locale identifier (LCID) for the installation of Microsoft Office. The LCID for English - United States is 1033.
  3. In the Enter the name of the file you want to scan box, enter the name of the .pst or .ost file that you want to check, or click Browse to look for the file.
  4. To specify scan log options, click Options, and then click the option you want.
  5. Click Start.
  1. When the scanning is completed, and if errors were found, you will be prompted to start the repair process.

To change the name or location of the backup file created during the repair process, in the Enter name of backup file box, enter a new name, or click Browse to look for the file.

  1. Click Repair.
  2. Start Outlook using the profile that contains the .pst file that you tried to repair.
  3. On the Go menu, click Folder List (Folder List: Displays the folders available in your mailbox. To view subfolders, click the plus sign (+) next to the folder. If the Folder List is not visible, on the Go menu, click Folder List.).

In the Folder List, you may see a Recovered Personal Folders folder containing default Outlook folders or a Lost and Found folder. The recovered folders are usually empty, because this is a rebuilt .pst file. The Lost and Found folder contains folders and items that the Inbox Repair tool recovered. Items that are missing from the Lost and Found folder cannot be repaired.

  1. If you see a Recovered Personal Folders folder, you can create a new .pst file, and then drag the items in the Lost and Found folder into the new .pst file. When you have finished moving all items, you can remove the Recovered Personal Folders (.pst) file, including the Lost and Found folder, from your profile.

Notes

  • If you are able to open the original .pst file, you may be able to recover additional items from your damaged .pst file. By default, the Inbox Repair tool creates a file called file name .bak, which is a copy of the original .pst file with a different extension. The .bak file is located in the same folder as your original .pst file. You may be able to recover items from the .bak file that the Inbox Repair tool could not recover. Make a copy of the .bak file, giving the file a new name with a .pst extension. Import the "bak.pst" file, and then move any additional recovered items to the new .pst file that you created.
  • A copy of the log file is written to the same location as the .pst file.
9Feb/10Off

outlook undelete emails

How to: Recover Deleted Emails in Outlook for FREE

It’s unbelievable how many products you can purchase to recover deleted emails in Outlook. Usually they're a free demo that ‘tease” you by showing what would be recovered, only if you purchased their full-version.

I’ve shown that you don’t need to purchase Automatic Windows Cleanup Software – and you don’t need to purchase Outlook Recovery Software to undelete an email!

When you delete an email in Outlook – it really isn’t deleted; it’s only “marked” for deletion. It’s only until you “compact” your PST file that your email is permanently erased, and the empty space is reclaimed.

Outlook’s Inbox Repair Tool (ScanPST.exe) can diagnose and repair errors in your PST file.  If the file is not corrupt, it does some minor clean-up – but if the file IS corrupt it also reverts all objects to “not deleted.”

So we’ll first need to “corrupt” our PST file to have ScanPST reclaim our “deleted” emails. [NOTE: I'm not including detailed instructions. If you're not comfortable please ask someone to help you.]

1) Locate and backup your Outlook PST file

2) From the Command Prompt type what’s in bold (not the hyphens "-")

DEBUG C:\fullpath\OutlookFile.PST
- f  107  113  20
- q

3) Now that you’ve “corrupted” your PST file run ScanPST (usually found in C:\Program Files\Common Files\System\Mapi\1033)

4) Once ScanPST completes, your deleted emails will be restored.


Recover the Deleted Items

If you don't know what a Hex editor is, you probably shouldn't be hex editing anything, but if you want to try, Google for "hex editor" - UltraEdit is probably the best and easiest one to use. Before doing anything to the PST with a Hex Editor, make a copy of the PST, or you may end up losing all of your e-mail.

  1. Open the PST in the Hex editor.
  2. Delete positions 7 through 13 with the spacebar. Since you're using hexadecimal numbering, this actually clears 13 characters in the following positions:
    00007, 00008, 00009, 0000a, 0000b, 0000c, 0000d
    0000e, 0000f, 00010, 00011, 00012, 00013
    As you clear the characters, the editor displays the code “20” in their position.

  1. Save the PST, it is now corrupted.
  2. Run the Inbox Repair Tool, SCANPST.exe, to recover the file. Use Windows Search utility to find it. For additional information on the Inbox Repair Tool, see KB article 287497
  3. The Inbox Repair Tool creates a backup and repairs the damage and recreates the PST.

Open the new PST in Outlook. The Deleted Items folder should now contain the deleted messages, unless Outlook has already deleted them for good by compacting the PST.

9Feb/10Off

backup outlook 2003

Just copy the outlook folder to a new location (desktop, memory key, etc)

Backing up outlook 2003
Close down outlook before backing up
Note: is your Windows name account.

Windows XP
C:\Documents and Settings\\Local Settings\Application Data\Microsoft\Outlook

Windows Vista/7
C:\Users\\AppData\Local\Microsoft\Outlook

Backing up outlook 2007
Close down outlook before backing up
Note: is your Windows name account.

Windows XP
C:\Documents and Settings\\Local Settings\Application Data\Microsoft\Outlook

Windows Vista/7
c:\users\\AppData\Local\Microsoft\Outlook

to restore, copy the backup to the same folder location, just make sure outlook is closed.

5Feb/10Off

Installing Apache Tomcat 6 on FreeBSD

So you want to install Tomcat 6 on FreeBSD, this is how I did it.

cd /usr/ports/www/tomcat6
make install clean

use the default Options for diablo-jdk

Then you get some nice "licensing restrictions"

Because of licensing restrictions, you must fetch the distribution
manually.

Please access

http://www.FreeBSDFoundation.org/cgi-bin/download?download=diablo-caffe-freebsd6-i386-1.6.0_07-b02.tar.bz2

with a web browser and "Accept" the End User License Agreement for
"Caffe Diablo 1.6.0".

Please open http://java.sun.com/javase/downloads/index.jsp
in a web browser and follow the "Download" link for
"JDK US DST Timezone Update Tool - 1_3_21" to obtain the
time zone update file, tzupdater-1_3_21-2009p.zip.

Please place the downloaded file(s) in /usr/ports/distfiles.

*** Error code 1

Stop in /usr/ports/java/diablo-jdk16.
*** Error code 1

Stop in /usr/ports/java/diablo-jdk16.
*** Error code 1

Stop in /usr/ports/www/tomcat6.

So we go to the freebsd foundation website and download diablo caffe.
Then we go to the sun websute to download the Timezone update and what do you know, Sun has version 1.3.25 and not 1.3.21.

So we do an "cvsup -g -L 2 /root/cvs-supfile" on our system to update the ports collection.
... wait 10..20 minutes as the system wasn't up to date ...

While that's going, we copy (sftp) the file over to the server "diablo-caffe-freebsd6-i386-1.6.0_07-b02.tar.bz2"

cp /home/user_name/diablo-caffe-freebsd6-i386-1.6.0_07-b02.tar.bz2 /usr/ports/distfiles

The ports collection was updated but it didn't do anything, still need 1.3.21... Maybe because it's an old version of FreeBSD (6.2) o_0
Luckily for me, I had tzupdater-1_3_21-2009p.zip from a pervious install on another server (email me if you need the file)
I rsync the file accross

rsync -ave ssh /usr/ports/distfiles/tzupdater-1_3_21-2009p.zip us[email protected]:/home/user_name/tzupdater-1_3_21-2009p.zip

cp /home/user_name/tzupdater-1_3_21-2009p.zip /usr/ports/distfiles
cd /usr/ports/www/tomcat6
make install clean

The installation continues. Then it finishes without issue.

cd /usr/local/apache-tomcat-6.0
vi RUNNING.txt

To run it, we need to set up the JAVA_HOME environment variable... I'm on the bash shell (GO BASH) and we installed the JDK not JRE so I do

JAVA_HOME=/usr/local/diablo-jdk1.6.0
cd /usr/local/etc/rc.d/
./tomcat6 start

and nothing happened... Probably because it's not in /etc/rc.conf

cd /usr/local/apache-tomcat-6.0/logs/
ls -l

no logs in the log folder...

cd /usr/local/apache-tomcat-6.0/bin/

./startup.sh

Now we have logs

tail catalina.out

The following line shows up...

Feb 5, 2010 10:17:01 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8180

so we go to http://192.168.1.101:8180 and just like that it comes up..

If you want to change the port, edit /usr/local/apache-tomcat-6.0/conf/server.xml

Now that was a long install, hope it helps someone.

4Feb/10Off

postfix bcc on all emails

Track the email messages that make their way across your system.
What are those reasons? You may have noticed an increase in email abuse, either internal or external, Where forwarding a copy of each message to an administrator would be desirable.

If your looking just to get bcc'ed on a users email, please look at my previous post.

# cd /etc/postfix
# vi main.cf

//add this line to the bottom of your main.cf
[email protected]

save and quit then restart postfix.

# cd /usr/local/sbin
# ./postfix reload

now every email that gets sent through that machine, [email protected] will get bcc'ed on it.