Location: PHPKode > projects > phprofession job board > phProfession_SA/functions.php
<?
#####################################
#   phprofession   June   2002      #
#   by Aidan Peiser	    	    #
#   Recruitment module for PN.714   #
#   www.galore.co.za	    #
#	.,.,.,,			    #
#	C 'C' C			    #
#	 > * <			    #
#####################################

function fixDate($val)
{
	// Format MySQL Date Values 
	//Pass: $val = date stamp 
	//Return: date stamp in d M Y format
	
	$arr = explode(" ", $val);
	$datearr = explode("-", $arr[0]);
	return date("d M Y", mktime(0, 0, 0, $datearr[1], $datearr[2], $datearr[0]));
}


function phprofession_language($script = 'global')
{
	// Get phprofession language choice
	//Pass: $script name of language file with out the php default is global
	//Return: Nothing it includes the language file
	
	global $ModName, $currentlang;
	
    	if (file_exists("lang/$currentlang/$script.php"))
    	{
        @include "lang/$currentlang/$script.php";
    	} 
    	elseif (file_exists("lang/$language/$script.php")) 
    	{
        @include "lang/$language/$script.php";
    	} 
    	else 
    	{
		$currentlang = "eng";
   	@include "lang/$currentlang/$script.php";
   	}
}


function pagenav($page) 
{
	// pageing function
	//Pass: page name eg:index
	//Return:page listings with next or previous links
	global $limit,$offset,$numpage,$ModuleBaseUrl,$cmd;
	
        echo "<center><TABLE CELLPADDING=0 BORDER=0 CELLSPACING=2 WIDTH=100%><TR><TD ALIGN=RIGHT>";
   	if ($offset>=$limit)
   	{
        	$newoff=$offset-$limit;
        	echo "<A HREF=\"$page.php?cmd=$cmd&offset=$newoff\">"._JOBPREVIOUS."</A></TD>";
   	}
   	else
   	{
     		echo ""._JOBPREVIOUS."";
   	}
   	echo "<TD ALIGN=CENTER> &nbsp; ";
   	for ($i=1;$i<=$numpage;$i++)
   	{
    		if ((($i-1)*$limit)==$offset)
    		{
        		print "$i ";
        	}
        	else
        	{
          		$newoff=($i-1)*$limit;
        		echo "<A HREF=\"$page.php?cmd=$cmd&offset=$newoff\">$i</A> ";
        	}
   	}
   	echo "&nbsp; </TD><TD ALIGN=LEFT>";
   	if ($offset!=$limit*($numpage-1))
   	{
      		$newoff=$offset+$limit;
     		echo "<A HREF=\"$page.php?cmd=$cmd&offset=$newoff\">"._JOBNEXT."</A></TD>";
   	}
   	else
   	{
     		echo ""._JOBNEXT."</TD>";
   	}
   	echo "</TR></TABLE><center>";
}


function isEmailInvalid($val)
{
        // E-Mail Validity Check 
        //Pass: $val = a email eg hide@address.com
        //Return: true if email is valid false if not valid
        	
	$pattern = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/";
	if(preg_match($pattern, $val))
	{
                return false;
	}
	else
	{
		return true;
	}  
}


function listErrors()
{
	// List of errors after validating the form
	//Pass: nothing
	//Return: your error message
	
	global $errorList;
	echo "The following errors were encountered: <br>";
	echo "<ul>";
        for ($x=0; $x<sizeof($errorList); $x++)
        {
               	echo "<li>$errorList[$x]";
        }
	echo "</ul>";
	echo "<a href=javascript:history.back();>Click here</a> to go back to the previous page and correct the errors";
}
		 
function Admin_menu($user_id)
{
	//Pass: $user_id = user name
	//Return: admin menu
	global $ModuleAdminUrl,$ModuleUploadUrl;
	echo"<center><br><br>logged in as $user_id &nbsp;|&nbsp;<a href=\"javascript:history.back()\">"._ADMINMENU1."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=Admin\">"._ADMINMENU2."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=Add\">"._ADMINMENU3."</a>
	&nbsp;|&nbsp;<a href=\"post.php?cmd=Browse\">Browse Your Jobs</a>
	<br><a href=\"admin.php?cmd=BrowseJobs\">Browse All Jobs</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=browseuser\">"._ADMINMENU4."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=DisplayConfig\">"._ADMINMENU13."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=Departments\">"._ADMINMENU11."</a>
	&nbsp;|&nbsp;<a href=\"$ModuleUploadUrl\">"._ADMINMENU6."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=location\">"._ADMINMENU9."</a>
	<br><a href=\"admin.php?cmd=salary\">"._ADMINMENU10."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=Search\">"._ADMINMENU5."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=RecruitingClient\">"._ADMINMENU8."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=ResumeUploads\">"._ADMINMENU14."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=Administrator\">"._ADMINMENU12."</a>
	&nbsp;|&nbsp;<a href=\"admin.php?cmd=Waiting\">Waiting Content</a><br><br></font></center> ";
}

