Location: PHPKode > projects > MyJobList > MyJobList.v0.1/mjl-includes/functions.inc.php
<?php

function FUNCT_EMPLOYEE_RECOVER_PW($mmail){
	global $theme;
	
	if (isValidEmail($mmail)){
		$result = mysql_query('SELECT EMAIL FROM users WHERE EMAIL = "'.$mmail.'" LIMIT 1');
		$cnt = mysql_num_rows($result);
		if($cnt > 0){
			$SSID = new r_id;
			$temp_key = $SSID->Getcnt();
			if (FUNCT_LOST_PW_MAIL($temp_key,$mmail)){
				$result = mysql_query('UPDATE users SET TEMP = "'.$temp_key.'" WHERE EMAIL = "'.$mmail.'" LIMIT 1');
				if(mysql_errno()){
					$rdata = '<div class="errorbox">Error with password recovery please contact support.</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
				}else{
					$rdata = '<div style="width:95%;padding:25px;"><div style="margin:auto;width:450px;padding:15px;border:1px solid #000000">An email has been sent to the email address provided please follow the instructions to continue with your password recovery.</div></div>';
				}
			}else{
				$rdata = '<div class="errorbox">Oops, there was a problem.  Please contact support.</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
			}
		}else{
			$rdata = '<div class="errorbox">The email address does not exist or is invalid</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
		}
	}else{
		$rdata = '<div class="errorbox">The email address was not valid</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
	}
	return $rdata;
}

function FUNCT_EMPLOYER_RECOVER_PW($mmail){
	global $theme;
	
	if (isValidEmail($mmail)){
		$result = mysql_query('SELECT CONTACTEMAIL FROM companies WHERE CONTACTEMAIL = "'.$mmail.'" LIMIT 1');
		$cnt = mysql_num_rows($result);
		if($cnt > 0){
			$SSID = new r_id;
			$temp_key = $SSID->Getcnt();
			if (FUNCT_LOST_PW_MAIL('empl'.$temp_key, $mmail)){
				$result = mysql_query('UPDATE companies SET TEMP = "'.$temp_key.'" WHERE EMAIL = "'.$mmail.'" LIMIT 1');
				if(mysql_errno()){
					$rdata = '<div class="errorbox">Error with password recovery please contact support.</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
				}else{
					$rdata = '<div style="width:95%;padding:25px;"><div style="margin:auto;width:450px;padding:15px;border:1px solid #000000">An email has been sent to the email address provided please follow the instructions to continue with your password recovery.</div></div>';
				}
			}else{
				$rdata = '<div class="errorbox">Oops, there was a problem.  Please contact support.</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
			}
		}else{
			$rdata = '<div class="errorbox">The email address does not exist or is invalid</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
		}		
	}else{
		$rdata = '<div class="errorbox">The email address was not valid</div>'.file_get_contents('mjl-themes/'.$theme.'/change_pw_form.theme.html');
	}
	
	return $rdata;
}

function isValidEmail($email){
	return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}

function FUNCT_LOST_PW_MAIL($tmpkey, $rcpt){

	global $mjlmail;
	global $org;
	global $regurl;;
	
	$headers = "From: ".$mjlmail."\r\n"; // From address
	$headers .= "Reply-To: ".$mjlmail."\r\n"; // Reply-to address
	$headers .= "Organization: ".$org."\r\n"; // Organisation
	$headers .= 'MIME-Version: 1.0' . "\r\n";
	$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; // Type
	
	
	
	$keyloc = '<a href="http://'.$regurl.'register.php?recover='.$tmpkey.'">http://'.$regurl.'index.php?recover='.$tmpkey.'</a>';
	
	$subj = $org .' Password Recovery';
	$regmsg = 'To have your new password emailed to you please click the link below. If you did not request a new password then delete this email.  Please understand that your account is safe and that no changes have been made.<br /><br />'.$keyloc;

	if(ereg("^.+@.+\\..+$", $rcpt)) {
		if(mail($rcpt, $subj, $regmsg, $headers)){
			return TRUE;
		}else{
			return FALSE;
		}
	}else{
		return FALSE;
	}
}

