Feed on
Posts
Comments

Archive for the 'Programming' Category

MySQL vs IIS7

CONCATing strings with numeric fields may return a binary value, depending on the OPTION parameter given in the connection string.

Read Full Post »

Save & Delete Attachments

This macro for Outlook 2002 will traverse every folder in your “Inbox” and then save any attachments to a location you speficy, mirroring the structure of your Inbox. Once saved, the attachments are removed from the email message. A note is added to the top of affected messages to indicate where the attachment has been [...]

Read Full Post »

Strip HTML Tags

Fairly self-explanatory. This example gets its input from a file called ‘filename’, strips the HTML markup and displays what’s left in the browser. <? $fp=fopen (“filename”,”r”); $file=fread ($fp,filesize (“filename”)); $fclose($fp); $pattern=”‘<[\/\!]*?[^<>]*?>’si”; $replace=””; $file = preg_replace ($pattern, $replace, $filev[$r]); print “$file”; ?>

Read Full Post »

RC4 Encryption

To use this code, simply call the EnDeCrypt function with two parameters: the string you want to encrypt/decrypt; the encryption password. <? function EnDeCrypt($plaintext,$strPwd) { $intLength=strlen($strPwd); $sbox=Array(); $key=Array(); $cipher=”; $i=0; $j=0; for ($a=0; $a<256; $a++) { $key[$a]=ord(substr($strPwd,($a % $intLength),1)); $sbox[$a]=$a; } $b=0; for ($a=0; $a<256; $a++) { $b=($b + $sbox[$a] + $key[$a]) % 256; $tempSwap [...]

Read Full Post »

MS Access Database Structure

This VBScript ASP writes the structure of a MS Access database to the browser. Change the value of dbName accordingly. <% dbName=”c:\temp\temp.mdb” Set DataConnection = _ Server.CreateObject(“ADODB.Connection”) DataConnection.ConnectionString = _ “Provider=Microsoft.Jet.OLEDB.4.0; _ Data Source=” & dbName & “; _ Jet OLEDB:Database Password=dbpwd;” DataConnection.Open Set rs = DataConnection.OpenSchema(20) While rs.EOF <> True If Left(rs.Fields(“Table_Name”).Value, 4) <> [...]

Read Full Post »

List Form Elements

This VBScript ASP writes the contents of form fields from the previous page (submitted with the POST method) into hidden fields on the current page. I found this handy when I needed to spread a form over several pages – it’s far quicker than writing hidden fields by hand, and you don’t have to worry [...]

Read Full Post »

LTrim() RTrim() Trim()

To use these, just call LTrim(), RTrim(), or Trim() with the string you want trimmed. <script type=”text/javascript”> <!– function LTrim(trimInputString) { while(trimInputString.charAt(0)==” “) trimInputString=trimInputString.substring(1,trimInputString.length); return (trimInputString); } function RTrim(trimInputString) { while(trimInputString.charAt(trimInputString.length-1)==” “) trimInputString=trimInputString.substring(0,trimInputString.length-1); return (trimInputString); } function Trim(trimInputString) { while(trimInputString.charAt(0)==” “) trimInputString=trimInputString.substring(1,trimInputString.length); while(trimInputString.charAt(trimInputString.length-1)==” “) trimInputString=trimInputString.substring(0,trimInputString.length-1); return (trimInputString); } //–> </script>

Read Full Post »

List Last x Days

To show the dates for Today – x days, set the value of x accordingly. <script type=”text/javascript”> <!– DateToday = new Date(); x=7; for (y=0; y<x; y++) { MyDate = new Date(Date.UTC(parseInt( _ DateToday.getYear()), _ parseInt(DateToday.getMonth()), _ parseInt(DateToday.getDate()))- _ (60*60*24*1000*y)); MyDateString=MyDate.getDate() + ‘.’ _ + parseInt(MyDate.getMonth()+1) _ + ‘.’ + MyDate.getYear(); document.write (MyDateString + “<br>”); [...]

Read Full Post »

isInArray()

If you want to check whether a particular value is in an array, call this function with something like this. if (isInArray(MyValue, MyArray)) <script type=”text/javascript”> <!– function isInArray(needle, arrayHaystack) { for (x=0; x < arrayHaystack.length; x++) if (arrayHaystack[x] == needle) return true; return false; } –> </script>

Read Full Post »

Get a value from an NVP String

To use this, call GetNVP(string NVPString, string NVPid) with the input NVP string and the name of the value you want to retrieve. <script type=”text/javascript”> <!– function GetNVP(NVPString,NVPid) { var NVPFound=false; var NVPArray=new Array(); var NVPList=NVPString.split(‘&’); for (x=0; x<NVPList.length; x++) { NVPData=NVPList[x].split(‘=’); NVPArray[NVPData[0>=NVPData[1]; } for (var LocalID in NVPArray) if(NVPid==LocalID) NVPFound=true; if (NVPFound) return (NVPArray[NVPid]); [...]

Read Full Post »

Next »