<?php

if (preg_match('/funcpass.php/i', $_SERVER['PHP_SELF']))
{ header("location:index.php");
  exit;
  }

function saltpassword($passinput)
{ global $dbConnection;
		/* Dengan salt
		$passArray=str_split($passinput);
		// Tentukan nilai salt, bisa menggunakan nilai dari database untuk salt dinamis
		$injectedSalt="1a2b3c4d5e6f7g8h9i0j";
		$saltArray=str_split($injectedSalt);
		// Buat password baru
		$n=0;
		$newPass="";
		foreach($passArray as $passChunk)
		{ $newPass.=$passChunk.$saltArray[$n];
				$n++;
				}
		$hashpass=md5($newPass);
		*/
		// tanpa salt
		if (!empty($passinput))
		{ $hashpass=md5($passinput);
				}
		else
		{ $hashpass="";
				}
		return $hashpass;
		}

function createnewpassword()
{ global $dbConnection;
		$chars="abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ1023456789";
		srand((double)microtime()*1000000);
		$i=0; 
		$pass="";
		$defaultlength=8;
		while ($i<=$defaultlength) 
		{ $num=rand()%33; 
				$tmp=substr($chars, $num, 1); 
				$pass=$pass . $tmp; 
				$i++; 
				} 
		return $pass; 
		}

?>