function FUNCT_JOB_DATA_LIST($numperpage,$bpage, $ecats='%'){  //This is the list shown on the first page.
	global $theme;
	
// ==========================================================	
// ==========================================================	
// ==========================================================		
	$result 	= mysql_query('SELECT * FROM jobs WHERE `ISENABLED` = 1 AND `CATID` LIKE "'.$ecats.'" ORDER BY `DATEPOSTED` ASC');
	$num 		= mysql_num_rows($result);
	
	$pages = intval($num/$numperpage);
	if ($num%$numperpage) {
		$pages++;
	} 
	$current = ($bpage/$numperpage) + 1;
	if (($pages < 1) || ($pages == 0)) {
		$total = 1;
	} else {
		$total = $pages;
	}
	$first = $bpage + 1;
	if (!((($bpage + $numperpage) / $numperpage) >= $pages) && $pages != 1) {
		$last = $bpage + $numperpage;
	} else {
		$last = $num;
	}
// ==========================================================	
// ==========================================================	
// ==========================================================	
	$result 	= mysql_query('SELECT * FROM jobs WHERE `ISENABLED` = 1 AND `CATID` LIKE "'.$ecats.'" ORDER BY `DATEPOSTED` DESC LIMIT '.$bpage.', '.$numperpage);
	
	$rdata 		= file_get_contents('mjl-themes/'.$theme.'/index_joblist_header.theme.html');
	$cnt = mysql_num_rows($result);
	if ($cnt > 0){
		$rdata		.= '<table border="0" cellspacing="0" cellpadding="0" class="joblist">
			<tr>
				<td class="jlh1">Job Title</td><td class="jlh2">Company</td><td class="jlh3">Posted</td><td class="jlh4">Location</td>
			</tr>';
		$jlistentry = '';
		
		while ($row = mysql_fetch_array($result)){
			if ($jlistentry == 'jlistentry1'){
				$jlistentry = 'jlistentry2';
			}else{
				$jlistentry = 'jlistentry1';
			}
			$cnamer = mysql_query('SELECT `COMPANYNAME` FROM companies WHERE CID = '.$row['CID'].' LIMIT 1'	);
			$cname = mysql_fetch_array($cnamer);
		
			$rdata		.= '<tr><td class="'.$jlistentry.'"><a href="?loc=view&jid='.$row['JID'].'">'.$row['JOBTITLE'].'</a></td><td class="'.$jlistentry.'"><a href="?loc=profile&eid='.$row['CID'].'">'.$cname['COMPANYNAME'].'</a></td><td align="center" class="'.$jlistentry.'">'.$row['DATEPOSTED'].'</td><td align="center" class="'.$jlistentry.'">'.$row['JOBLOCATION'].'</td></tr>';
		}
		$rdata		.= '</table>';			
// ==========================================================	
// ==========================================================	
// ==========================================================	
		$rdata		.= '<table border="0" cellspacing="0" cellpadding="0" class="joblistpg">
			<tr>
				<td>';
		if ($bpage != 0) { // Don't show back link if current page is first page.
			$back_page = $bpage - $numperpage;
			$rdata		.= '<a href="?page='.$back_page.'&num_per_page='.$numperpage.'">back</a>&nbsp;';
		}
		for ($i=1; $i <= $pages; $i++){
 			$ppage = $numperpage*($i - 1);
 			if ($ppage == $bpage){
				if ($pages > 1){
	 				$rdata		.= $i.'&nbsp;';
				}
			}else{
 				$rdata		.= '<a href="?page='.$ppage.'&num_per_page='.$numperpage.'">'.$i.'</a>&nbsp;';
			}
		}

		if (!((($bpage+$numperpage) / $numperpage) >= $pages) && $pages != 1) {
			$next_page = $bpage + $numperpage;
			$rdata		.= '<a href="?page='.$next_page.'&num_per_page='.$numperpage.'">next</a>';
		}
		$rdata		.= '</td></tr></table>';
// ==========================================================
// ==========================================================	
// ==========================================================					
	}else{
		$rdata .= 'No items were found that matched your search criteria.';
	}
	$rdata 		.= file_get_contents('mjl-themes/'.$theme.'/index_joblist_footer.theme.html');
return $rdata;
}

