<?php
if ( function_exists('register_sidebars') )
    register_sidebars(1,array('name'=>'Leftside',
        'before_widget' => '',
        'after_widget' => '<br />',
        'before_title' => '<div class="left2head">',
        'after_title' => '</div>',
    ));
	    register_sidebars(1,array('name'=>'Rightside',
        'before_widget' => '',
        'after_widget' => '<br />',
        'before_title' => '<div class="right2arch">',
        'after_title' => '</div>',
    ));
#################my hits counter addition ##################
function my_hits () {
$file = "counter.txt";
if ( !file_exists($file)){
       touch ($file);
       $handle = fopen ($file, 'r+'); // Let's open for read and write
       $count = 0;
}
else{
       $handle = fopen ($file, 'r+'); // Let's open for read and write
       $count = fread ($handle, filesize ($file));
       settype ($count,"integer");
}
rewind ($handle);
fwrite ($handle, ++$count); // Don't forget to increment the counter
fclose ($handle); // Done 
echo '<br /><p align="center"><b>'.$count.' pageviews</b><br /><span class="counter">logged since July 2008</span></p>';
}
######################contact processor##############
function kirimsurat($aksi)  {
	global $_POST;
	$nom	= $_POST['kunci'];
	$vers	= $_POST['verifikasi'];
	$kunci[901]	= "CINT4";
	$kunci[902]	= "ONGI5";
	$kunci[903]	= "N6OPI";
	$kunci[904]	= "IDR3K";
	$kunci[905]	= "4PPLE";
	$betul	= $kunci[$nom];
if ($aksi=='1') {
	if (empty($_POST['nama']) || empty($_POST['telp']) || empty($_POST['email']) || empty($_POST['pesan']) || empty($_POST['verifikasi'])) {
	echo "<div class=\"textwidget\">
			<p>Sorry, your message can't be sent. Your name, phone number, email, and message, can't be left empty.</p>
			<p><a href=\"javascript:history.back(1)\">Click here to repeat.</a></p>
		</div>";
	} elseif ($betul!=$vers) {
	echo "<div class=\"textwidget\">
			<p>Sorry, your message can't be sent... The verification code entered isn't the same as displayed.</p>
			<p><a href=\"javascript:history.back(1)\">Click here to repeat.</a></p>
		</div>";
	} else {
	$_POST['nama'] = stripslashes(trim($_POST['nama']));
    $_POST['email'] = stripslashes(trim($_POST['email']));
    $_POST['telp'] = stripslashes(trim($_POST['telp']));
    $_POST['pesan'] = stripslashes(trim($_POST['pesan']));

	$recipient	= get_bloginfo('admin_email');
	$ip_addr	= $_SERVER["REMOTE_ADDR"];
	$browser	= $_SERVER['HTTP_USER_AGENT'];
            $nama		= $_POST['nama'];
            $lembaga	= $_POST['lembaga'];
            $telp		= $_POST['telp'];
            $email		= $_POST['email'];
            $judul		= "Pesan dari $nama Melalui ". get_bloginfo('name') ."";
            $msg		= $_POST['pesan'];
                $headers .= "From: ".$nama."<".$email.">\n";
				$headers .= "Reply-To: ".$nama."<".$email.">\n";
				$headers .= "Return-Path: ".$nama."<".$email.">\n";    // these two to set reply address
				$headers .= "Message-ID: <".time()."-".$email.">\n";
				$headers .= "X-Mailer: PHP v".phpversion()."\n";          // These two to help avoid spam-filters
 # Boundry for marking the split & Multitype Headers
				$headers .= "MIME-Version: 1.0\n\n";
				$headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"\n";

                $fullmsg    .= wordwrap($msg, 76, "\n") . "\n\n";
                $fullmsg    .= "\n----------------------------------------------------------------------------\n";
                $fullmsg    .= "Sender info:\n\n";
                $fullmsg    .= "IP: " .$ip_addr. " <http://ws.arin.net/whois/?queryinput=".$ip_addr.">\n";
                $fullmsg    .= "Browser/OS: " . wordwrap($browser, 76, "\n\t    ") . "\n";
                $fullmsg    .= "----------------------------------------------------------------------------\n";
                mail($recipient, $judul, $fullmsg, $headers);
            echo "<div class=\"textwidget\"><p>Thank You.<br />Your message, with these details has been sent<br />
			We would soon reply to your message below.
			</p></div>
			<p>Name:<br />
				<b>$nama</b><br />
			Organization:<br />
				<b>$lembaga</b><br />
			Phone number:<br />
				<b>$telp</b><br />
			Message:<br />
			<blockquote><b>$msg</b></blockquote>
			</p>"; }
	} else { 
		$rd =rand( 901, 905);
		?>
		<form method="post" action="?aksi=1"><input type="hidden" name="kunci" value="<?php print($rd); ?>" /><br />
		<table celpadding="0" cellspacing="2" border="0" id="kirim">
			<tr>
				<td>Name</td>
				<td colspan="2"><input class="comm" type="text" name="nama" /></td>
			</tr><tr>
				<td>Organization</td>
				<td colspan="2"><input class="comm" type="text" name="lembaga" /></td>
			</tr><tr>
				<td>Phone Number</td>
				<td colspan="2"><input class="comm" type="text" name="telp" /></td>
			</tr><tr>
				<td>E-mail Address</td>
				<td colspan="2"><input class="comm" type="text" name="email" /></td>
			</tr><tr>
				<td valign="top">Message for us</td>
				<td colspan="2"><textarea class="comm" name="pesan" rows="7" cols="35"></textarea></td>
			</tr><tr>
				<td>&nbsp;</td>
				<td colspan="2"><small>Insert verification code displayed by the image below. <br />
				Letters used are in capital.</small></td>
			</tr><tr>
				<td>&nbsp;</td>
				<td width="130"><img src="<?php bloginfo('template_url'); ?>/images/<?php print($rd); ?>.png" width="132" height="35" alt="kunci" /></td>
				<td><input class="commv" type="text" name="verifikasi" id="kunci" /><br /><input class="comm" id="submit" type="submit" value="Kirimkan" class="submit" /></td>
			</tr>
		</table>		
		</form>
<?php
	}
}
?>