';
return $print_all;
}
function funGetCatName($table="",$id=1,$linkTo=""){
global $catName;
global $catLink;
$link =$GLOBALS[link];
$SQLcmd=" select name,id from `".$table."` where id='$id' ";
$result=mysql_query($SQLcmd,$link);
$array=mysql_fetch_array($result);
$catName=$array[name];
$catLink=''.$catName.'';
}
// resize image function //
function imageResize($width, $height, $targetw, $targeth)
{
$percentage = 1;
if (($width > $targetw) || ($height > $targeth))
{
$width_diff = $width - $targetw;
$height_diff = $height - $targeth;
if ($width_diff >= $height_diff)
{
$percentage = ($targetw / $width);
}
else
{
$percentage = ($targeth / $height);
}
}
$width = round($width * $percentage);
$height = round($height * $percentage);
$percentage = 1;
//gets the new value and applies the percentage, then rounds the value
if (($width > $targetw) || ($height > $targeth))
{
$width_diff = $width - $targetw;
$height_diff = $height - $targeth;
if ($width_diff >= $height_diff)
{
$percentage = ($targetw / $width);
}
else
{
$percentage = ($targeth / $height);
}
}
$width = round($width * $percentage);
$height = round($height * $percentage);
return "width='$width' height='$height'";
}
// return a resized image
function funMakeImage($photoPath,$targetWidth=100,$targetHeight=100,$enlarge=0){
$temp=array_reverse(split('/',$photoPath));
$filename=$temp[0];
// resize =====
if (file_exists($photoPath) && strstr($photoPath,'.') && $filename!="" ) {
$image_size = getimagesize($photoPath);
$size = imageResize($image_size[0], $image_size[1], $targetWidth,$targetHeight);
if($enlarge==1){
return "";
}else{
return "";
}
} else {
$size="";
}
}
function str2time($strStr, $strPattern = null)
{
// an array of the valide date characters, see: http://php.net/date#AEN21898
$arrCharacters = array(
'd', // day
'm', // month
'y', // year, 2 digits
'Y', // year, 4 digits
'H', // hours
'i', // minutes
's' // seconds
);
// transform the characters array to a string
$strCharacters = implode('', $arrCharacters);
// splits up the pattern by the date characters to get an array of the delimiters between the date characters
$arrDelimiters = preg_split('~['.$strCharacters.']~', $strPattern);
// transform the delimiters array to a string
$strDelimiters = quotemeta(implode('', array_unique($arrDelimiters)));
// splits up the date by the delimiters to get an array of the declaration
$arrStr = preg_split('~['.$strDelimiters.']~', $strStr);
// splits up the pattern by the delimiters to get an array of the used characters
$arrPattern = preg_split('~['.$strDelimiters.']~', $strPattern);
// if the numbers of the two array are not the same, return false, because the cannot belong together
if (count($arrStr) !== count($arrPattern)) {
return false;
}
// creates a new array which has the keys from the $arrPattern array and the values from the $arrStr array
$arrTime = array();
for ($i = 0;$i < count($arrStr);$i++) {
$arrTime[$arrPattern[$i]] = $arrStr[$i];
}
// gernerates a 4 digit year declaration of a 2 digit one by using the current year
if (isset($arrTime['y']) && !isset($arrTime['Y'])) {
$arrTime['Y'] = substr(date('Y'), 0, 2) . $arrTime['y'];
}
// if a declaration is empty, it will be filled with the current date declaration
foreach ($arrCharacters as $strCharacter) {
if (empty($arrTime[$strCharacter])) {
$arrTime[$strCharacter] = date($strCharacter);
}
}
// checks if the date is a valide date
if (!checkdate($arrTime['m'], $arrTime['d'], $arrTime['Y'])) {
return false;
}
// generates the timestamp
$intTime = mktime($arrTime['H'], $arrTime['i'], $arrTime['s'], $arrTime['m'], $arrTime['d'], $arrTime['Y']);
// returns the timestamp
return $intTime;
}
// ==============================
function funGetCount($filename="count.dat"){
//====================================
// simple counter
//data file name
$datafile=$filename;
//length of the counter
$length = 10;
//Don't update the following lines
if (!file_exists($datafile))
{
$fout = fopen($datafile, "w");
$count = 0;
fwrite($fout, $count, 100);
fclose($fout);
}
$file = fopen($datafile,"r");
$count = fread($file, 100);
$count++;
fclose($file);
$fileb = fopen($datafile,"w");
fwrite($fileb, $count, 100);
fclose($fileb);
$j = 0;
$cntn = strlen($count);
while($j < $length-$cntn) {
//echo("0");
$j++;
}
return $count;
}
//====================================
// =================
/*setcookie('cookie_memberid');
setcookie('cookie_s');
*/
$memberid=$_SESSION["memberid"];
$s=$_SESSION["s"];
if(empty($memberid)){
$memberid=$_COOKIE["cookie_memberid"];
$s=$_COOKIE["cookie_s"];
}
if($memberid!=""){
if(pw_check($memberid,$s)){
$_SESSION["this_memberid"]=$memberid;
}else{
$memberid='';
$_SESSION["this_memberid"]='';
}
}
// =================
$this_memberid=$_SESSION["this_memberid"];
// check member area ======
$memberArea=array(
"member_edit.php",
"member_tran_edit.php",
"editentry.php",
"member.php",
"editentry2db.php",
"mdeleteentry.php",
"moveentry.php",
"updatepassword.php"
);
$currentFilename=$_SERVER['PHP_SELF'];
$temp = explode("/", $currentFilename);
$currentFilename=$temp[count($temp)-1];
//$currentFilename.="X".$_SERVER['QUERY_STRING'];
if (in_array($currentFilename, $memberArea) && !isMember()) {
header('Location: home.php?to='.$currentFilename.'&query_string='.urlencode($_SERVER['QUERY_STRING']));
}else{
}
$to=$_GET["to"];
$query_string=($_GET["query_string"]);
if(!empty($query_string)){
$to=$to.'?'.$query_string;
}
// =======
function funGetMemberName(){
$memberid=$_SESSION["this_memnerid"];
$strsql = "select * from `member` where id='$memberid'";
$result=mysql_query($strsql);
$array=mysql_fetch_array($result);
if($array[sex]=="Male"){
//$member_name="Mr ".$array[lastname];
$member_name=$array[firstname]." ".$array[lastname];
}else{
//$member_name="Ms ".$array[lastname];
}
$member_name=$array[loginname];
return $member_name;
}
function isMember(){
if($_SESSION["this_memberid"]=="" || $_SESSION["this_memberid"]==null){
return false;
}else{
return true;
}
}
// get one field
function funGetField($tablename,$id,$field="name"){
$strsql = "SELECT $field FROM `$tablename` where id='$id' ";
//print $strsql;
if($result=mysql_query($strsql)){
$row = mysql_fetch_array($result);
}
return $row[$field];
}
function funGetNewProduct($tablename,$mywhere,$field="name", $order=""){
$strsql = "SELECT $field FROM `$tablename` where 1 and $field!='' and $mywhere $order ";
//print $strsql;
if($result=mysql_query($strsql)){
$row = mysql_fetch_array($result);
}
return $row[$field];
}
// get option
function funGetOpt($tablename){
$strsql = "SELECT * FROM `$tablename` where status='1' order BY sorting , id desc";
$result=mysql_query($strsql);
while($row = mysql_fetch_array($result)){
$output.='';
}
return $output;
}
?>