function FUNCT_JOB_DATA($jid){  //this is the job shown when someone clicks on the job title.
	global $theme;
	
	$rdata  = file_get_contents('mjl-themes/'.$theme.'/view_job_body.theme.html');
	
	$result = mysql_query('SELECT * FROM jobs WHERE `JID` = '.$jid.' AND `ISENABLED` = 1 LIMIT 1');

	while ($row = mysql_fetch_array($result)){
		$company 		= $row['CID'];
		
		$cdata = mysql_query('SELECT* FROM companies WHERE CID = '.$company.' LIMIT 1'); 
		$crow = mysql_fetch_array($cdata);
		$cinfo = '<span class="proflnk"><a href="?loc=profile&eid='.$row['CID'].'">View Comapany Profile</a></span><p></p>'.$crow['COMPANYNAME'].'<br />'.$crow['MAILADDRESS1'].'<br />'.$crow['CITY'].', '.$crow['STATE'].' '.$crow['ZIP'];
		$cwebsite = '';
		if(!empty($crow['WEBSITE'])){
			$cwebsite = '<a href="'.$crow['WEBSITE'].'" target="_blank">'.$crow['WEBSITE'].'</a>';
		}
		
		
		$contact = '
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td align="left" width="50%">
						'.$crow['CONTACT'].'
						<br />'.$crow['CONTACTTITLE'].'
						<br />'.$crow['MAILADDRESS1'].'
						<br />'.$crow['CITY'].', '.$crow['STATE'].'
					</td>
					<td align="left" width="50%">
						Phone: '.$crow['PHONE'].'<br />
						Email: '.$crow['CONTACTEMAIL'].'
					</td>
				</tr>
			</table>';
		$benefits='<p></p>';
		$dateposted 	= @date("M j, Y", mktime($row['DATEPOSTED']));
		$hottoapply 	= unserialize(stripslashes($row['HOWTOAPPLY']));
		$apply='';
		$application = '';
		if (count($hottoapply[0]) > 0){
			for ($i=1;$i <= count($hottoapply[0]);$i++){
				if( $hottoapply[0][$i-1] == 'online'){
					$application .= '<br /><a href="?loc=view&act=app&jid='.$jid.'" border="0" title="Apply Online"> <img src="mjl-themes/'.$theme.'/applyonline.jpg" alt="Apply Online"></a>';
				}else{
					$application .= 'by '. $hottoapply[0][$i-1].'&nbsp;&nbsp;';
				}
			}
			$apply = '<br /><br /><br /><u>Apply via</u>:<br />'.$application;
		}else{
			$apply = '<br /><br /><br /><u>Apply via</u>:<br />by mail';
		}
		
		$rdata = str_replace('%HOWTOAPPLY%',$apply,$rdata);
		$prata = '<div class="joptions"><a href="?loc=jview&id='.$row['JID'].'" target="_blank"><span id="print1">Print</span></a></div>';
		$rdata = str_replace('%TITLE%',$prata.$row['JOBTITLE'],$rdata);
		$rdata = str_replace('%LOCATION%',$row['JOBLOCATION'],$rdata);
		if (!empty($row['JOBDESCRIPTION'])){
			$description = '<h3>Job Description</h3>'.nl2br($row['JOBDESCRIPTION']);
		}
		$rdata = str_replace('%JOBDESCRIPTION%',$description,$rdata);
		$experience ='';
		if(!empty($row['JOBREQUIREMENTS'])){
			$experience = '<h3>Experience</h3>'.nl2br($row['JOBREQUIREMENTS']);
		}
		$rdata = str_replace('%JOBREQUIREMENTS%',$experience,$rdata);
		if(!empty($row['EDREQUIREMENTS'])){
			$education = '<h3>Educational Requirements</h3>'.nl2br($row['EDREQUIREMENTS']);
		}
		$rdata = str_replace('%EDREQUIREMENTS%',$education,$rdata);
		$rdata = str_replace('%CATEGORY%',$row['CATID'],$rdata);
		if (!empty($row['BENEFITS'])){
			$benefits = '<h3>Benefits</h3>'.nl2br($row['BENEFITS']);
		}
		
		$rdata = str_replace('%BENEFITS%',$benefits,$rdata);
		$rdata = str_replace('%POSTEDON%',$dateposted,$rdata);
		$rdata = str_replace('%DURATION%',$row['JOBDURATION'],$rdata);
		$rdata = str_replace('%JOBTYPE%',$row['JOBTYPE'],$rdata);
		$rdata = str_replace('%WAGETYPE%',$row['WAGETYPE'],$rdata);
		$rdata = str_replace('%COMPANY%',$cinfo,$rdata);
		$rdata = str_replace('%CONTACT%',$contact,$rdata);
		$rdata = str_replace('%COMPANYWEBSITE%',$cwebsite,$rdata);

	}

	return $rdata;
}

function SOW_CO_PROFILE($eeid){
	global $theme;
	
	$result = mysql_query('SELECT * FROM companies WHERE CID = '.$eeid.' LIMIT 1');
	$row = mysql_fetch_array($result);

	$coname = $row['COMPANYNAME'];
	
	if (!empty($row['MAILADDRESS2'])) {
		$completeaddress = $row['COMPANYNAME'].'<br />'.$row['MAILADDRESS1'].'<br />'.$row['MAILADDRESS2'].'<br />'.$row['CITY'].', '.$row['STATE'].' '.$row['ZIP'];
	}else{
		$completeaddress = $row['COMPANYNAME'].'<br />'.$row['MAILADDRESS1'].'<br />'.$row['CITY'].', '.$row['STATE'].' '.$row['ZIP'];
	}
	
	if(!empty($row['WEBSITE'])){
		$web = '<a href="'.$row['WEBSITE'].'" target="_blank">'.$row['WEBSITE'].'</a>';
	}else{
		$web = '';
	}
	
	$completeaddress = $completeaddress.'<br /><br /><u>Contact</u>: <br />'.$row['CONTACT'].'<br />'.$row['CONTACTTITLE'];
	$contactinfor = 'Website: '.$web.'<br />Phone: '.$row['PHONE'].'<br />Fax: '.$row['FAX'].'<br />Email: '.$row['CONTACTEMAIL'];
	
	if (!empty($row['ABOUT'])){
		$about = '<h3>About</h3>'.$row['ABOUT'];
	}else{
		$about = '';
	}
	
	$rdata  = file_get_contents('mjl-themes/'.$theme.'/view_co_profile.theme.html');
	$rdata = str_replace('%COMPANYNAME%',$coname,$rdata);
	$rdata = str_replace('%CONTACT1%',$completeaddress,$rdata);
	$rdata = str_replace('%CONTACT2%',$contactinfor,$rdata);
	$rdata = str_replace('%ABOUT%',$about,$rdata);

	return $rdata;
}

