Location: PHPKode > projects > Site Sift Listings > include/myfunctions.ini.php
<?
#################################################################################
# myfunctions.ini.php
#################################################################################

#properly encode urls for transmission to paypal
function paypalURL ($url) {
	$urlarray = parse_url($url);
	$paypalurl = $urlarray['scheme'] . '://';
	$paypalurl .= $urlarray['host'];
	$paypalurl .= $urlarray['path'];
	if (strlen($urlarray['query']) > 0) {$paypalurl .= urlencode('?' . $urlarray['query']);}
	if (strlen($urlarray['fragment']) > 0) {$paypalurl .= urlencode('#' . $urlarray['fragment']);}
	return $paypalurl;
}
#gLink Function -- return a href for a <a> tag pending mod rewrite setting
/*string go, string id, mysql connection $mycon*/
function gLink($keywords,$go,$id,$myconn,$page=false){
	global $LINK_BASE;
	if($go == 'detail'){
		$sql = "select * from settings where id = '1'";
		$r = mysql_query($sql,$myconn);
		$settings = mysql_fetch_assoc($r);
		if($settings['directLink'] == 'No'){
			$sql = "select url from pages where id = '" . $id . "'";
			$r = mysql_query($sql,$myconn);
			$page = mysql_fetch_assoc($r);
			return $page['url'];
		}
	}
	$keywords = eregi_replace("[^a-zA-Z0-9_ ]",'',$keywords);	
	$keywords = str_replace(' ','_',$keywords);	
	$keywords = eregi_replace("[_]+",'_',$keywords);						
	if($_SESSION['MM_UserGroup'] == 'Admin') {//disable seo urls if loged in as admin
		$return = 'index.php?go=' . $go . '&id=' . $id;
		if ($page > '0') {
			$return .= '&pageNum_pages=' . $page;
		}
		return $return;
	}
	$sql = "select seoUrl from settings where id = '1'";
	$results = mysql_query($sql,$myconn) or die(mysql_error());
	$settings = mysql_fetch_assoc($results);
	if($settings['seoUrl'] == 'Yes'){
		if($go == 'detail') {
			return $keywords . '-' . $go . '-' . $id . '.html';
		} else {
			$return = $LINK_BASE . $id . '/' . $keywords . '/';
			if ($page > '0') {
				$return .= $page . '/';
			}
			return $return;
		}
//		return $keywords.'-'.$go.'-'.$id.'.html';
	} else {
		$return = $LINK_BASE . 'index.php?go='.$go.'&id='.$id;
		if ($page > '0') {
			$return .= '&pageNum_pages=' . $page;
		}
		return $return;
	}
}//end gLink function

#Future Date Function -- get a future date
/* A MySQL type datetime is inputted (YYYY-MM-DD), a date is calculated that is $days days in the future and converted back to YYYYMMDD format and returned*/ 
function futuredate($date, $days) { 
	//CODE FROM WWW.GREGGDEV.COM 
    $date = str_replace("-", "", $date); 
    $date = strtotime(substr($date,0,10)); 
    //seconds per day times number of days 
    $date = $date + (86400*$days); 
    $date = date("Y-m-d", $date); 
    return $date; 
} 
		
#Money Function -- return a formated money string
/* string amount */
function Money($amount,$myconn){
	//fetch db connection
	$Result = mysql_query("select currSign from settings where id = '1'",$myconn) or die(mysql_error());
	$settings = mysql_fetch_assoc($Result);
	return $settings['currSign']." ".number_format($amount,2,'.',',');
}

	
#catRSel -- Recursive category select
/* mysql query result $fatherR, mysql connecion $myconn */
function catRSel($fatherR,$myconn){
	while($father = mysql_fetch_assoc($fatherR)){
		if($father['fatherID'] == 0)
			print '<option value="' . $father['id'] . '">*' . $father['title'] . '</option>';
		else
			print '<option value="'.$father['id'].'">&nbsp;&nbsp;&nbsp;' . $father['title'] . '</option>';		
		$sql = "select * from categories where fatherID = '" . $father['id'] . "'";
		$R = mysql_query($sql,$myconn) or die(mysql_error());
		catRSel($R,$myconn);
	}//end while
}//end function

#catRSelEdit -- Recursive category select that stops when id is found
/* int $idF, mysql query result $fatherR, mysql connecion $myconn, int $id */
function catRSelEdit($idF,$fatherR,$myconn,$id){
	while($father = mysql_fetch_assoc($fatherR)){
		if($father['id'] != $id){//display select 	
			if($father['id'] == $idF) 
				$selected = ' selected ';
			if($father['fatherID'] == 0)
				print '<option value="'.$father['id'].'"'.$selected.'>*'.$father['title'].'</option>';
			else
				print '<option value="'.$father['id'].'"'.$selected.'>&nbsp;&nbsp;&nbsp;'.$father['title'].'</option>';		
			$selected = '';
			$sql = "select * from categories where fatherID = '" . $father['id'] . "'";
			$R = mysql_query($sql,$myconn) or die(mysql_error());
			catRSelEdit($idF,$R,$myconn,$id);
		}//end if
	}//end while
}//end function
	
#catRSelEditPage -- Recursive category select that stops when id is found
/* int $idF, mysql query result $fatherR, mysql connecion $myconn */
function catRSelEditPage($idF,$fatherR,$myconn){
	while($father = mysql_fetch_assoc($fatherR)){ 	
			if($father['id'] == $idF) 
				$selected = ' selected ';
			if($father['fatherID'] == 0)
				print '<option value="'.$father['id'].'"'.$selected.'>*'.$father['title'].'</option>';
			else
				print '<option value="'.$father['id'].'"'.$selected.'>&nbsp;&nbsp;&nbsp;'.$father['title'].'</option>';		
			$selected = '';
			$sql = "select * from categories where fatherID = '" . $father['id'] . "'";
			$R = mysql_query($sql,$myconn) or die(mysql_error());
			catRSelEditPage($idF,$R,$myconn);
	}//end while
}//end function