function User_Menu($ModuleBaseUrl)
{
	echo" <center><br><br><a href=\"javascript:history.back()\">"._JOBBOTGOBACK."</a>
	&nbsp;|&nbsp;<a href=index.php?cmd=JobSearch>"._JOBBOTSEARCH."</a>
	&nbsp;|&nbsp;<a href=index.php?cmd=Joblist>"._JOBBOTLISTING."</a>
	&nbsp;|&nbsp;<a href=index.php?cmd=List>"._JOBBOTDEP."</a>
	&nbsp;|&nbsp;<a href=index.php?cmd=Joblist2>"._JOBBOTALL."</a>
	&nbsp;|&nbsp;<a href=upload.php?jcode=1>"._JOBBOTREGISTER."</a>
	&nbsp;|&nbsp;<a href=index.php?cmd=RecruitingClient>"._JOBBOTRECRUITING."</a>
	&nbsp;|&nbsp;<a href=post.php>"._JOBBOTPOST."</a>
	<br><br></center>";
}

function draw_create_login_box($title, $width, $ModuleDirName) 
{
	echo "<table border='0' width='$width'>\n";
	echo "<form action='create_login.php' method='post'>\n";
	echo "<input type='hidden' name='usertype' value='0'>";
	echo "<th colspan='2' bgcolor='#dddddd'><font color='#000000'>$title</font></th>\n";
	echo "<tr><td>Username</td><td><input type='text' name='CreateUserName'></td></tr>\n";
	echo "<tr><td>Password</td><td><input type='password' name='CreatePassword'></td><tr>\n";
	echo "<tr><td>Confirm Password</td><td><input type='password' name='ConfirmCreatePassword'></td></tr>\n";
	echo "<tr><td>Email Address</td><td><input type='text' name='EmailAddress'></td></tr>\n";
	echo "<tr><td>Company</td><td><input type='text' name='Company'></td></tr>\n";
	echo "<tr><td>Contact Number</td><td><input type='text' name='ContactNumber'></td></tr>\n";
	echo "<tr><td colspan='2' align='right'><input type='submit' name='CreateNewLogin' value='Create'></td></tr>\n";
	echo "</form></table>\n";
}

function draw_create_admin_login_box($title, $width, $ModuleDirName) 
{
	echo "<table border='0' width='$width'>\n";
	echo "<form action='create_login.php' method='post'>\n";
	echo "<input type='hidden' name='usertype' value='1'>";
	echo "<th colspan='2' bgcolor='#dddddd'><font color='#000000'>$title</font></th>\n";
	echo "<tr><td>Username</td><td><input type='text' name='CreateUserName'></td></tr>\n";
	echo "<tr><td>Password</td><td><input type='password' name='CreatePassword'></td><tr>\n";
	echo "<tr><td>Confirm Password</td><td><input type='password' name='ConfirmCreatePassword'></td></tr>\n";
	echo "<tr><td>Email Address</td><td><input type='text' name='EmailAddress'></td></tr>\n";
	echo "<tr><td>Company</td><td><input type='text' name='Company'></td></tr>\n";
	echo "<tr><td>Contact Number</td><td><input type='text' name='ContactNumber'></td></tr>\n";
	echo "<tr><td colspan='2' align='right'><input type='submit' name='CreateNewLogin' value='Create'></td></tr>\n";
	echo "</form></table>\n";
}

function draw_login_box ($title, $width, $ModuleDirName) 
{
    echo "<table border='0' width='$width'>\n";
    echo "<form action='authenticate.php' method='post'>\n";
    echo "<th colspan='2' bgcolor='#dddddd'><font color='#000000'>$title</font></th>\n";
    echo "<tr><td>Username</td><td><input type='text' name='UserName'></td></tr>\n";
    echo "<tr><td>Password</td><td><input type='password' name='Password'></td><tr>\n";
    echo "<tr><td colspan='2' align='right'><input type='submit' name='Login' value='Login'></td></tr>\n";
    echo "</form></table>\n";
}

function init_session ($name) 
{
	setcookie ("authok", $name ,time()+36000, "/", '', 0);	
}

function kill_session() 
{
	setcookie ("authok", "",time()-36000, "/", '', 0);
}

function verify_session ($md5) 
{
	$ModName = basename(dirname(__FILE__));
	include("config.php");
	mysql_connect($hostname, $user, $pass) or die("Could not connect");
	mysql_select_db($database) or die("Could not select database");
	$result = mysql_query("SELECT * FROM {$prefix}_jobaccounts WHERE md5='$md5'");
	$row_array = mysql_fetch_array($result);
	if ($row_array[0] != "")
	{
		return $row_array[0];
	}
	else
	{
		return "FALSE";
	}
}
function redirect ($url) 
{
	echo "<SCRIPT LANGUAGE='JavaScript'>";
	echo "document.location.href='$url'";
	echo "</SCRIPT>";
	exit;
}

function OpenTable()
{
	
}
function CloseTable()
{
	
}
?>
Return current item: phprofession job board