function FUNCT_SHOW_COVER($cid){
	global $url;
	
	$result = mysql_query('SELECT * FROM covers WHERE ID = '.$cid.' LIMIT 1');
	$row = mysql_fetch_array($result);
	$searchable = $row['SEARCHABLE'];

	if($_SESSION['cid'] == $row['UID']){
		$searchable = 'CHECKED';
	}
	if ($searchable != 'CHECKED') {
		$msg = 'Error: Does not exist';
		echo FUNCT_HDR($msg).'The cover letter you are looking for does not exist or is not accessible'.FUNCT_FTR();
	}else{
		if (($_SESSION['cid'] == $row['UID']) || ($_SESSION['acctype'] == 'employer')){
			echo FUNCT_HDR($row['COVERTITLE']).'<div style="border:2px solid #000000;margin:25px;padding:20px;">';
			$result = mysql_query('SELECT * FROM users WHERE UID = '.$row['UID'].' LIMIT 1');
			$cnt = mysql_num_rows($result);
			if ($cnt > 0){
				$urow = mysql_fetch_array($result);
				echo '<h3>Contact Information</h3>';
				echo '<strong>Name</strong> : '.$urow['FIRSTNAME']. ' ' . $urow['LASTNAME'].'<br />';
				echo '<strong>Email</strong> : ' . $urow['EMAIL'] . '<br />';
				echo '<strong>Phone</strong> : ' . $urow['PHONE'] . '<br />';
				echo '<strong>Address</strong> : <br />' .
					$urow['STREETADDRESS1'].'<br />';
					if (strlen($urow['STREETADDRESS2']) > 2){
						echo $urow['STREETADDRESS2'].'<br />';
					}
					echo $urow['CITY'].', '.$urow['STATE'].' '.$urow['ZIP'].'<br /><br /><hr width="50%">';
			}
			echo  nl2br($row['COVERBODY']).'</div>'.FUNCT_FTR();
			exit();
		}
	}
}

function FUNCT_SHOW_RESUME($rid){
	global $url;
	
	$result = mysql_query('SELECT * FROM resumes WHERE ID = '.$rid.' LIMIT 1');
	$row = mysql_fetch_array($result);
	$searchable = $row['SEARCHABLE'];

	if($_SESSION['cid'] == $row['UID']){
		$searchable = 'CHECKED';
	}
	
	if ($searchable != 'CHECKED') {
		$msg = 'Error: Does not exist';
		echo FUNCT_HDR($msg).'The resume you are looking for does not exist or is not accessible'.FUNCT_FTR();
	}else{
		if (($_SESSION['cid'] == $row['UID']) || ($_SESSION['acctype'] == 'employer')){
			echo FUNCT_HDR($row['RESUMETITLE']).'<div style="border:2px solid #000000;margin:25px;padding:20px;">';
			$result = mysql_query('SELECT * FROM users WHERE UID = '.$row['UID'].' LIMIT 1');
			$cnt = mysql_num_rows($result);
			if ($cnt > 0){
				$urow = mysql_fetch_array($result);
				echo '<h3>Contact Information</h3>';
				echo '<strong>Name</strong> : '.$urow['FIRSTNAME']. ' ' . $urow['LASTNAME'].'<br />';
				echo '<strong>Email</strong> : ' . $urow['EMAIL'] . '<br />';
				echo '<strong>Phone</strong> : ' . $urow['PHONE'] . '<br />';
				echo '<strong>Address</strong> : <br />' .
					$urow['STREETADDRESS1'].'<br />';
					if (strlen($urow['STREETADDRESS2']) > 2){
						echo $urow['STREETADDRESS2'].'<br />';
					}
					echo $urow['CITY'].', '.$urow['STATE'].' '.$urow['ZIP'].'<br /><br /><hr width="50%">';
			}
			echo nl2br($row['RESUMEBODY']).'</div>'.FUNCT_FTR();
			exit();
		}
	}
}