#getBCrum -- return bread crum style hor nav links (recursive)
/* int $id, mysql connection $myconn */
function getBCrum($id,$myconn){
	global $LINK_BASE;
	$settings = mysql_fetch_assoc(mysql_query("select * from settings where id = '1'",$myconn));	
	$sql = "select * from categories where id = '" . $id . "'";
	$results = mysql_query($sql,$myconn) or die(mysql_error());
	while($category = mysql_fetch_assoc($results)){
		getBCrum($category['fatherID'],$myconn);
		print '&nbsp;&raquo;&nbsp;<a class="pageLink" style="color:'.$settings['catColor'].'" href="'.gLink($category['title'],'subcat',$category['id'],$myconn).'">'.$category['title'].'</a>';
	}//end while
}//end function

#getAdminBCrum -- return bread crum style hor nav links for admin(recursive)
/* int $id, mysql connection $myconn */
function getAdminBCrum($id,$myconn){
	$sql = "select * from categories where id = '" . $id . "'";
	$results = mysql_query($sql,$myconn) or die(mysql_error());
	while($category = mysql_fetch_assoc($results)){
		getAdminBCrum($category['fatherID'],$myconn);
		print '&nbsp;&raquo;&nbsp;<a class="pageLink" href="subcat.php?id='.$category['id'].'">'.$category['title'].'</a>';
	}//end while
}//end function

#findRootFather -- return father at root level (recursive)
/* int $id, mysql connection $myconn */
function findRootFather($id,$myconn){
	$sql = "select * from categories where id = '" . $id . "'";
	$results = mysql_query($sql,$myconn) or die(mysql_error());
	while($category = mysql_fetch_assoc($results)){
		findRootFather($category['fatherID'],$myconn);
		if($category['fatherID'] == 0)
			print $category['title'].'&nbsp;&raquo;';
	}//end while
}//end function

#getBCrumTitle -- return bread crum style for title (recursive)
/* int $id, mysql connection $myconn */
function getBCrumTitle($id,$myconn){
	$sql = "select * from categories where id = '" . $id . "'";
	$results = mysql_query($sql,$myconn) or die(mysql_error());
	while($category = mysql_fetch_assoc($results)){
		getBCrumTitle($category['fatherID'],$myconn);
		print '&nbsp;&raquo;&nbsp;'.$category['title'];
	}//end while
}//end function


#getMetaTags -- print meta tags based on current page location
/* string $curloc */
function getMetaTags($curloc,$myconn){
	//fetch settings
	$settings = (mysql_fetch_assoc(mysql_query("select * from settings where id = '1'",$myconn)));
	
	switch($curloc){//pending current location
		case 'detail':
		$title = " information page";
		$sql = "select * from pages where id = '" . $_REQUEST['id'] . "'";
		break;
		case 'subcat':
		$title = " " . $settings['title'];
		$sql = "select * from categories where id = '" . $_REQUEST['id'] . "'";
		break;
		default:
		$sql = "select * from settings where id = '1'";
		break;
	}//end switch
	
	
	$results = mysql_query($sql,$myconn) or die(mysql_error());
	$page = mysql_fetch_assoc($results);
	
	if($settings['bcTitle'] == '1' & $curloc == 'subcat'){
		print '<title>'.$title.' ';
		GetBCrumTitle($page['id'],$myconn);
		if ($_REQUEST['pageNum_pages'] > 1) {
			print '&nbsp;&raquo;&nbsp;Page&nbsp;'.$_REQUEST['pageNum_pages'];
		}
		print '</title>';
	}
	else//print meta tags
		print '<title>'.$page['title'].$title.'</title>';
	
	if($page['keywords'] != '')
		print '<meta name="keywords" content="'.$page['keywords'].'">';
	else
		print '<meta name="keywords" content="'.$page['title'].'">';
			
	print '<meta name="description" content="'.$page['description'].'">';
	
	
}//end function

#sessionTransSid -- set USE_TRANS_SID based on admin settings
function sessionTransSid(){
	global $LINK_BASE;
	$settings = @mysql_fetch_array(mysql_query("select * from settings where id = '1'"));	
	if ($settings['useTransSid'] == 'true') {
		if (function_exists('ini_set')) {
			ini_set('session.use_trans_sid', true);
			ini_set('url_rewriter.tags', true);
		}
	} else {
		if (function_exists('ini_set')) {
			ini_set('session.use_trans_sid', false);
			ini_set('url_rewriter.tags', false);
		}
	}
}//end function

function encodestr(){
	global $instid;
	switch($instid){
		case '1':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '2':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '3':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '4':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '5':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '6':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '7':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '8':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		case '9':
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
		default:
			$numberstring = '60:100:105:118:32:97:108:105:103:110:61:34:99:101:110:116:101:114:34:62:60:65:32:104:114:101:102:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:34:62:60:73:77:71:32:115:114:99:61:34:104:116:116:112:58:47:47:119:119:119:46:115:105:116:101:45:115:105:102:116:46:99:111:109:47:80:111:119:101:114:101:100:66:89:72:46:106:112:103:34:32:98:111:114:100:101:114:61:48:62:60:47:65:62';
			break;
	}//end switch
	$array = explode(':',$numberstring);
	foreach($array as $element) echo chr($element);
}
?>
Return current item: Site Sift Listings