function FUNCT_SHOW_JOB($jid){
	$result = mysql_query('SELECT * FROM jobs WHERE `JID` = '.$jid.' AND `ISENABLED` = 1 LIMIT 1');
	$cnt = mysql_num_rows($result);
	if($cnt > 0){
		$row = mysql_fetch_array($result);
	}
	
	global $theme;
	
	$rdata  = file_get_contents('mjl-themes/'.$theme.'/view_job_body.theme.html');
	$result = mysql_query('SELECT * FROM jobs WHERE `JID` = '.$jid.' AND `ISENABLED` = 1 LIMIT 1');
	$cnt = mysql_num_rows($result);
	if($cnt > 0){
		$row = mysql_fetch_array($result);
		echo FUNCT_HDR($row['JOBTITLE']);
		$company 		= $row['CID'];
		
		$cdata = mysql_query('SELECT * FROM companies WHERE CID = '.$company.' LIMIT 1'); 
		$crow = mysql_fetch_array($cdata);
		$cinfo = '<span class="proflnk"><a href="?loc=profile&eid='.$row['CID'].'">View Comapany Profile</a></span><p></p>'.$crow['COMPANYNAME'].'<br />'.$crow['MAILADDRESS1'].'<br />'.$crow['CITY'].', '.$crow['STATE'].' '.$crow['ZIP'];
		$cwebsite = '';
		if(!empty($crow['WEBSITE'])){
			$cwebsite = '<a href="'.$crow['WEBSITE'].'" target="_blank">'.$crow['WEBSITE'].'</a>';
		}
			
		$contact = '
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td align="left" width="50%">
						'.$crow['CONTACT'].'
						<br />'.$crow['CONTACTTITLE'].'
						<br />'.$crow['MAILADDRESS1'].'
						<br />'.$crow['CITY'].', '.$crow['STATE'].'
					</td>
					<td align="left" width="50%">
						Phone: '.$crow['PHONE'].'<br />
						Email: '.$crow['CONTACTEMAIL'].'
					</td>
				</tr>
			</table>';
		$benefits='<p></p>';
		$dateposted 	= @date("M j, Y",mktime($row['DATEPOSTED']));
		$hottoapply 	= unserialize(stripslashes($row['HOWTOAPPLY']));
		$apply='';
		$application = '';
		
		if (count($hottoapply[0]) > 0){
			for ($i=1;$i <= count($hottoapply[0]);$i++){
				if( $hottoapply[0][$i-1] == 'online'){
					$application .= '<br /><a href="?loc=view&act=app&jid='.$jid.'" border="0" title="Apply Online"> <img src="mjl-themes/'.$theme.'/applyonline.jpg" alt="Apply Online"></a>';
				}else{
					$application .= 'by '. $hottoapply[0][$i-1].'&nbsp;&nbsp;';
				}
			}
			$apply = '<br /><br /><br /><u>Apply via</u>:<br />'.$application;
		}else{
			$apply = '<br /><br /><br /><u>Apply via</u>:<br />by mail';
		}
	
		$rdata = str_replace('%HOWTOAPPLY%',$apply,$rdata);
		$rdata = str_replace('%TITLE%',$row['JOBTITLE'],$rdata);
		$rdata = str_replace('%LOCATION%',$row['JOBLOCATION'],$rdata);
		if (!empty($row['JOBDESCRIPTION'])){
			$description = '<h3>Job Description</h3>'.nl2br($row['JOBDESCRIPTION']);
		}
		$rdata = str_replace('%JOBDESCRIPTION%',$description,$rdata);
		$experience = '';
		if(!empty($row['JOBREQUIREMENTS'])){
			$experience = '<h3>Experience</h3>'.nl2br($row['JOBREQUIREMENTS']);
		}
		$rdata = str_replace('%JOBREQUIREMENTS%',$experience,$rdata);
		$education = '';
		if(!empty($row['EDREQUIREMENTS'])){
			$education = '<h3>Educational Requirements</h3>'.nl2br($row['EDREQUIREMENTS']);
		}
		$rdata = str_replace('%EDREQUIREMENTS%',$education,$rdata);
		$rdata = str_replace('%CATEGORY%',$row['CATID'],$rdata);
		$benefits = '';
		if (!empty($row['BENEFITS'])){
			$benefits = '<h3>Benefits</h3>'.nl2br($row['BENEFITS']);
		}
		$rdata = str_replace('%BENEFITS%',$benefits,$rdata);
		$rdata = str_replace('%POSTEDON%',$dateposted,$rdata);
		$rdata = str_replace('%DURATION%',$row['JOBDURATION'],$rdata);
		$rdata = str_replace('%JOBTYPE%',$row['JOBTYPE'],$rdata);
		$rdata = str_replace('%WAGETYPE%',$row['WAGETYPE'],$rdata);
		$rdata = str_replace('%COMPANY%',$cinfo,$rdata);
		$rdata = str_replace('%CONTACT%',$contact,$rdata);
		$rdata = str_replace('%COMPANYWEBSITE%',$cwebsite,$rdata);
	
		echo '<div style="margin:15px;padding:10px;border:2px solid #000000">'.$rdata.'</div>'.FUNCT_FTR();
		exit();
	}
}

function FUNCT_HDR($msgtitle){
	$retval = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>'.$msgtitle.'</title>
</head>

<body>';
	
	return $retval;
}
function FUNCT_FTR(){
	$retval = '</body>
</html>';
	return $retval;
}
function BASIC_SEARCH($searchstuff,$numperpage,$bpage){
	global $theme;
	
	$search = base64_encode($searchstuff);
	
	if(!empty($searchstuff) && isset($searchstuff)){
		if(preg_match("/[A-Z  | a-z | 0-9]+/", $searchstuff)){  
			$rdata 		= file_get_contents('mjl-themes/'.$theme.'/index_joblist_header.theme.html');
			$searchstuff = mysql_real_escape_string($searchstuff);
			
			$kt=split(",",$searchstuff);
			$sql = '';
			while(list($key,$val)=each($kt)){
				if($val<>" " and strlen($val) > 0){
					$sql .= "CATID LIKE '%" . trim($val) . "%' OR JOBTITLE LIKE '%" . trim($val)  ."%' OR JOBLOCATION LIKE '%" .  trim($val) . "%' OR JOBDESCRIPTION LIKE '%" .  trim($val) . "%' OR JOBREQUIREMENTS LIKE '%" .  trim($val) . "%' OR EDREQUIREMENTS LIKE '%" .  trim($val) . "%' OR BENEFITS LIKE '%" .  trim($val) . "%' OR DATEPOSTED LIKE '%" .  trim($val) . "%' OR JOBDURATION LIKE '%" .  trim($val) . "%' OR JOBTYPE LIKE '%" .  trim($val) . "%' OR WAGETYPE LIKE '%" .  trim($val) . "%' or ";
				}
			}
			$sql=substr($sql,0,(strlen($sql)-3));
			
			$query = "SELECT * FROM jobs WHERE (" . $sql . ") AND `ISENABLED` = 1";
// ==========================================================	
// ==========================================================	
// ==========================================================		
	$result 	= mysql_query($query.' ORDER BY `DATEPOSTED` ASC');
	$num 		= mysql_num_rows($result);
	
	$pages = intval($num/$numperpage);
	if ($num%$numperpage) {
		$pages++;
	} 
	$current = ($bpage/$numperpage) + 1;
	if (($pages < 1) || ($pages == 0)) {
		$total = 1;
	} else {
		$total = $pages;
	}
	$first = $bpage + 1;
	if (!((($bpage + $numperpage) / $numperpage) >= $pages) && $pages != 1) {
		$last = $bpage + $numperpage;
	} else {
		$last = $num;
	}
// ==========================================================	
// ==========================================================	
// ==========================================================	
			//$result = mysql_query($query);
			//$cnt = mysql_num_rows($result);
			
			if ($num == 0){
				$rdata 		.= '<span class="errmsg"><p>No items were found that matched your search criteria</p></span>';
			}else{
				$result 	= mysql_query($query.' ORDER BY `DATEPOSTED` DESC LIMIT '.$bpage.', '.$numperpage);

				$rdata		.= '<table border="0" cellspacing="0" cellpadding="0" class="joblist">
					<tr>
						<td class="jlh1">Job Title</td><td class="jlh2">Company</td><td class="jlh3">Posted</td><td class="jlh4">Location</td>
					</tr>';
				$jlistentry = '';
				while($row = mysql_fetch_array($result)){
					if ($jlistentry == 'jlistentry1'){
						$jlistentry = 'jlistentry2';
					}else{
						$jlistentry = 'jlistentry1';
					}
					$cnamer = mysql_query('SELECT `COMPANYNAME` FROM companies WHERE CID = '.$row['CID'].' LIMIT 1'	);
					$cname = mysql_fetch_array($cnamer);
		
					$rdata		.= '<tr><td class="'.$jlistentry.'"><a href="index.php?loc=view&jid='.$row['JID'].'">'.$row['JOBTITLE'].'</a></td><td class="'.$jlistentry.'"><a href="index.php?loc=profile&eid='.$row['CID'].'">'.$cname['COMPANYNAME'].'</a></td><td align="center" class="'.$jlistentry.'">'.$row['DATEPOSTED'].'</td><td align="center" class="'.$jlistentry.'">'.$row['JOBLOCATION'].'</td></tr>';
				}
				$rdata		.= '</table>';
// ==========================================================	
// ==========================================================	
// ==========================================================	
	$rdata		.= '<table border="0" cellspacing="0" cellpadding="0" class="joblistpg">
			<tr>
				<td>';
	if ($bpage != 0) { // Don't show back link if current page is first page.
		$back_page = $bpage - $numperpage;
		$rdata		.= '<a href="?search='.$search.'&page='.$back_page.'&num_per_page='.$numperpage.'">back</a>&nbsp;';
	}
	for ($i=1; $i <= $pages; $i++){
 		$ppage = $numperpage*($i - 1);
 		if ($ppage == $bpage){
			if ($pages > 1){
	 			$rdata		.= $i.'&nbsp;';
			}
		}else{
 			$rdata		.= '<a href="?search='.$search.'&page='.$ppage.'&num_per_page='.$numperpage.'">'.$i.'</a>&nbsp;';
		}
	}

	if (!((($bpage+$numperpage) / $numperpage) >= $pages) && $pages != 1) {
		$next_page = $bpage + $numperpage;
		$rdata		.= '<a href="?search='.$search.'&page='.$next_page.'&num_per_page='.$numperpage.'">next</a>';
	}
	$rdata		.= '</td></tr></table>';
// ==========================================================
// ==========================================================	
// ==========================================================
			}
			$rdata 		.= file_get_contents('mjl-themes/'.$theme.'/index_joblist_footer.theme.html');
		}
	}else{ 
		 $rdata .=  '<span class="errmsg"><p>Please enter a search query</p></span>'; 
	} 

	return $rdata;
}

function SEARCH_FORM(){
	global $theme;
	$rdata 	= file_get_contents('mjl-themes/'.$theme.'/search_box.theme.html');
	return $rdata;
}

function FUNCT_EMPLOYEE_SEARCH($searchstuff,$numperpage,$bpage){
	global $theme;
	
	$search = base64_encode($searchstuff);

	if(!empty($searchstuff) && isset($searchstuff)){
		if(preg_match("/[A-Z  | a-z | 0-9]+/", $searchstuff)){  
			$rdata	= file_get_contents('mjl-themes/'.$theme.'/company_area_header.theme.html');
			$rdata 		.= file_get_contents('mjl-themes/'.$theme.'/employee_search_box.theme.html');
			$searchstuff = mysql_real_escape_string($searchstuff);
			
			$kt=split(",",$searchstuff);
			$sql = '';
			while(list($key,$val)=each($kt)){
				if($val<>" " and strlen($val) > 0){
					$sql .= "covers.COVERTITLE LIKE '%" . trim($val) . "%' OR covers.COVERBODY LIKE '%" . trim($val)  ."%' OR resumes.RESUMETITLE LIKE '%" . trim($val) . "%' OR resumes.RESUMEBODY LIKE '%" . trim($val)  ."%' OR users.CITY LIKE '%" .  trim($val) . "%' OR users.STATE LIKE '%" .  trim($val) . "%' OR users.ZIP LIKE '%" .  trim($val) . "%' or ";
				}
			}
			$sql=substr($sql,0,(strlen($sql)-3));
			
			$query = "SELECT covers.SEARCHABLE as cSEARCH, covers.COVERTITLE, covers.COVERBODY,resumes.SEARCHABLE as rSEARCH,resumes.ID as RID,covers.ID as CID,resumes.RESUMETITLE, resumes.RESUMEBODY, users.FIRSTNAME, users.LASTNAME, users.CITY, users.STATE, users.ZIP FROM users, resumes, covers WHERE (" . $sql . ") AND covers.UID = users.UID AND resumes.UID = users.UID AND (resumes.SEARCHABLE = 'CHECKED' OR covers.SEARCHABLE = 'CHECKED')";
// ==========================================================	
// ==========================================================	
// ==========================================================	
	$result 	= mysql_query($query.' ORDER BY `LASTNAME` ASC');
	$num 		= mysql_num_rows($result);
	
	$pages = intval($num/$numperpage);
	if ($num%$numperpage) {
		$pages++;
	} 
	$current = ($bpage/$numperpage) + 1;
	if (($pages < 1) || ($pages == 0)) {
		$total = 1;
	} else {
		$total = $pages;
	}
	$first = $bpage + 1;
	if (!((($bpage + $numperpage) / $numperpage) >= $pages) && $pages != 1) {
		$last = $bpage + $numperpage;
	} else {
		$last = $num;
	}
// ==========================================================	
// ==========================================================	
// ==========================================================	
			//$result = mysql_query($query);
			//$cnt = mysql_num_rows($result);
			
			if ($num == 0){
				$rdata 		.= '<span class="errmsg"><p>No items were found that matched your search criteria</p></span>';
			}else{
				$result 	= mysql_query($query.' ORDER BY `LASTNAME` DESC LIMIT '.$bpage.', '.$numperpage);

				$rdata		.= '<table border="0" cellspacing="0" cellpadding="0" class="joblist">
					<tr>
						<td class="jlh1">Name</td><td class="jlh2">Cover Title</td><td class="jlh3">Resume Title</td><td class="jlh4">Location</td>
					</tr>';
				$elistentry = '';
				while($row = mysql_fetch_array($result)){
					if ($elistentry == 'elistentry1'){
						$elistentry = 'elistentry2';
					}else{
						$elistentry = 'elistentry1';
					}
					
					if ($row['cSEARCH'] == 'CHECKED'){
						$cover = '<a href="index.php?loc=cview&id='.$row['CID'].'" target="_blank">'.$row['COVERTITLE'].'</a>';
					}else{
						$cover = '';
					}
					if ($row['rSEARCH'] == 'CHECKED'){
						$resume = '<a href="index.php?loc=rview&id='.$row['RID'].'" target="_blank">'.$row['RESUMETITLE'].'</a>';
					}else{
						$resume = '';
					}
					if (($row['rSEARCH'] != 'CHECKED') && ($row['cSEARCH'] != 'CHECKED')) {
						//do nothing
					}else{
						$rdata		.= '<tr><td class="'.$elistentry.'">'.$row['FIRSTNAME']. ' ' . $row['LASTNAME'].'</td><td class="'.$elistentry.'">'.$cover.'</td><td align="center" class="'.$elistentry.'">'.$resume.'</td><td align="center" class="'.$elistentry.'">'.$row['CITY'].', '. $row['STATE'] .'</td></tr>';
					}
				}
				$rdata		.= '</table>';
// ==========================================================	
// ==========================================================	
// ==========================================================	
	$rdata		.= '<table border="0" cellspacing="0" cellpadding="0" class="joblistpg">
			<tr>
				<td>';
	if ($bpage != 0) { // Don't show back link if current page is first page.
		$back_page = $bpage - $numperpage;
		$rdata		.= '<a href="?search='.$search.'&page='.$back_page.'&num_per_page='.$numperpage.'">back</a>&nbsp;';
	}
	for ($i=1; $i <= $pages; $i++){
 		$ppage = $numperpage*($i - 1);
 		if ($ppage == $bpage){
			if ($pages > 1){
	 			$rdata		.= $i.'&nbsp;';
			}
		}else{
 			$rdata		.= '<a href="?search='.$search.'&page='.$ppage.'&num_per_page='.$numperpage.'">'.$i.'</a>&nbsp;';
		}
	}

	if (!((($bpage+$numperpage) / $numperpage) >= $pages) && $pages != 1) {
		$next_page = $bpage + $numperpage;
		$rdata		.= '<a href="?search='.$search.'&page='.$next_page.'&num_per_page='.$numperpage.'">next</a>';
	}
	$rdata		.= '</td></tr></table>';
// ==========================================================
// ==========================================================	
// ==========================================================
			}
			//$rdata 		.= file_get_contents('mjl-themes/'.$theme.'/index_joblist_footer.theme.html');
			$rdata	.= file_get_contents('mjl-themes/'.$theme.'/company_area_footer.theme.html');
		}
	}else{ 
		 $rdata .=  '<span class="errmsg"><p>Please enter a search query</p></span>'; 
	} 

	return $rdata;
}

function FUNCT_EMPLOYEE_SEARCH_FORM(){
	global $theme;
	$rdata	= file_get_contents('mjl-themes/'.$theme.'/company_area_header.theme.html');
	$rdata	.= file_get_contents('mjl-themes/'.$theme.'/employee_search_box.theme.html');
	$rdata	.= file_get_contents('mjl-themes/'.$theme.'/company_area_footer.theme.html');
	return $rdata;
}

class r_id{
     var $mid;
     var $cnt = 1;

     function Getid(){
          $rID = md5(mt_rand(1, 2048));
          $id = md5($rID . microtime());
          return $id;
     }
     function Getcnt(){
          while ($this->cnt > 0){
               $this->mid = $this->Getid();
               $result = mysql_query("SELECT users.TEMP, companies.TEMP FROM users, companies  WHERE users.TEMP = '" . $this->mid . "' OR companies.TEMP = '" . $this->mid . "' LIMIT 1");
               $this->cnt = mysql_num_rows($result);
          }
          return $this->mid;
     }
}

function SHOW_EMAIL_FORM($jid){
	global $theme;
	
	$result = mysql_query('SELECT * FROM jobs WHERE JID = '.$jid.' LIMIT 1') or die(mysql_errno().', '.mysql_error());
	$row = mysql_fetch_array($result);
	$jtitle	= $row['JOBTITLE'];
	$cid 	= $row['CID'];
	
	$retval = file_get_contents('mjl-themes/'.$theme.'/apply_form_header.theme.html');
	$result = mysql_query('SELECT * FROM companies WHERE CID = '.$cid.' LIMIT 1');
	$row = mysql_fetch_array($result);
	$coname = $row['COMPANYNAME'];
	
	$result = mysql_query('SELECT * FROM covers WHERE UID = '.$_SESSION['cid'].' LIMIT 3');
	$cnt = mysql_num_rows($result);
	$cover = '';
	if($cnt == 0){
		$cover = '&nbsp;&nbsp;&nbsp;<a href="?loc=covers" title="Create a cover letter">Create a cover letter.</a><br /><br />';
	}else{
		while($row = mysql_fetch_array($result)){
			$cover .= '<OPTION value="'.$row['ID'].'" />'.$row['COVERTITLE'].'</OPTION>';
		}
	}
	
	$result = mysql_query('SELECT * FROM resumes WHERE UID = '.$_SESSION['cid'].' LIMIT 3') or die();
	$cnt = mysql_num_rows($result);
	$resume = '';
	if($cnt == 0){
		$resume = '&nbsp;&nbsp;&nbsp;<a href="?loc=covers" title="Create a resume">Create a resume.</a><br /><br />';
	}else{
		while($row = mysql_fetch_array($result)){
			$resume .= '<OPTION value="'.$row['ID'].'" />'.$row['RESUMETITLE'].'</OPTION>';
		}
	}
	
	$retval .= '<form method="POST" action="?loc=view&jid='.$jid.'"><strong>To:  '.$coname.'</strong><input type="hidden" name="cid" value="'.$cid.'" /><br />';
	
	$retval .= '<strong>Subject:</strong> Inquiry for '.$jtitle.'<br />
	<input type="hidden" name="jtitle" value="'.$jtitle.'" />';
	$retval .= '<strong>Optional Message:</strong><br />
			<textarea name="opmsg" class="opmsg"></textarea><br /><br />';
	$retval .= '<strong>Choose a cover letter:</strong><br />';
	$retval .= '<SELECT name="covselect"><option value="-1">None</option>'.$cover.'</SELECT><br /><br />';
	$retval .= '<strong>Choose a resume:</strong><br />';
	$retval .= '<SELECT name="reselect"><option value="-1">None</option>'.$resume.'</SELECT><br />';
	$retval .= '<br /><input type="submit" value="Apply" /></form>';
	$retval .= file_get_contents('mjl-themes/'.$theme.'/apply_form_footer.theme.html');
	return $retval;
}

function FUNCT_SEND_APP($ecid,$ejtitle,$eopmsg,$ecovselect,$ereselect){
	if ($_SESSION['acctype'] == 'seeker') {
		mysql_query('INSERT INTO mail (TCID,FUID,UID,CID,SENTDATE,SUBJECT,MESSAGE,COVER,RESUME) VALUES ('.$ecid.','.$_SESSION['cid'].','.$_SESSION['cid'].','.$ecid.',NOW(),"'.$ejtitle.'","'.$eopmsg.'",'.$ecovselect.','.$ereselect.')') or die(mysql_errno().', '.mysql_error());
	}
	return TRUE;
}
?>
Return current item: MyJobList