Jump to content

whatsupron

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Posts posted by whatsupron

  1. Hi I want to start a rating and social networking site and I would like to know which php template system is the best and easiest to use or which method to use.

    Its because I want to code all the script myself but I'm wondering what template system would be the best

  2. Check the session variable to see if a registered user is logged in before you increment the vote count.  If they're not then throw an error message.

     

    Yeah I have checked it and there is an option for enable/disable login to rate but I want to disable the login to rate and let the guests to rate and also not count their vote

  3. Hi i have a rating website and I have enabled guests to rate but is there anyway I can do that if guests rate people, their vote dont count, so only my registered users votes count not the guests.

     

    here is the code for rating:

    <?php
    
    if(!defined("IN_MIPHOTO")) {
    trigger_error("Unable to process {$HTTP_SERVER_VARS['PHP_SELF']}", E_USER_ERROR);
    }
    
    /*
    
    DEV_CHECK
    
    Added parameter of $bVideo. Need to find where this function is called from and setup to use the parameter
    
    */
    
    
    $iId = initVar('id');
    $iRating = initVar('rating');
    $iGender = initVar('gender',HTTP_GET,true,0);
    $sAct = initVar('act');
    
    $bVideo = initVar('video');
    
    if(getConfig('loginrate',0) && !$gGlobals['user']['loggedin'] ) {
    $oTpl->assign('ErrorMessage',getConfig('errormustlogin'),false);
    return;
    }
    
    if(!userHasAccess(USER_ACCESS_RATE)) {
    if($gGlobals['user']['loggedin']) {
    	$sDo = $HTTP_GET_VARS['do'] = "subscriptions";
    	return $cPlugins->callPluginFunction(PLUGIN_FUNCTION_CLIENT_OUTPUT,0,0);
    } else {
    	$oTpl->assign('ErrorMessage',getConfig('errormustlogin'),false);
    	include('login.php');
    }
    return;
    }
    
    if($iGender != '0' && $gGlobals['user']['loggedin'] && $oCustoms->getCustomID() != 154 /*!CUSTOM_BEN_*/) {
    $iUserCategory = $oDb->getResult($oDb->select("gender","users","id='".$oDb->escape($gGlobals['user']['id'])."'","LIMIT 1"));
    if($oDb->getResult($oDb->select("COUNT(*)","categories_settings","category_id='".$oDb->escape($iUserCategory)."' AND value='".$oDb->escape($iGender)."' AND setting_id='".$oDb->escape(CATEGORY_SETTING_RATE)."'","LIMIT 1")) < 1) {
    	$oTpl->assign('Content',getConfig('errorcannotratecategory'),false);
    	return;
    }
    }
    
    $iPreviousPhoto = initVar('prevphoto',HTTP_GET,true,0);
    
    if($iRating > 10 && !empty($iPreviousPhoto) && $sAct != "nextphoto" && $sAct != "prevphoto")
    $iRating = 10;
    
    if($iRating < 1 && !empty($iPreviousPhoto) && $sAct != "nextphoto" && $sAct != "prevphoto")
    $iRating = 1;
    
    require_once(dirname(__FILE__)."/../include/functions.vote.php");
    
    // Try to record the vote it if valid
    recordRating($iPreviousPhoto,$iRating);
    
    $oTpl->define(array("rate-Default"	=> "rate/default.tpl",));
    
    if($oCustoms->runCustoms(FILE_CONTENT_RATE,1)) {
    } else {
    $sUsersTablePrefix = "userstable.";
    $sPhotosTablePrefix = "photostable.";
    
    $sWhere = " !({$sUsersTablePrefix}special_flags & ".$oDb->escape(USERS_SPECIAL_FLAGS_PAYMENT_DUE).") AND !({$sUsersTablePrefix}special_flags & ".$oDb->escape(USERS_SPECIAL_FLAGS_PROFILE_NEEDS_APPROVAL).") AND !({$sUsersTablePrefix}special_flags & ".$oDb->escape(USERS_SPECIAL_FLAGS_REGISTER_APPROVAL).") AND !({$sUsersTablePrefix}special_flags & ".$oDb->escape(USERS_SPECIAL_FLAGS_PROFILE_DECLINED).") AND !({$sUsersTablePrefix}special_flags & ".$oDb->escape(USERS_SPECIAL_FLAGS_SUSPENDED).") AND {$sUsersTablePrefix}rating_contest='1' ";
    
    if($iGender != '0')
    	$sWhere .= " AND {$sUsersTablePrefix}gender='".$oDb->escape($iGender)."'";
    
    if(getConfig('votedelay',0)) {
    	$sWhereVotes = "((";
    
    	if($gGlobals['user']['loggedin'])
    		$sWhereVotes .= "from_user_id='".$oDb->escape(getUserId())."' OR ";
    
    	$sWhereVotes .= "ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."') AND ((";
    
    	if(getConfig('ratingdelaytype',0) == '2') {
    		$sDelayDate = getConfig('votedelaydate',0);
    		$sWhereVotes .= "((UNIX_TIMESTAMP('".$oDb->escape($sDelayDate)."')-UNIX_TIMESTAMP(added)) > 0)  AND ((UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP('".$oDb->escape($sDelayDate)."')) <= 0)))) GROUP BY to_user_id";
    	} else {
    		$iIdelay = intval(getConfig('votedelayseconds',0));
    
    		if(empty($iIdelay) || !is_numeric($iIdelay))
    			$iIdelay = 300;
    
    		$sWhereVotes .= "UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) < {$iIdelay})) GROUP BY to_user_id";
    	}
    
    	$sWhereVotesList = "";
    	if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    		$sWhere .= $sWhereVotesList = " AND ({$sPhotosTablePrefix}userid NOT IN(";
    	}
    	elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY) {
    		$sWhere .= $sWhereVotesList = " AND ({$sPhotosTablePrefix}id NOT IN(";
    	}
    	elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || $gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS) {
    		$sWhere .= $sWhereVotesList = " AND (videostable.id NOT IN(";
    	}
    
    	$sWhereList = "0,";
    
    	$rResult = $oDb->select("to_user_id","votes",$sWhereVotes,"ORDER BY NULL");
    	while($aData = $oDb->getRow($rResult)) {
    		$sWhereList .= "{$aData['to_user_id']},";
    	}
    	$oDb->freeResult($rResult);
    
    	$sWhereList = substr($sWhereList,0,-1);
    
    	$sWhere .= "{$sWhereList}))";
    //		$sWhereVotesList .= "{$sWhereList}))";
    }
    
    $sWhere .= " AND userstable.id!=".intval(getUserId());
    
    $iMaxAge = intval(initVar('maxage'));
    $iMinAge = intval(initVar('minage'));
    // Add min and max age restrictions if they are setup...
    if($iMinAge > 0)
    	$sWhere .= " AND ROUND((PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM userstable.birthday),EXTRACT(YEAR_MONTH FROM NOW()))/-12),0)>=".($iMinAge);
    if($iMaxAge > 0)
    	$sWhere .= " AND ROUND((PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM userstable.birthday),EXTRACT(YEAR_MONTH FROM NOW()))/-12),0)<=".($iMaxAge);
    
    
    $oCustoms->runCustoms(FILE_CONTENT_RATE,4,array('sWhere' => &$sWhere));
    
    if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    	$aTables = array(
    						array('table'	=>	'photos',
    								'alias'	=>	'photostable',
    								'select'	=>	array('id','userid'),
    								'useindex' => 'photos_default',
    								),
    						array('table'	=>	'users',
    								'alias'	=>	'userstable',
    								'select'	=> array(),
    								'useindex' => 'users_random_rating',
    								)
    						);
    
    	$sWhere .= " AND photostable.isdefault=1 AND photostable.gallery_id=0 AND photostable.approved=1 AND photostable.userid=userstable.id";
    	//		$rResult = $oDb->selectMultiple($aTables,$sWhere," GROUP BY photostable.userid ORDER BY NULL");
    	$rResult = $oDb->selectMultiple($aTables,$sWhere," GROUP BY photostable.userid ORDER BY RAND() LIMIT 1");
    }
    elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && !$bVideo)) {
    	$aTables = array(
    						array('table'	=>	'photos',
    								'alias'	=>	'photostable',
    								'select'	=>	array('id','userid')
    								),
    						array('table'	=>	'users',
    								'alias'	=>	'userstable',
    								'select'	=> array(),
    								'useindex' => 'users_random_rating',
    								),
    						array('table'	=>	'galleries',
    								'alias'	=>	'g',
    								'select'	=> array(),
    								)
    					);
    	$sWhere .= " AND photostable.ratable=1 AND photostable.approved=1 AND photostable.userid=userstable.id AND (photostable.gallery_id=0 OR (g.id=photostable.gallery_id AND g.is_private=0)) ";
    	//		$rResult = $oDb->selectMultiple($aTables,$sWhere," GROUP BY photostable.id ORDER BY NULL");
    
    	$rResult = $oDb->selectMultiple($aTables,$sWhere," GROUP BY photostable.id ORDER BY RAND() LIMIT 1");
    }
    elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && $bVideo)) {
    	$aTables = array(
    						array('table'	=>	'videos',
    								'alias'	=>	'videostable',
    								'select'	=>	array('id','userid','description','video_filename')
    								),
    						array('table'	=>	'users',
    								'alias'	=>	'userstable',
    								'select'	=> array(),
    								'useindex' => 'users_random_rating',
    								)
    					);
    
    	$sWhere .= " AND videostable.ratable=1 AND videostable.approved=1 AND videostable.userid=userstable.id ";
    	//		$rResult = $oDb->selectMultiple($aTables,$sWhere," GROUP BY videostable.id ORDER BY NULL");
    	$rResult = $oDb->selectMultiple($aTables,$sWhere," GROUP BY videostable.id ORDER BY RAND() LIMIT 1");
    }
    
    //echo "<!-- ".$sWhere." -->";
    
    $iMaxPhotos = $oDb->getRowCount($rResult);
    
    if($iMaxPhotos > 0) {
    	$bFindUser = true;
    
    	$aData = $oDb->getRow($rResult);
    
    	if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    		$iUserId = $aData['userid'];
    	}
    	elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || $gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || $gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS) {
    		$iUserId = $aData['id'];
    	}
    
    	$bFindUser = false;
    
    	$iUserId = $aData['userid'];
    	$iPhotoId = $aData['id'];
    
    
    	// Display rating bars here... stops the template variables from being cleared...
    	if($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || $gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || $gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS) {
    		displayRatingBars($iPhotoId,'Rate',"index.php?do=rate",$iGender);
    		$oTpl->assign('RateUserIdOrPhotoId',$iPhotoId);
    	}
    
    
    	$oTpl->assign('RateUserVideoDownloadLink','');
    	$oTpl->assign('RateUserVideoFileName','');
    
    	if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    		$iPhotoId = getUserDefaultPhotoId($iUserId);
    		$oTpl->assign('RateUserIdOrPhotoId',$iUserId);
    		displayRatingBars($iUserId,'Rate',"index.php?do=rate",$iGender);
    
    		if(MIPHOTO_FEATURE_PHOTO_DETAILS) {
    			setPhotoFieldsTemplateVariables($iPhotoId,'Rate');
    		}
    	}
    	elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && !$bVideo)) {
    		if(MIPHOTO_FEATURE_PHOTO_DETAILS) {
    			setPhotoFieldsTemplateVariables($iPhotoId,'Rate');
    		}
    	}
    	elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && $bVideo)) {
    		$oTpl->assign('RateUserPhotoDescription',$aData['description'],false);
    		//$oTpl->assign('RateUserVideoDownloadLink',"dl.php?",false);
    		$oTpl->assign('RateUserVideoFileName',$aData['video_filename'],false);
    	}
    
    	$oTpl->assign('RateUserId',$iUserId);
    	$oTpl->assign('RateUserName',getUserProfileLink($iUserId));
    
    	if(RANDOM_RATE_PROFILE_INFORMATION) {
    		setUserTemplateVariables($iUserId,'Rate',false,NULL,false);
    	}
    
    	$oTpl->assign('RateUserPhotoId',$iPhotoId);
    
    	$oTpl->assign('RateUserThumbnailLink',getImageThumbnailLink($iPhotoId,false,THUMBNAIL_SIZE_RATE,false,false,(($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && $bVideo)) ? true : false),true,"",$iUserId));
    
    	$oCustoms->runCustoms(FILE_CONTENT_RATE,2,array('iPhotoId'=> &$iPhotoId, 'iUserId' => &$iUserId));
    
    	$oTpl->assign('RateUserGender',$iGender);
    	$oTpl->parse('Content','rate-Default',true);
    } else {
    	$oTpl->assign('ErrorMessage',getConfig('errornousertorate'),false);
    }
    }
    ?>

     

    and here is function.vote.php

    <?php
    
    
    if(!defined("IN_MIPHOTO")) {
    trigger_error("Unable to process {$HTTP_SERVER_VARS['PHP_SELF']}", E_USER_ERROR);
    }
    
    function updateDatabaseRealRatingField($sTable, $iId = -1) {
    global $oDb;
    
    switch(strtolower($sTable)) {
    	case "photos":
    		$oDb->update("photos",array('real_rating' => MYSQL_NO_QUOTES_ESCAPE_CHARACTERS.MIPHOTO_RATING_FORMULA_MYSQL), ($iId != -1 ? "id=".intval($iId) : ""));
    		break;
    	case "users":
    		$oDb->update("users",array('real_rating' => MYSQL_NO_QUOTES_ESCAPE_CHARACTERS.MIPHOTO_RATING_FORMULA_MYSQL), ($iId != -1 ? "id=".intval($iId) : ""));
    		break;
    }
    }
    
    /*
    
    DEV_CHECK
    
    Added parameter of $bVideo. Need to find where this function is called from and setup to use the parameter
    
    */
    
    function canUserVoteAgain($iPreviousPhoto, $bVideo = false) {
    global $oDb,$gGlobals,$oTpl;
    // check to see if voting is disabled
    if(!getConfig('votingenabled',0)) {
    	$oTpl->assign('Content',getConfig('errorvotingdisabled'),false);
    	return -1;
    }
    
    
    if($gGlobals['user']['loggedin']) {
    	if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    		$iOtherUserCategory = $oDb->getResult($oDb->select("gender","users","id='".$oDb->escape($iPreviousPhoto)."'","LIMIT 1"));
    	}
    	elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && !$bVideo)) {
    		$iUserId = $oDb->getResult($oDb->select("userid","photos","id='".$oDb->escape($iPreviousPhoto)."'","LIMIT 1"));
    
    		$iOtherUserCategory = $oDb->getResult($oDb->select("gender","users","id='".$oDb->escape($iUserId)."'","LIMIT 1"));
    	}
    	elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && $bVideo)) {
    		$iUserId = $oDb->getResult($oDb->select("userid","videos","id='".$oDb->escape($iPreviousPhoto)."'","LIMIT 1"));
    
    		$iOtherUserCategory = $oDb->getResult($oDb->select("gender","users","id='".$oDb->escape($iUserId)."'","LIMIT 1"));
    	}
    
    
    	$iUserCategory = $oDb->getResult($oDb->select("gender","users","id='".$oDb->escape($gGlobals['user']['id'])."'","LIMIT 1"));
    
    	//echo "\n\n<!-- DEBUG  {$iOtherUserCategory}:{$iUserCategory} -->\n\n";
    
    	if($oDb->getResult($oDb->select("COUNT(*)","categories_settings","category_id='".$oDb->escape($iUserCategory)."' AND value='".$oDb->escape($iOtherUserCategory)."' AND setting_id='".$oDb->escape(CATEGORY_SETTING_RATE)."'","LIMIT 1")) < 1) {
    		//echo "\n\n<!-- DEBUG  user cannot rate members in this category -->\n\n";
    		return -2;
    	}
    
    	if($oDb->getResult($oDb->select("COUNT(*)","block_list","user_id='".$oDb->escape($iPreviousPhoto)."' AND block_user_id='".$oDb->escape(getUserId())."'","LIMIT 1"))) {
    		return -3;
    	}
    }
    
    $bVoteDelay = getConfig('votedelay',0);
    $iNewRating = 1;
    
    if($bVoteDelay) {
    	if(getConfig('ratingdelaytype',0) == '2') {
    		$sDelayDate = getConfig('votedelaydate',0);
    		//$iNewRating = !$oDb->getResult($oDb->select("COUNT(*)","votes","(ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."' OR from_user_id='".$oDb->escape(getUserId())."') AND to_user_id='".$oDb->escape($iPreviousPhoto)."' AND ((UNIX_TIMESTAMP(added)-UNIX_TIMESTAMP('".$oDb->escape($sDelayDate)."')) <= 0)"));
    		//$iNewRating = (($oDb->getResult($oDb->select("COUNT(*)","votes","(ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."' OR from_user_id='".$oDb->escape(getUserId())."') AND to_user_id='".$oDb->escape($iPreviousPhoto)."' AND (((UNIX_TIMESTAMP('".$oDb->escape($sDelayDate)."')-UNIX_TIMESTAMP(added)) > 0)  AND ((UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP('".$oDb->escape($sDelayDate)."')) <= 0))")) == '0') ? 1 : 0);
    
    		$iNewRating = (($oDb->getResult($oDb->select("COUNT(*)","votes","(ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'".(($gGlobals['user']['loggedin'])?" OR from_user_id='".$oDb->escape(getUserId())."'":"").") AND to_user_id='".$oDb->escape($iPreviousPhoto)."' AND (((UNIX_TIMESTAMP('".$oDb->escape($sDelayDate)."')-UNIX_TIMESTAMP(added)) > 0)  AND ((UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP('".$oDb->escape($sDelayDate)."')) <= 0))","LIMIT 1")) == '0') ? 1 : 0);
    	} else {
    		$iIdelay = getConfig('votedelayseconds',0);
    
    		if(empty($iIdelay) || !is_numeric($iIdelay))
    			$iIdelay = 300;
    
    		//$iNewRating = (($oDb->getResult($oDb->select("COUNT(*)","votes","(ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."' OR from_user_id='".$oDb->escape(getUserId())."') AND to_user_id='".$oDb->escape($iPreviousPhoto)."' AND ((UNIX_TIMESTAMP(added)-UNIX_TIMESTAMP((now()-{$iIdelay}))) >= 0)")) == '0') ? 1 : 0);
    		$iNewRating = (($oDb->getResult($oDb->select("COUNT(*)","votes","(ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'".(($gGlobals['user']['loggedin'])?" OR from_user_id='".$oDb->escape(getUserId())."'":"").") AND to_user_id='".$oDb->escape($iPreviousPhoto)."' AND ((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) < '{$iIdelay}')","LIMIT 1")) == '0') ? 1 : 0);
    		//$iNewRating = (($oDb->getResult($oDb->select("COUNT(*)","votes","(ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'".(($gGlobals['user']['loggedin'])?" OR from_user_id='".$oDb->escape(getUserId())."'":"").") AND to_user_id='".$oDb->escape($iPreviousPhoto)."' AND ((added-(CURRENT_TIMESTAMP()-{$iIdelay})) >= 0)")) == '0') ? 1 : 0);
    	}
    }
    
    return $iNewRating;
    }
    
    /*
    
    DEV_CHECK
    
    Added parameter of $bVideo. Need to find where this function is called from and setup to use the parameter
    
    */
    
    function recordRating($iPreviousPhoto, $iRating, $bVideo = false) {
    global $oDb,$gGlobals;
    
    if(empty($iPreviousPhoto) || empty($iRating) || !is_numeric($iRating) || !is_numeric($iPreviousPhoto) || $iPreviousPhoto == getUserId())
    	return 0;
    
    if((int)$iRating > 10) {
    	return 0;
    }
    if((int)$iRating < 1) {
    	return 0;
    }
    
    if(strlen((string)$iRating) > 2)
    	return 0;
    
    $iNewRating = canUserVoteAgain($iPreviousPhoto);
    
    if((int)$iNewRating < 0)
    	return 0;
    
    if($iNewRating) {
    	$aFields = array('rating'	=>	MYSQL_NO_QUOTES_ESCAPE_CHARACTERS.'(rating+'.$oDb->escape($iRating).')',
    						'votes'	=>	MYSQL_NO_QUOTES_ESCAPE_CHARACTERS.'(votes+1)'
    					);
    
    	if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    		$oDb->update("users",$aFields,"id='".$oDb->escape($iPreviousPhoto)."'");
    
    		updateDatabaseRealRatingField("users",$iPreviousPhoto);
    	}
    	elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && !$bVideo)) {
    		$iUserId = $oDb->getResult($oDb->select("userid","photos","id='".$oDb->escape($iPreviousPhoto)."'","LIMIT 1"));
    
    		$oDb->update("users",$aFields,"id='".$oDb->escape($iUserId)."'");
    		$oDb->update("photos",$aFields,"id='".$oDb->escape($iPreviousPhoto)."'");
    
    		updateDatabaseRealRatingField("users",$iUserId);
    		updateDatabaseRealRatingField("photos",$iPreviousPhoto);
    	}
    	elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && $bVideo)) {
    		$iUserId = $oDb->getResult($oDb->select("userid","videos","id='".$oDb->escape($iPreviousPhoto)."'","LIMIT 1"));
    
    		$oDb->update("users",$aFields,"id='".$oDb->escape($iUserId)."'");
    		$oDb->update("videos",$aFields,"id='".$oDb->escape($iPreviousPhoto)."'");
    
    		updateDatabaseRealRatingField("users",$iUserId);
    		updateDatabaseRealRatingField("videos",$iPreviousPhoto);
    	}
    
    	$aFields = array('added'	=>	MYSQL_NO_QUOTES_ESCAPE_CHARACTERS.'NOW()',
    						'to_user_id'	=> $iPreviousPhoto,
    						'from_user_id'	=>	getUserId(),
    						'rating'	=>	$iRating,
    						'ip_address'	=>	$gGlobals['user']['ipaddress']);
    	$oDb->insert("votes",$aFields);
    } else {
    	/*
    	// Disabled due to not allowing a user to vote any more since implementation of rating_bars.tpl
    	$sWhere = "to_user_id='".$oDb->escape($iPreviousPhoto)."' AND (";
    
    	if($gGlobals['user']['loggedin'])
    		$sWhere .= "from_user_id='".$oDb->escape(getUserId())."' OR ";
    
    	$sWhere .= " ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."')";
    
    	$iOldRating = $oDb->getResult($oDb->select("rating","votes",$sWhere,"LIMIT 1"));
    	$aFields = array('updated'	=>	MYSQL_NO_QUOTES_ESCAPE_CHARACTERS.'NOW()',
    						'rating' => $iRating);
    
    	$iRating = $iRating - $iOldRating;
    	$oDb->query("UPDATE {$gGlobals['database']['prefix']}_usersz SET rating=(rating+".$oDb->escape($iRating).") WHERE id='".$oDb->escape($iPreviousPhoto)."'");
    
    	$oDb->update('votes',$aFields,$sWhere,"ORDER BY added DESC LIMIT 1");
    	*/
    }
    return 1;
    }
    
    ?>

  4. Hi I have a rating website like hotornot.com and I have the option where I can make my users login to rate but I also want the guests to rate and when I allow guests to rate there is lots of spammers just using a proxy with different Ip's and they give unfair rating to everyone, is there anyway or any php script that I can get rid of these scammers???

  5. Hi i have setup an ajax function for photo comments and I have called the ajax function but my problem is I cant get the template file to show for photo comments and here is the link for it http://dating.iurate.com/index.php?do=rate&act=profile&view=mypictures&op=comments&user_id=2&photoid=2

    here is more information on the script 

    <?php
    
    if(!defined("IN_MIPHOTO")) {
    trigger_error("Unable to process {$HTTP_SERVER_VARS['PHP_SELF']}", E_USER_ERROR);
    }
    
    function returnPhotoComments($iPhotoId, $iStart = 0, $iNumberOfComments = 1) {
    global $oDb, $oTpl;
    
    $oTpl->define(array('profile-ViewProfileMyPicturesPhotoCommentsEach'	=>	'profile/my_pictures_comments_default.tpl'));
    
    if($iStart < 0) {
    	$iStart = 0;
    }
    if($iNumberOfComments < 1) {
    	$iNumberOfComments = 1;
    }
       $rResult = $oDb->select("added,from_user_id,comments","photo_comments","approved=1 AND photo_id='".$oDb->escape($iPhotoId)."'","ORDER BY added DESC LIMIT {$iStart}, {$iNumberOfComments}");
    while($aData = $oDb->getRow($rResult)) {
    	$oTpl->assign('RateViewProfileMyPicturesPhotoCommentsEachComment',$aData['comments']);
    	$oTpl->assign('RateViewProfileMyPicturesPhotoCommentsEachDate',formatDateTime($aData['added']));
    
    	setUserTemplateVariables($aData['from_user_id'],'RateViewProfileMyPicturesPhotoCommentsEach');
    
    	$oTpl->parse('temp','.profile-ViewProfileMyPicturesPhotoCommentsEach');
    }
    $oDb->freeResult($rResult);
    
    $sComments = $oTpl->getValue('temp');
    $oTpl->clearVars('temp');
    
    return $sComments;
    }
    
    function addPhotoComment($iPhotoId, $sComments) {
    global $oDb;
    
    if(empty($sComments)) {
    	return 0;
    }
    
    $aFields = array('added'	=>	MYSQL_CHARACTER_SET.'NOW()',
    'photo_id'	=>	$iPhotoId,
    'from_user_id'	=>	getUserId(),
    'comments'	=>	$sComments,
    'approved'	=>	getConfig('commentapproval',0)
    );
    
    return $oDb->insert("photo_comments",$aFields);
    }
    
    function requestGalleryAccess($iGalleryId, $iUserId = -1) {
    global $oDb;
    
    $iUserId = intval($iUserId);
    $iGalleryId = intval($iGalleryId);
    
    if($iUserId < 1) {
    	$iUserId = getUserId();
    }
    
    if($iUserId < 1)
    	return 0;
    
    // Check to make sure the user and gallery exists
    // check to make sure this request isn't already in database
    if(!$oDb->getResult($oDb->select("COUNT(*)","users","id=".$iUserId)) ||
    	!$oDb->getResult($oDb->select("COUNT(*)","galleries","id=".$iGalleryId)) ||
    	!$oDb->getResult($oDb->select("COUNT(*)","galleries_accesslist","user_id=".$iUserId." AND gallery_id=".$iGalleryId))
    	) {
    	return 0;
    }
    
    $aFields = array('added'	=>	MYSQL_NO_QUOTES_ESCAPE_CHARACTERS.'NOW()',
    				'gallery_id'	=>	$iGalleryId,
    				'user_id'		=>	$iUserId,
    				'approved'	=> 0
    				);
    
    $oDb->insert("galleries_accesslist",$aFields);
    
    return 1;
    }
    
    if(AJAX_CALL) {
    return;
    }
    
    // END OF AJAX FUNCTIONS
    // ***************************************************************************************
    // ***************************************************************************************
    // ***************************************************************************************
    
    if($sAct == 'requestgalleryaccess') {
    requestGalleryAccess($iGalleryId);
    }
    
    if($sOp == 'comments') {
    returnPhotoComments($iPhotoId, $iStart, 10);
    }
    
    
    $oTpl->assign('RateViewProfileUserGalleries','');
    
    if(empty($iGalleryId)) {
    $rResult = $oDb->select("id,title","galleries","user_id='".$oDb->escape($iId)."'","ORDER BY added DESC");
    
    while($aDataGalleries = $oDb->getRow($rResult)) {
    	if($oDb->getResult($oDb->select("COUNT(*)","photos","gallery_id='".$oDb->escape($aDataGalleries['id'])."' AND approved='1'","LIMIT 1")) < 1)
    		continue;
    
    	$oTpl->assign('RateViewProfileUserGalleriesGalleryThumbnailLink',getImageThumbnailLink(getUserDefaultPhotoId($iId,true,$aDataGalleries['id']),false,THUMBNAIL_SIZE_DEFAULT,true,false,false,true,"index.php?do=rate&act=profile&view={$sView}&user_id={$iId}&gallery_id={$aDataGalleries['id']}"));
    	$oTpl->assign('RateViewProfileUserGalleriesGalleryId',$aDataGalleries['id']);
    	$oTpl->assign('RateViewProfileUserGalleriesGalleryTitle',htmlspecialchars($aDataGalleries['title']));
    	$oTpl->assign('RateViewProfileUserGalleriesGalleryNumberOfPhotos',$oDb->getResult($oDb->select("COUNT(*)","photos","userid='".$oDb->escape($iId)."' AND approved='1' AND gallery_id='".$oDb->escape($aDataGalleries['id'])."'")));
    
    	$oTpl->parse('RateViewProfileUserGalleries','.profile-ViewProfileGalleriesEach');
    }
    $oDb->freeResult($rResult);
    }
    
    $bAccessGallery = true;
    
    $sWhere = "userid=".intval($iId)." AND approved='1'";
    
    $oTpl->assign('RateViewProfileUserGalleryTitle','',false);
    
    if(empty($iGalleryId) || !is_numeric($iGalleryId)) {
    $sWhere .= " AND gallery_id=0 ";
    } else {
    $sWhere .= " AND gallery_id=".intval($iGalleryId)." ";
    
    $oTpl->assign('RateViewProfileUserGalleryTitle',$oDb->getResult($oDb->select("title","galleries","id=".intval($iGalleryId)." AND user_id=".intval($iId),"LIMIT 1")),false);
    
    // Let users see their own galleries
    if($iId != getUserId()) {
    	// Check that user has access to view this gallery
    	$bAccessGallery = userHasAccessToGallery($iGalleryId);
    
    	// Make the SQL query impossible
    	if(!$bAccessGallery) {
    		$sWhere = "id=0";
    	}
    }
    }
    
    $oCustoms->runCustoms(FILE_CONTENT_PROFILE_MYPICTURES,1);
    
    $oTpl->assign('RateViewProfileUserPhotos','');
    
    $iPhotosPerPage = getConfig('photospergallerypage',0);
    
    if(!userHasAccess(USER_ACCESS_VIEW_ADDITIONAL_PHOTOS)) {
    // See if the profile display type is split
    if($bSplitProfile) {
    	if($gGlobals['user']['loggedin']) {
    		$sDo = $HTTP_GET_VARS['do'] = "subscriptions";
    		return $cPlugins->callPluginFunction(PLUGIN_FUNCTION_CLIENT_OUTPUT,0,4);
    	} else {
    		$oTpl->assign('ErrorMessage',getConfig('errormustlogin'),false);
    		include_once(dirname(__FILE__)."/login.php");
    	}
    	return;
    } else {
    	$oTpl->assign('RateViewProfileUserPhotos',getConfig('errorpremierusersonly'),false);
    	return;
    }
    
    $rResult = 0;
    } else {
    $iStart = setPagingTemplateVariables('RateViewProfileUserPictures',"rate&act=profile&id={$iId}&view={$sView}&gallery_id={$iGalleryId}",'photos',$sWhere,$iPage,$iPhotosPerPage);
    // Display addition photos
    $rResult = $oDb->select("id,ratable".(($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || $gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS)?",rating,votes":""),"photos",$sWhere,"ORDER BY added DESC LIMIT {$iStart},{$iPhotosPerPage}");
    }
    
    while($aDataPictures = $oDb->getRow($rResult)) {
    if(MIPHOTO_FEATURE_PHOTO_DETAILS) {
    	setPhotoFieldsTemplateVariables($aDataPictures['id'],'RateViewProfile');
    }
    
    $oTpl->assign('RateViewProfileUserPhotosPhoto',getImageThumbnailLink($aDataPictures['id'],false,THUMBNAIL_SIZE_DEFAULT,true,false,false,true,"",$iId));
    $oTpl->assign('RateViewProfileUserPhotosPhotoId',$aDataPictures['id']);
    
    // Output the rating bar for the photo if photos are rated
    if($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || $gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS) {
    	if($aDataPictures['ratable']) {
    		$oTpl->assign('RateViewProfileUserPhotosPhotoRating',formatRating($aDataPictures['rating'],$aDataPictures['votes'],0));
    		$oTpl->assign('RateViewProfileUserPhotosPhotoVotes',$aDataPictures['votes']);
    		$oTpl->assign('RateViewProfileUserPhotosPhotoNumericalRating',formatRating($aDataPictures['rating'],$aDataPictures['votes'],0,0,false,true));
    	} else {
    		$oTpl->assign('RateViewProfileUserPhotosPhotoRating','');
    	}
    } else {
    	$oTpl->assign('RateViewProfileUserPhotosPhotoRating','');
    }
    
    
    if($oCustoms->runCustoms(FILE_CONTENT_PROFILE_MYPICTURES,2)) {}
    else {
    	$oTpl->parse('RateViewProfileUserPhotos','.profile-ViewProfilePhotosEach');
    }
    }
    $oDb->freeResult($rResult);
    
    if(!$bAccessGallery) {
    // See if the user has
    $sSQL = sprintf("SELECT COUNT(*) FROM {$oDb->sTablePrefix}_galleries_accesslist WHERE user_id=%d AND gallery_id=%d AND approved=0",getUserId(),$iGalleryId);
    if($oDb->getResult($oDb->query($sSQL))) {
    	$sErrorMsg = getConfig('errorpendingaccessviewgallery');
    	$oTpl->assign('ErrorMessage',$sErrorMsg,false);
    } else {
    	$sErrorMsg = getConfig('errornoaccessviewgallery');
    	$sErrorMsg = replaceVars($sErrorMsg,'GalleryId',$iGalleryId);
    	$oTpl->assign('ErrorMessage',$sErrorMsg,false);
    }
    }
    
    ?>

     

    and this is what $oTpl stands for

    $oTpl = new cMiTemplate($gGlobals['html_directory']);

     

    and here is template class

    <?php
    
    if(!defined("IN_MIPHOTO")) {
    trigger_error("Unable to process {$HTTP_SERVER_VARS['PHP_SELF']}", E_USER_ERROR);
    }
    
    class cMiTemplate {
    var $aTemplateFileList = array();
    var $_aVars = array();
    var $_aVarsTemp = array();
    var $_aParseVarsTemp = array();
    
    var $sTemplateDir = "html_1";
    var $sVariableChar = '$';
    
    var $sStartDelim = '\$';
    var $sEndDelim = '\$';
    var $sCompileDir = 'include/cache'; // The dir to store compiled templates
    
    var $iTime;
    
    function cMiTemplate($sTemplateDir = "") {
    	$this->sTemplateDir = $sTemplateDir;
    	$this->sCompileDir = dirname(__FILE__).'/../'.$this->sCompileDir;
    }
    
    function define($aArray) {
    	$this->aTemplateFileList = array_merge($this->aTemplateFileList,$aArray);
    }
    
    function assign($aArray, $sValue="", $bRemoveAfterParse = true) {
    	if(is_array($aArray)) {
    		foreach($aArray as $sKey => $sValue) {
                    if(!empty($sKey)) {
                        $this->_aVars[$sKey] = $sValue;
    
                        if($bRemoveAfterParse) {
                        	$this->_aVarsTemp[] = $sKey;
                        }
                    }
                }
            } else {
                if(!empty($aArray)) {
                    $this->_aVars[$aArray] = $sValue;
    
                    if($bRemoveAfterParse) {
                    	$this->_aVarsTemp[] = $aArray;
                    }
                }
            }
    }
    
    function getValue($sTemplateVariable) {
    	return $this->_aVars[$sTemplateVariable];
    }
    
    function clearAllVars() {
    	$this->_aVars = array();
    	$this->_aVarsTemp = array();
    }
    
    function clearVars($sKey = null) {
    	if($sKey == null) {
    		foreach($this->_aVarsTemp as $a) {
    			if(array_key_exists($a,$this->_aVars)) {
    				// Remove this key from the array
    				unset($this->_aVars[$a]);
    			}
    		}
    		// Clear the removal list..
    		$this->_aVarsTemp = array();
    	} else {
    		if(array_key_exists($sKey, $this->_aVars)) {
    			// Unset this one key in the array
    			unset($this->_aVars[$sKey]);
    		}
    	}
    }
    
    function clearParseVars($sKey = null) {
    	if($sKey == null) {
    		foreach($this->_aParseVarsTemp as $a) {
    			if(array_key_exists($a,$this->_aVars)) {
    				// Remove this key from the array
    				unset($this->_aVars[$a]);
    			}
    		}
    		// Clear the removal list..
    		$this->_aParseVarsTemp = array();
    	} else {
    		if(in_array($sKey, $this->_aVars)) {
    			// Unset this one key in the array
    			unset($this->_aVars[$sKey]);
    		}
    	}
    }
    
    function append($sKey, $aArray) {
    	if(is_array($aArray) && is_array($this->_aVars[$sKey])) {
    		$this->_aVars[$sKey] = array_merge($this->_aVars[$sKey],$aArray);
            }
            elseif(is_string($aArray) && is_string($this->_aVars[$sKey])) {
    		$this->_aVars[$sKey] .= $aArray;
            } else {
            	$this->assign($sKey,$aArray,false);
            }
    }
    
    function parse($sKey, $sValue, $bClearParseVars = false) {
    	$bAppend = false;
    
    	if(substr($sValue,0,1) == ".") {
    		$bAppend = true;
    		$sValue = substr($sValue,1);
    	}
    
    	$sTempBuffer = $this->_fetch($this->aTemplateFileList[$sValue]);
    
    	if($bAppend) {
    		$this->append($sKey,$sTempBuffer);
    	} else {
    		$this->assign($sKey,$sTempBuffer,false);
    	}
    
    	// Clear up the memory
    	unset($sTempBuffer);
    
    	if(!$bAppend) {
    		// Clear the temp vars to save memory and time
    
    		// DISABLED FOR NOW... WHAT IF USERS WISH TO MOVE STUFF AROUND.. REALLY MESSES THINGS UP
    		//$this->clearVars();
    	}
    
    	if($sKey != 'Content') {
    		$this->_aParseVarsTemp[] = $sKey;
    	}
    
    	if($bClearParseVars) {
    		// DISABLED FOR NOW... WHAT IF USERS WISH TO MOVE STUFF AROUND.. REALLY MESSES THINGS UP
    		//$this->clearParseVars();
    	}
    }
    
    function display($sFileName) {
    	echo($this->_fetch($this->aTemplateFileList[$sFileName]));
    }
    
    function returndisplay($sFileName) {
    	return $this->_fetch($this->aTemplateFileList[$sFileName]);
    }
    
    function _getTemplatePath($sFileName) {
    	$sPath = $this->sTemplateDir;
    
    	if((substr($sPath,-1) != "/" && substr($sPath,-1) != "\\") && (substr($sFileName,0,1) != "/" && substr($sFileName,0,1) != "\\")) {
    		// Add /
    		$sPath .= "/";
    	}
    
    	return $sPath.$sFileName;
    }
    
    function _getCompiledPath($sFileName) {
    	$sPath = $this->sCompileDir;
    
    	if(substr($sFileName,0,1) == "/" || substr($sFileName,0,1) == "\\") {
    		$sFileName = substr($sFileName,1);
    	}
    
    	$sFileName = $this->_compiledFileName($sFileName);
    
    	if((substr($sPath,-1) != "/" && substr($sPath,-1) != "\\")) {
    		// Add /
    		$sPath .= "/";
    	}
    
    	return $sPath.$sFileName;
    }
    
    function _fetch($sFileName) {
    	$sCompiledFile = $this->_getCompiledPath($sFileName);
    
    	//echo "$sFileName - Compiled time: ".filemtime($sCompiledFile)."<br>\n";
    	//echo "$sFileName - Template time: ".filemtime($this->_getTemplatePath($sFileName))."<br>\n";
    
    	// Make sure the template file is complied, if not compile it
    	// Also check to see if the timestamp on the template file is greater than the compiled file. If it is then we need to rebuild
    	if(!$this->_isCompiled($sFileName) || (filemtime($sCompiledFile) < filemtime($this->_getTemplatePath($sFileName)))) {
    		$this->_compileFile($sFileName);
    	}
    
    	ob_start();
    	include($sCompiledFile);
    	$output = ob_get_contents();
    	ob_end_clean();
    
    	return $output;
    }
    
    function _isCompiled($sFileName) {
    	return file_exists($this->_getCompiledPath($sFileName));
    }
    
    function _compiledFileName($sFileName) {
    	return 'c_'.md5($this->sTemplateDir.'/'.$sFileName).'.php';
    }
    
    function _compileFile($sFile) {
    	$sFilePath = $this->_getTemplatePath($sFile);
    	$iFileSize = filesize($sFilePath);
    
    	if($iFileSize) {
    		// Open the source template file for reading
    		$fp = fopen($sFilePath,"r");
    
    		// Open the compiled file for writing
    		$fpC = fopen($this->_getCompiledPath($sFile),"w");
    
    		if($fp && $fpC) {
    			$sContents = fread($fp,$iFileSize);
    
    			// Write the compiled template
    			fwrite($fpC,$this->_compileContents($sContents));
    
    			// Close the files
    			fclose($fp);
    			fclose($fpC);
    		}
    	}
    }
    
    function _compileContents($sFileContents) {
    	// Replace the template variables with the required PHP code...
    	/*return preg_replace("!{$this->sStartDelim}(.*?){$this->sEndDelim}!i","<?php echo \$this->_aVars['\\1']; ?>",$sFileContents);*/
    	//  \$(\S[\w]*\S)\$
    	// (\S[\w]+\-?[\w]*\S)
    	// (\S[\w]+\-?.+\S)
    
    	//([a-zA-Z0-9_\-]{1,})
    	//(\S[\w]+\-?[\w]*\S)
    
    	//\$(\S*?)\$
    	// Has problems with <a href='index.php?do=rate&act=profile&id=$RateViewProfileUserId$&op=block'>$RateViewProfileBlockOrUnblockUser$</a>
    	// But no problems in regex coach?!?!?!
    
    	//([a-zA-Z0-9_\-]{1,})
    	// best so far...
    
    	return preg_replace("!{$this->sStartDelim}([a-zA-Z0-9_\-]{1,}){$this->sEndDelim}!iU","<?php echo \$this->_aVars['\\1']; ?>",$sFileContents);
    }
    }
    
    
    $aTemplateFileList = array(
    				"index"			=> "index.tpl",
    				"captchaImage"	=>	"captcha_image.tpl",
    
    				'errorTable'	=>	'error_message.tpl',
    
    				"activeMembers-Default"	=> "activemembers/default.tpl",
    				"activeMembers-DefaultEach"	=> "activemembers/default_each.tpl",
    
            			"joinEmail"			=> "join_email.tpl",
            			"referralEmail"			=> "referral_email.tpl",
            			"refresh"			=> "refresh.tpl",
            			"register"			=> "register.tpl",
            			"report"			=> "report.tpl",
            			"refresh"			=> "refresh.tpl",
            			"register"			=> "register.tpl",
            			"contact"			=> "contact.tpl",
    
            			"rate-RatingBars"							=>	"rate/rating_bars.tpl",
    
            			"sideTopNewEach"			=> "side_top_new_each.tpl",
    
            			"controlPanel-DeleteAccountDefault"		=>	"controlpanel/deleteaccount/default.tpl",
    
            			"controlPanel-NavBar"		=> "controlpanel/member_navbar.tpl",
    
            			"controlPanel-MyBlockListAdd"	=>	"controlpanel/myblocklist/add.tpl",
            			"controlPanel-MyBlockListDefault"	=>	"controlpanel/myblocklist/default.tpl",
            			"controlPanel-MyBlockListDefaultEach"	=>	"controlpanel/myblocklist/default_each.tpl",
            			"controlPanel-MyBlockListDelete"	=>	"controlpanel/myblocklist/delete.tpl",
    
            			"controlPanel-MyCommentsNew"	=> "controlpanel/mycomments/new.tpl",
            			"controlPanel-MyCommentsDelete"	=> "controlpanel/mycomments/delete.tpl",
            			"controlPanel-MyCommentsDefault"	=> "controlpanel/mycomments/default.tpl",
            			"controlPanel-MyCommentsDefaultEach"	=> "controlpanel/mycomments/default_each.tpl",
    
            			"controlPanel-MyProfile"		=> "controlpanel/myprofile.tpl",
    
            			"controlPanel-MyPicturesDefault"	=> "controlpanel/mypictures/default.tpl",
            			"controlPanel-MyPicturesDefaultPhotoEach"	=> "controlpanel/mypictures/default_photo_each.tpl",
            			"controlPanel-MyPicturesDefaultPhotoRowEach"	=> "controlpanel/mypictures/default_photo_row_each.tpl",
            			"controlPanel-MyPicturesDelete"	=> "controlpanel/mypictures/delete.tpl",
            			"controlPanel-MyPicturesReset"	=> "controlpanel/mypictures/reset.tpl",
    
            			"controlPanel-MyStatsReset"		=> "controlpanel/mystats/reset.tpl",
            			"controlPanel-MyStatsDefault"		=> "controlpanel/mystats/default.tpl",
            			"controlPanel-MyStatsDefaultVotesEach"		=> "controlpanel/mystats/default_votes_each.tpl",
            			"controlPanel-MyStatsProfileViewsDefault"		=> "controlpanel/mystats/profile_views_default.tpl",
            			"controlPanel-MyStatsProfileViewsDefaultEach"		=> "controlpanel/mystats/profile_views_default_each.tpl",
    
            			"controlPanel-PMSDelete"			=> "controlpanel/pms/delete.tpl",
            			"controlPanel-PMSDefault"			=> "controlpanel/pms/default.tpl",
            			"controlPanel-PMSDefaultEach"		=> "controlpanel/pms/default_each.tpl",
            			"controlPanel-PMSSend"			=> "controlpanel/pms/send.tpl",
            			"controlPanel-PMSRead"			=> "controlpanel/pms/read.tpl",
            			"controlPanel-PMSReadMessagesEach"		=> "controlpanel/pms/read_messages_each.tpl",
            			"controlPanel-PMSMassDelete"			=> "controlpanel/pms/mass_delete.tpl",
    
            			"controlPanel-Email"			=> "controlpanel/email.tpl",
    
            			"login-SideLogin"				=> "login/side_login.tpl",
            			"login-Default"			=> "login/default.tpl",
            			"login-ForgotPassword"	=> "login/forgot_password.tpl",
    
            			"main-Default"			=> "main/default.tpl",
            			"main-NewsDefault"			=> "main/news_default.tpl",
            			"main-NewsEach"			=> "main/news_each.tpl",
            			"main-FeaturedUser"			=> "main/featured_user.tpl",
            			"main-RecentCommentsEach"			=> "main/recent_comments_each.tpl",
            			"main-RecentUploadsEach"			=> "main/recent_uploads_each.tpl",
    
    
            			"rate-PreviousPhoto"					=> "rate/previous_photo.tpl",
    
    
            			"controlPanel-MyPicturesDefaultGalleriesRowEach"	=> "controlpanel/mypictures/default_galleries_row_each.tpl",
    											"controlPanel-MyPicturesDefaultGalleriesEach"		=> "controlpanel/mypictures/default_galleries_each.tpl",
    											"controlPanel-MyPicturesViewGalleryDefault"		=> "controlpanel/mypictures/view_gallery_default.tpl",
    
    											"controlPanel-MyPicturesGalleryEdit"		=> "controlpanel/mypictures/gallery_edit.tpl",
    											"controlPanel-MyPicturesGalleryDelete"		=> "controlpanel/mypictures/gallery_delete.tpl",
    											"controlpanel-MyPicturesGalleryEditPrivateUsersEach"	=>	"controlpanel/mypictures/gallery_edit_private_users_each.tpl",
    											"controlPanel-MyPicturesGalleryAddUser" => "controlpanel/mypictures/gallery_add_user.tpl",
    											"controlPanel-MyPicturesGalleryDeleteUser" => "controlpanel/mypictures/gallery_delete_user.tpl",
    
    											"controlPanel-MyVideosDefault"	=> "controlpanel/myvideos/default.tpl",
    						        			"controlPanel-MyVideosDefaultVideoEach"	=> "controlpanel/myvideos/default_video_each.tpl",
    						        			"controlPanel-MyVideosDefaultVideoRowEach"	=> "controlpanel/myvideos/default_video_row_each.tpl",
    						        			"controlPanel-MyVideosDelete"	=> "controlpanel/myvideos/delete.tpl",
    
            										"main-RecentUploadsVideosEach"		=> "main/recent_uploads_videos_each.tpl",
    						        	);
    ?>

     

    anyone please help to get me the template file to show

     

  6. and here is mysql.class.inc file just to show the mysql functions

    <?php
    
    if(!defined("IN_MIPHOTO")) {
    trigger_error("Unable to process {$HTTP_SERVER_VARS['PHP_SELF']}", E_USER_ERROR);
    }
    
    if(!defined('MIPHOTO_INSTALL'))
    define('MIPHOTO_INSTALL',0,true);
    
    $sAct2 = isset($HTTP_GET_VARS['act']) ? stripslashes($HTTP_GET_VARS['act']) : "";
    
    if($sAct2 == "goinstall" || MIPHOTO_INSTALL)
    @include_once(dirname(__FILE__)."/config.php");
    else
    require_once(dirname(__FILE__)."/config.php");
    
    
    
    if(!defined('MYSQL_PCONNNECT'))
    define('MYSQL_PCONNNECT',0,true);
    
    if(!defined('MYSQL_CHARACTER_SET'))
    define('MYSQL_CHARACTER_SET','utf8');
    
    define('MYSQL_NO_QUOTES_ESCAPE_CHARACTERS','&~^@()A');
    define('MYSQL_USE_MYSQLI',function_exists('mysqli_connect'));
    
    
    require_once(dirname(__FILE__)."/globals.php");
    
    /*
    Returns an Array
    
    Array ('thekey' => '','thevalue' => '','language_id' => '')
    */
    
    function returnConfigTableFields($sKey, $sValue = "", $iLanguageId = 0) {
    return array('thekey' => $sKey, 'thevalue' => $sValue, 'language_id' => $iLanguageId);
    }
    
    
    class cMySQLDB {
    var $conn;
    var $oDb;
    var $sDatabaseName;
    
    var $sCurrentDB;
    
    var $sServer;
    var $sPort;
    var $sUsername;
    var $sPassword;
    var $sTablePrefix;
    var $iNumQueries;
    var $iSelectQueries;
    var $aQueries;
    var $db_version;
    
    var $aQueriesPerTable;
    
    function cMySQLDB($sServer,$sPort,$sUsername,$sPassword,$sDatabaseName,$sTablePrefix) {
    	$this->sDatabaseName = $sDatabaseName;
    	$this->sServer = $sServer;
    	$this->sPort = $sPort;
    	$this->sUsername = $sUsername;
    	$this->sPassword = $sPassword;
    	$this->sTablePrefix = $sTablePrefix;
    	$this->iNumQueries = $this->iSelectQueries = 0;
    }
    
    function connect($bHideError = false, $bInstall = false, $bNewLink = false, $bDie = true) {
            if(MYSQL_USE_MYSQLI) {
            	if($bInstall) {
                	$this->conn = @mysqli_connect($this->sServer,$this->sUsername,$this->sPassword,"",$this->sPort) or reportError($this,"",$bHideError,true,$bDie);
            	} else {
    	        $this->conn = @mysqli_connect($this->sServer,$this->sUsername,$this->sPassword,$this->sDatabaseName,$this->sPort) or reportError($this,"",$bHideError,true,$bDie);
    	        $this->sCurrentDB = $sDatabaseName;
            	}
            } else {
            	if(MYSQL_PCONNNECT) {
            		$this->conn = @mysql_pconnect($this->sServer.":".$this->sPort,$this->sUsername,$this->sPassword) or reportError($this,"",$bHideError,true,$bDie);
            	} else {
    			$this->conn = @mysql_connect($this->sServer.":".$this->sPort,$this->sUsername,$this->sPassword,$bNewLink) or reportError($this,"",$bHideError,true,$bDie);
            	}
            }
    
    
    	$aMySQLVersion = $this->version();
    
    	if($aMySQLVersion[0] >= 5) {
    		// to prevent MySQL 5 strict errors with inputed data and create tables
    		$this->query("SET SQL_MODE = 'MYSQL40'",false,true);
    	}
    	if((($aMySQLVersion[0] == 4 && $aMySQLVersion[1] >= 1) || ($aMySQLVersion[0] >= 5)) && !CUSTOM_ROBERT_281) {
    		if(defined('MYSQL_CHARACTER_SET')) {
    			if(MYSQL_CHARACTER_SET != '') {
    				$this->query("SET NAMES '".MYSQL_CHARACTER_SET."'",false,true);
    			//$this->query("SET SQL_MODE='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'",false,true);
    			//$this->query("SET @@character_set_server=".MYSQL_CHARACTER_SET,false,true);
    			}
    		}
    	}
    
    	$this->iNumQueries = $this->iSelectQueries = 0;
    
            return $this->conn;
    }
    
    function disconnect() {
            if(MYSQL_USE_MYSQLI)
            @mysqli_close($this->conn);
            else
    		@mysql_close($this->conn);
    
    	$this->conn = NULL;
    }
    
    /*
    // NOT IMPLEMENTED BECAUSE YOU GO THE OPERATORS - AND,OR,XOR,>=,<,etc
    function delete($sTable,$aWhere) {
    	global $gGlobals;
    
    	if(empty($sTable) || gettype($aWhere) != "array" || sizeof($aWhere) < 1)
    		return 0;
    
    	$sWhere = "";
    
    	foreach($aWhere as $sField => $sFieldValue)
    		$sWhere .= "{$sField}=".((substr($sFieldValue,0,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)) == MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)?"(".substr($sFieldValue,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)).")":"'".$this->escape($sFieldValue)."'").", ";
    
    	$sWhere = @substr($sWhere,0,-2);
    
    	return $this->query("DELETE FROM {$this->sTablePrefix}_{$sTable}".((!empty($sWhere))?" WHERE {$sWhere}":""));
    }
    */
    function delete($sTable,$sWhere,$sOther = "") {
    	global $gGlobals;
    
    	if(empty($sTable))
    		return 0;
    
    	return $this->query("DELETE FROM {$this->sTablePrefix}_{$sTable}".((!empty($sWhere))?" WHERE {$sWhere}":"")." {$sOther}");
    }
    
    
    function insert($sTable, $aFields, $sOther = "", $bQuiet = false) {
    	global $gGlobals;
    	if(empty($sTable) || gettype($aFields) != "array" || sizeof($aFields) < 1)
    		return 0;
    
    	$sFields = $sFieldsValues = "";
    
    	foreach($aFields as $sField => $sFieldValue) {
    		$sFields .= "{$sField}, ";
    		$sFieldsValues .= ((substr($sFieldValue,0,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)) == MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)?"(".substr($sFieldValue,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)).")":"'".$this->escape($sFieldValue)."'").", ";
    	}
    
    	$sFields = substr($sFields,0,-2);
    	$sFieldsValues = substr($sFieldsValues,0,-2);
    
    	return $this->query("INSERT INTO {$this->sTablePrefix}_{$sTable} ({$sFields}) VALUES ({$sFieldsValues}) {$sOther}",!$bQuiet,$bQuiet);
    }
    
    function update($sTable,$aFields,$sWhere = "", $sOptions = "") {
    	global $gGlobals;
    	if(empty($sTable) || gettype($aFields) != "array" || sizeof($aFields) < 1)
    		return 0;
    
    	$sFields = "";
    
    	foreach($aFields as $sField => $sFieldValue)
    		$sFields .= "`{$sField}`=".((substr($sFieldValue,0,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)) == MYSQL_NO_QUOTES_ESCAPE_CHARACTERS) ? "(".substr($sFieldValue,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)).")" : "'".$this->escape($sFieldValue)."'").", ";
    
    	$sFields = substr($sFields,0,-2);
    
    	return $this->query("UPDATE `{$this->sTablePrefix}_{$sTable}` SET {$sFields}".((!empty($sWhere))?" WHERE {$sWhere}":"")." {$sOptions}");
    }
    
        function escape($sStr) {
        	global $gGlobals;
            if(MYSQL_USE_MYSQLI)
            	return mysqli_real_escape_string ($this->conn,$sStr);
            else
            	return mysql_real_escape_string($sStr,$this->conn);
        }
    
        function affectedRows() {
        	global $gGlobals;
        	if(MYSQL_USE_MYSQLI)
        		return @mysqli_affected_rows($this->conn);
        	else
        		return @mysql_affected_rows($this->conn);
        }
    
    function selectdb($sTablePrefix = "", $sDatabase = "") {
        global $gGlobals;
    
        if(empty($sDatabase))
        	$sDatabase = $gGlobals['database']['name'];
    
        if($sDatabase == $this->sCurrentDB)
        	return;
    
        $this->sTablePrefix = $sTablePrefix;
    
        if(empty($sTablePrefix))
        	$this->sTablePrefix = $gGlobals['database']['prefix'];
    
            if(MYSQL_USE_MYSQLI)
            @mysqli_select_db($this->conn,$sDatabase) or reportError($this);
            else
    		@mysql_select_db($sDatabase,$this->conn) or reportError($this);
    	$this->sDatabaseName = $sDatabase;
    }
    
    function query($str, $bDie = true, $bHideError = false) {
        global $gGlobals;
    
    	if(empty($str))
    		return 0;
            if(MYSQL_USE_MYSQLI) {
            $result = mysqli_query($this->conn,$str) or reportError($this,$str,$bHideError,false,$bDie);
            } else {
    		$result = mysql_query($str,$this->conn) or reportError($this,$str,$bHideError,false,$bDie);
            }
    
    	if(MIPHOTO_DEV) {
    		$this->iNumQueries++;
    		$this->aQueries[] = $str;
    	}
    
    	return ($result);
    }
    
    function alterTable($sTable, $sParams) {
    	$sQuery = "ALTER TABLE {$this->sTablePrefix}_{$sTable} {$sParams}";
    
    	return $this->query($sQuery);
    }
    
    function select($sWhat,$table,$params="",$order="") {
        	global $gGlobals;
    
    	if(empty($sWhat)||empty($table))
    		return 0;
    
    	if(!empty($params))
    		$params = " WHERE ".$params;
    
    	$sQuery = "SELECT {$sWhat} FROM {$this->sTablePrefix}_{$table}{$params} {$order}";
    
    	if(MIPHOTO_DEV) {
    		$this->iSelectQueries++;
    		$this->aQueriesPerTable[$table]++;
    	}
    
    	return $this->query($sQuery);
    }
    
    function selectMultiple($aArray,$params="",$order="", $bCountOnly = false /*, $bEcho = false */) {
    	/*
    
    		format of array for $aArray parameter
    
    		$aArray = Array(
    							Array(
    									'table'	=>	The table name
    									'alias'	=>	The alias for the table
    									'select'	=>	Array( What to select from this table )
    								)
    							...
    						)
    	*/
    
    
        	global $gGlobals;
    
        	$sTables = $sSelect = "";
    
        	$bMore = true;
    
        	if(!is_array($aArray))
        		return 0;
    
        	foreach($aArray as $aTable) {
        		if(empty($aTable['table']) || empty($aTable['alias']))
        			return 0;
    
    		$sTables .= "{$this->sTablePrefix}_{$aTable['table']} AS {$aTable['alias']}";
    
    		if(isset($aTable['useindex']) && !empty($aTable['useindex'])) {
    			$sTables .= " USE INDEX ({$aTable['useindex']})";
    		}
    
    		$sTables .= ",";
    
    		if(MIPHOTO_DEV) {
    			$this->aQueriesPerTable[$aTable['table']]++;
    		}
    
    		if(!is_array($aTable['select'])) {
    			// The select is a string, not an array
    			// Lets parse the select string into an array
    			$aTable['select'] = explode(",",$aTable['select']);
    		}
    
    		foreach($aTable['select'] as $sTableSelect) {
    			if(!$bMore)
    				continue;
    			if($sTableSelect == "COUNT(*)" || $sTableSelect == "COUNT(id)" || $bCountOnly) {
    				$sSelect .= "COUNT(*),";
    				$bMore = false;
    			} elseif(!$bCountOnly) {
    				$sSelect .= "{$aTable['alias']}.{$sTableSelect},";
    			}
    
    		}
        	}
    
        	$sTables = substr($sTables,0,-1);
        	$sSelect = substr($sSelect,0,-1);
    
    	if(empty($sSelect) || empty($sTables))
    		return 0;
    	if(!empty($params))
    		$params = " WHERE ".$params;
    
    	$sQuery = "SELECT {$sSelect} FROM {$sTables} {$params} {$order}";
    
    	if(MIPHOTO_DEV) {
    		$this->iSelectQueries++;
    	}
    /*
    	if($bEcho)
    		echo $sQuery;
    */
    
    	return ($this->query($sQuery));
    }
    
    function getRow($result,$bFreeResult = false) {
            global $gGlobals;
        if(MYSQL_USE_MYSQLI) {
        	$sReturn = @mysqli_fetch_array($result,MYSQLI_ASSOC);
        } else {
    		$sReturn = @mysql_fetch_array($result,MYSQL_ASSOC);
            }
    
            if($bFreeResult) {
            	$this->freeResult($result);
            }
    
            return $sReturn;
    }
    
        function getResult($result,$offset=0) {
            global $gGlobals;
        if(MYSQL_USE_MYSQLI) {
            @mysqli_data_seek($result,$offset);
                $row = @mysqli_fetch_row($result);
                $this->freeResult($result);
            return $row[0];
            } else {
        	$sReturn = @mysql_result($result,$offset);
    
        	$this->freeResult($result);
        	return $sReturn;
            }
        }
    
        function setRowSeek($rResult, $iRow) {
        	if(MYSQL_USE_MYSQLI) {
        		return mysqli_data_seek($rResult,$iRow);
        	} else {
        		return mysql_data_seek($rResult,$iRow);
        	}
        }
    
    function getRowCount($result) {
            global $gGlobals;
        if(MYSQL_USE_MYSQLI)
            return @mysqli_num_rows($result);
            else
    		return @mysql_num_rows($result);
    }
    
    function freeResult($result) {
            global $gGlobals;
        	if(MYSQL_USE_MYSQLI)
            return @mysqli_free_result($result);
            else
    		return @mysql_free_result($result);
    }
    
    function getInsertId() {
            global $gGlobals;
            if(MYSQL_USE_MYSQLI)
            return @mysqli_insert_id($this->conn);
            else
    		return @mysql_insert_id($this->conn);
    }
    
    function version($bArray = true) {
    	global $gGlobals;
    
    	if(!empty($this->db_version)) {
    		return $this->db_version;
    	}
    
    	if(MYSQL_USE_MYSQLI)
    		$this->db_version = @mysqli_get_server_info($this->conn);
    	else
    		$this->db_version = @mysql_get_server_info($this->conn);
    
    	if($bArray)
    		return explode(".",$this->db_version);
    
    	return $this->db_version;
    }
    
    function getErrorNumber($bOnConnect = false) {
    	global $gGlobals;
    	if(MYSQL_USE_MYSQLI) {
    		if($bOnConnect) {
    			return mysqli_connect_errno($this->conn);
    		} else {
    			return mysqli_errno($this->conn);
    		}
    	} else {
    		if($this->conn)
    			return mysql_errno($this->conn);
    		else
    			return mysql_errno();
    	}
    }
    
    function getErrorMessage($bOnConnect = false) {
    	global $gGlobals;
    	if(MYSQL_USE_MYSQLI) {
    		if($bOnConnect) {
    			return mysqli_connect_error();
    		} else {
    			return mysqli_error($this->conn);
    		}
    	} else {
    		if($this->conn)
    			return mysql_error($this->conn);
    		else
    			return mysql_error();
    	}
    }
    
    function getDefaultTimeStamp() {
    	$aMySQLVersion = $this->version(true);
    
    	// See if version is >= 4.1.2
    	if(($aMySQLVersion[0] == 4 && $aMySQLVersion[1] >= 1 && $aMySQLVersion[2] >= 2) || ($aMySQLVersion[0] >= 5)) {
    		//$sDefaultCurrentTimeStamp = " DEFAULT '0'";
    		$sDefaultCurrentTimeStamp = "";
    		$sDefaultCurrentTimeStampOnUpdate = " DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP";
    	}
    	elseif($aMySQLVersion[0] == 4 && $aMySQLVersion[1] == 0 && $aMySQLVersion[2] == 17) {
    		// This version seems to only work with this...
    		$sDefaultCurrentTimeStamp = $sDefaultCurrentTimeStampOnUpdate = "";
    	} else {
    		$sDefaultCurrentTimeStamp = $sDefaultCurrentTimeStampOnUpdate = " DEFAULT 0";
    	}
    
    	return array('current_timestamp' => $sDefaultCurrentTimeStamp, 'on_update' => $sDefaultCurrentTimeStampOnUpdate);
    }
    }
    
    function reportError($oDb, $sQuery = "", $bHideError = false, $bOnConnect = false, $bDie = true) {
        if(!$bHideError) {
        echo "<table><tr><th>Error: ";
    
        echo $oDb->getErrorNumber($bOnConnect);
    
        echo "</th></tr><tr><td class='col2'>";
    
        echo $oDb->getErrorMessage($bOnConnect);
    
        echo "</th></tr><tr><td>{$sQuery}</td></tr></table>";
        }
    
        if($bDie) {
        if($oDb->conn)
    		$oDb->disconnect();
    	die();
        }
    }
    
    ?>

  7. I'm talking about: $oDb->select() method.

    well I looked to my index.php where it shows what those methods do and here it is

    <?php
    
    //=======================================
    //###################################
    //
    //
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //###################################
    //=======================================
    
    define('IN_MIPHOTO',true);
    
    require_once(dirname(__FILE__)."/include/functions.php");
    
    $oLog->logEvent(__FILE__,__LINE__,"Include all files");
    
    $sDo = initVar('do');
    
    // Initialize Db class
    $oDb = new cMySQLDB($gGlobals['database']['server'],$gGlobals['database']['port'],$gGlobals['database']['user'],$gGlobals['database']['password'],$gGlobals['database']['name'],$gGlobals['database']['prefix']);
    
    // Initiate Plugin Classes
    $cPlugins = new cMicroScriptsPluginServer;
    $cDummyPluginClient = new cMicroScriptsPluginClient;
    
    $oLog->logEvent(__FILE__,__LINE__,"Create database, plugin objects");
    
    $oDb->connect();
    $oDb->selectdb();
    
    $oCache = new cMicroCache();
    $oCache->loadCache(CACHE_CONFIG_TABLE,false);
    $oCache->loadCache(CACHE_COUNTRIES_TABLE,false);
    $oCache->loadCache(CACHE_PROFILE_TABLE,false);
    $oCache->loadCache(CACHE_CATEGORIES_TABLE,false);
    $oCache->loadCache(CACHE_PLUGINS_TABLE,false);
    $oCache->loadCache(CACHE_LANGUAGES_TABLE,false);
    
    // Lets do a database version check to make sure this version of the script is the same as what is in the database...
    $sDatabaseVersion = strtolower(trim(getConfig('version',0)));
    if($sDatabaseVersion != MIPHOTO_VERSION) {
    $sError = "This version (".MIPHOTO_VERSION.") is not compatible with the version in the database ({$sDatabaseVersion}).";
    
    if(!@ini_get('display_errors')) {
    	echo $sError;
    }
    trigger_error($sError, E_USER_ERROR);
    }
    
    if(MIPHOTO_FEATURE_PHOTO_DETAILS) {
    $oCache->loadCache(CACHE_PHOTO_FIELDS_TABLE,false);
    }
    
    $oLog->logEvent(__FILE__,__LINE__,"Loaded cache files");
    
    if(!checkLicense()) {
    $oDb->disconnect();
    $oDb = NULL;
    exit;
    }
    
    $oLog->logEvent(__FILE__,__LINE__,"License Check");
    
    $bLoad = true;
    
    if((int)getConfig('topnew_update_timestamp',0) <= time()) {
    $__IN_CLIENT = 1;
    
    require_once(dirname(__FILE__)."/".ADMIN_DIR."/admin.functions.php");
    // Rebuild the top users/photos/videos cache
    rebuildTopUsersCache(false,false,false);
    
    // Rebuild the new users/photos/videos cache
    rebuildTopUsersCache(true);
    
    $bLoad = false;
    }
    
    if($bLoad) {
    $oCache->loadCache(CACHE_TOP_USERS,false);
    
    if(MIPHOTO_FEATURES_SIDE_NEW_MEMBERS) {
    	$oCache->loadCache(CACHE_NEW_USERS,false);
    }
    }
    
    $oLog->logEvent(__FILE__,__LINE__,"Load TOP/NEW cache");
    
    if(MIPHOTO_FEATURE_IMAGE2FTP)
    $oCache->loadCache(CACHE_IMAGE2FTP_TABLE,false);
    
    $gGlobals['datetime']['servertimezone'] = intval(getConfig('servertimezone',0));
    $gGlobals['maxresultsperpage'] = intval(getConfig('maxresultsperpage',0));
    $gGlobals['topnumber'] = intval(getConfig('topnumber',0));
    $gGlobals['rating']['graphic'] = intval(getConfig('graphicrating',0));
    $gGlobals['images']['imagefilepath'] = getConfig('photofilepath',0);
    $gGlobals['sidetop'] = intval(getConfig('sidetop',0));
    $gGlobals['rating']['type'] = intval(getConfig('rateusersorphotos',0));
    //$gGlobals['allowhtmlcode'] = intval(getConfig('allowmembershtmlinfields',0));
    $gGlobals['allowhtmlcode'] = FEATURE_FCKEDITOR ? 1 : intval(getConfig('allowmembershtmlinfields',0));
    
    $gGlobals['agelimits']['maxage'] = intval(getConfig('maxage',0));
    $gGlobals['agelimits']['minage'] = intval(getConfig('minage',0));
    $gGlobals['wraptext']['profile'] = intval(getConfig('wraptext_profile',0));
    $gGlobals['wraptext']['other'] = intval(getConfig('wraptext_other',0));
    
    if($gGlobals['use_sessions']) {
    // Set the cookie lifetime to 30 days for sessions
    // For just cookies this is done in content/login.php
    if(initVar('remember_login',HTTP_POST,true,0)) {
    	//@ini_set('session.use_cookies','1');
    	//@ini_set('session.use_only_cookies','1');
    	//@ini_set('session.use_trans_sid','0');
    	session_set_cookie_params(1296000);
    }
    
    session_name($gGlobals['cookieprefix']);
    
    if(!session_id())
    	session_start();
    
    if(isset($_SESSION['sessionlast'])) {
    	$gGlobals['user']['session_last'] = $_SESSION['sessionlast'];
    }
    } else {
    if(isset($_COOKIE[$gGlobals['cookieprefix'].'sessionlast'])) {
    	$gGlobals['user']['session_last'] = $_COOKIE[$gGlobals['cookieprefix'].'sessionlast'];
    }
    }
    
    $gGlobals['user']['loggedin'] = ( ($sDo=='logout') ? 0 : verifyCookie() );
    if($gGlobals['user']['loggedin']) {
    $gGlobals['user']['id'] = getUserId();
        $gGlobals['user']['name'] = getUserName();
        $aData = $oDb->getRow($oDb->select("email,timezone,language_id","users","id='".$oDb->escape($gGlobals['user']['id'])."'"));
    $gGlobals['user']['timezone'] = $aData['timezone'];
    $gGlobals['user']['premier'] = isUserPremier();
    $gGlobals['user']['language']['id'] = $aData['language_id'];
    
    // Only will work with new definition table
    //$oDb->query("INSERT INTO {$gGlobals['database']['prefix']}_users_ip_addresses (added,user_id,ip_address) VALUES (NOW(),'".$oDb->escape($gGlobals['user']['id'])."','".$oDb->escape($gGlobals['user']['ipaddress'])."') ON DUPLICATE KEY UPDATE updated=NOW()");
    if($oDb->getResult($oDb->select("COUNT(*)","users_ip_addresses","user_id='".$oDb->escape($gGlobals['user']['id'])."' AND ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'")) < 1) {
    	$oDb->query("INSERT INTO {$gGlobals['database']['prefix']}_users_ip_addresses (added,user_id,ip_address) VALUES (NOW(),'".$oDb->escape($gGlobals['user']['id'])."','".$oDb->escape($gGlobals['user']['ipaddress'])."')");
    } else {
    	// Do a query to update the updated timestamp?
    	// Or maybe start counting the number of times the site is accessed by a certain IP address
    }
    
    if($oDb->getResult($oDb->select("COUNT(*)","bans","ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'".(!empty($aData['email']) ? " OR email LIKE '".$oDb->escape($aData['email'])."'" : "").(!empty($gGlobals['user']['name']) ? " OR username LIKE '".$oDb->escape($gGlobals['user']['name'])."'" : ""),"LIMIT 1")) > 0) {
    	$oDb->disconnect();
    	Header("HTTP/1.1 404 Not Found");
    	exit;
    }
    } else {
    if($oDb->getResult($oDb->select("COUNT(*)","bans","ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'","LIMIT 1")) > 0) {
    	$oDb->disconnect();
    	Header("HTTP/1.1 404 Not Found");
    	exit;
    }
    }
    
    // See if the user has attempted to change language via the change language form
    $iLanguage = initVar('language',HTTP_POST,true,0);
    
    // or by the URL
    if(initVar('changelanguage',HTTP_GET,true,0) == '1' && empty($iLanguage))
    $iLanguage = initVar('language',HTTP_GET,true,0);
    
    if(empty($gGlobals['user']['language']['id']) || !empty($iLanguage)) {
    if($gGlobals['use_sessions'])
    	$gGlobals['user']['language']['id'] = base64_decode($_SESSION['language']);
    else {
    	if(isset($_COOKIE[$gGlobals['cookieprefix'].'language'])) {
    		$gGlobals['user']['language']['id'] = base64_decode($_COOKIE[$gGlobals['cookieprefix'].'language']);
    	}
    }
    
    if(!empty($iLanguage)) {
    	if($gGlobals['use_sessions'])
    		$_SESSION['language'] = base64_encode($iLanguage);
    	else
    		setcookie($gGlobals['cookieprefix']."language",base64_encode($iLanguage),time()+1296000,'/');
    		//setcookie($gGlobals['cookieprefix']."language",base64_encode($iLanguage),time()+1296000,'/','.'.getConfig('siteaddress',0));
    
    	$gGlobals['user']['language']['id'] = $iLanguage;
    }
    
    if($gGlobals['user']['loggedin'])
    	$oDb->update("users",array('language_id'	=>	$gGlobals['user']['language']['id']),"id='".$oDb->escape(getUserId())."'");
    }
    
    // We still don't have a language ID, so attempt to detect the language based off the user's browser information
    if(empty($gGlobals['user']['language']['id'])) {
    $aAcceptLanguage = explode(";",$HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']);
    $aCharacterCodes = explode(",",$aAcceptLanguage[0]);
    
    $sWhere = "enabled=1";
    
    if(sizeof($aCharacterCodes)) {
    	// Remember to clean up the input before putting it in SQL query!!!
    	$aCharacterCodes = array_map("mysql_escape_string",$aCharacterCodes);
    	$sWhere .= " AND character_code IN ('".implode("','",$aCharacterCodes)."')";
    }
    
    $gGlobals['user']['language']['id'] = $oDb->getResult($oDb->select("id","languages",$sWhere,"LIMIT 1"));
    }
    
    $gGlobals['html_directory'] = getHTMLDirectoryWithLanguage();
    
    $gGlobals['datetime']['format'] = getConfig('dateformat');
    $gGlobals['datetime']['dateformat'] = getConfig('dateonlyformat');
    
    $gGlobals['onlinestatustext'] = getConfig('useronlinestatustext');
    $gGlobals['offlinestatustext'] = getConfig('userofflinestatustext');
    $gGlobals['rating']['nonetext'] = getConfig('nonetext');
    $gGlobals['rating']['imagepath'] = "html_{$gGlobals['user']['language']['id']}/images/rank";
    
    
    $oTpl = new cMiTemplate($gGlobals['html_directory']);
    $oTpl->assign('HTMLDirectory',$gGlobals['html_directory'],false);
    $oTpl->assign('UserName',getUserName());
    $oTpl->assign('UserLoggedIn',$gGlobals['user']['loggedin']);
    $oTpl->define($aTemplateFileList);
    
    $oCustoms->runCustoms(FILE_INDEX,4);
    
    if($gGlobals['user']['loggedin'] == -2) {
    $oTpl->assign('Content',getConfig('errorprofilenotapproved'),false);
    }
    elseif($gGlobals['user']['loggedin'] == -1) {
    $oTpl->assign('Content',getConfig('erroraccountsuspended'),false);
    }
    
    if(!getConfig('siteactive',0)) {
    echo getFile("maintenance");
    $oDb->disconnect();
    $oDb = NULL;
    exit;
    }
    
    $oDb->query("UPDATE {$gGlobals['database']['prefix']}_config SET thevalue=(thevalue+1) WHERE thekey='counter'");
    
    // Load only the Plugins that the admin wants loaded
    $aPlugins = $oCache->aCache[CACHE_PLUGINS_TABLE];
    if(!is_array($aPlugins))
    $aPlugins = array();
    foreach($aPlugins as $iId => $sFileName) {
    $cPlugins->loadPlugin($sFileName);
    }
    
    $gGlobals['user']['premier'] = isUserPremier();
    
    for($i=1;$i<=3;$i++) {
    $oTpl->assign('Advertisement'.$i,'',false);
    }
    
    // Call a function for the plugins to do needed operations before we get started
    $cPlugins->callPluginFunction(PLUGIN_FUNCTION_MAIN_START);
    
    // Code for managing active_user table
    $oDb->delete("activeusers","((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(laston)) >= '".$oDb->escape(ACTIVE_MEMBERS_INACTIVE_DELAY)."') OR ip='".$oDb->escape($gGlobals['user']['ipaddress'])."'".(($gGlobals['user']['loggedin'])?" OR user='".$oDb->escape($gGlobals['user']['id'])."'":""));
    $oDb->query("INSERT INTO {$gGlobals['database']['prefix']}_activeusers (user,ip,laston) VALUES ('".$oDb->escape($gGlobals['user']['id'])."','".$oDb->escape($gGlobals['user']['ipaddress'])."',NOW())");
    // End of code for active users
    
    $rResult = $oDb->select("user","activeusers","user!=0");
    while($aData = $oDb->getRow($rResult)) {
    $oCache->addValue(CACHE_ACTIVE_USERS_DATA,$aData['user'],$aData['user']);
    }
    $oDb->freeResult($rResult);
    
    $iUnreadPrivateMessages = 0;
    
    if($gGlobals['user']['loggedin']) {
    $iUnreadPrivateMessages = $oDb->getResult($oDb->select("COUNT(*)","pms USE INDEX (pms_new_msgs)","toid='".$oDb->escape($gGlobals['user']['id'])."' AND seen='0' AND todeleted='0'"));
    $oTpl->assign('ControlPanelMemberNavbarNewMessages',$iUnreadPrivateMessages,false);
    }
    
    $oTpl->assign("PMPopUp","");
    
    if(empty($sDo) && $iUnreadPrivateMessages > 0) {
    $sResult = $oDb->getResult($oDb->select("popuppm","users","id='".$oDb->escape($gGlobals['user']['id'])."'","LIMIT 1"));
    if($sResult == "1") {
        $oTpl->assign("PMPopUp","popUpPMSWin({$iUnreadPrivateMessages});");
    }
    }
    
    
    
    $sSiteAddress = getConfig('siteaddress',0);
    $oTpl->assign('SiteDomain',$sSiteAddress,false);
    $oTpl->assign('SiteAddress',$sSiteAddress,false);
    
    // Fill in stats vars
    $iActiveMembers = intval(@sizeof($oCache->aCache[CACHE_ACTIVE_USERS_DATA]));
    $iActiveVisitors = intval($oDb->getResult($oDb->select("COUNT(*)","activeusers","user='0'")));
    $oTpl->assign('TotalActiveUsers',$iActiveMembers + $iActiveVisitors,false);
    $oTpl->assign('MembersOnline',$iActiveMembers,false);
    $oTpl->assign('VisitorsOnline',$iActiveVisitors,false);
    $oTpl->assign('RegisteredMembers',getConfig('countmembers',0),false);
    $oTpl->assign('RatableMembers',getConfig('countmembersratable',0),false);
    $oTpl->assign('SubmittedPictures',getConfig('countphotos',0),false);
    $oTpl->assign('SubmittedVideos',getConfig('countvideos',0),false);
    $oTpl->assign('SitePageViews',getConfig('counter',0),false);
    
    $oTpl->assign('PhotoAlbums',getConfig('countphotoalbums',0),false);
    $oTpl->assign('PrivatePhotoAlbums',getConfig('countprivatephotoalbums',0),false);
    $oTpl->assign('TotalVotes',getConfig('counttotalvotes',0),false);
    $oTpl->assign('AverageRating',getConfig('countaveragerating',0),false);
    $oTpl->assign('AverageVotesPerUser',getConfig('countaveragevotes',0),false);
    $oTpl->assign('NewMembersToday',getConfig('countnewmemberstoday',0),false);
    $oTpl->assign('NewMembersYesterday',getConfig('countnewmembersyesterday',0),false);
    $oTpl->assign('NewMembersPastWeek',getConfig('countnewmemberspastweek',0),false);
    $oTpl->assign('NewMembersPastMonth',getConfig('countnewmemberspastmonth',0),false);
    $oTpl->assign('NewMembersPastYear',getConfig('countnewmemberspastyear',0),false);
    
    
    // Put out client IP Address
    $oTpl->assign('IPAddress',$gGlobals['user']['ipaddress'],false);
    $oTpl->assign('SiteTitle',getconfig('sitename'),false);
    
    // Metatag Stuff
    $oTpl->assign('MetatagTitle',getconfig('metatagstitle'),false);
    $oTpl->assign('MetatagName',getconfig('metatagsname'),false);
    $oTpl->assign('MetatagKeywords',getconfig('metatagskeywords'),false);
    $oTpl->assign('MetatagPictureKeywords',getconfig('metatagspicturekeywords'),false);
    $oTpl->assign('MetatagDescription',getconfig('metatagsdescription'),false);
    
    // Shit for return URL after login
    $gGlobals['returnurl'] = urlencode(initVar('returnurl'));
    if(empty($gGlobals['returnurl'])) {
    $gGlobals['returnurl'] = $HTTP_SERVER_VARS['PHP_SELF']."?";
    foreach($HTTP_GET_VARS as $getVar => $sGetVar) {
    	$sGetVar = stripslashes($sGetVar);
    	$gGlobals['returnurl'] .= "&{$getVar}={$sGetVar}";
    }
    $gGlobals['returnurl'] = urlencode($gGlobals['returnurl']);
    }
    $oTpl->assign('ReturnURL',$gGlobals['returnurl'],false);
    $oTpl->assign('ReturnURLNoEncode',urldecode($gGlobals['returnurl']),false);
    
    $sLanguageOptions = "";
    
    $aLanguages = $oCache->aCache[CACHE_LANGUAGES_TABLE];
    foreach($aLanguages as $iLanguageId => $sLanguageName) {
    $sLanguageOptions .= "<option value='{$iLanguageId}'".(($iLanguageId == $gGlobals['user']['language']['id'])?" selected":"").">{$sLanguageName}</option>";
    }
    $oTpl->assign('LanguageOptions',$sLanguageOptions,false);
    
    $oTpl->assign('CategoriesOptions',getCategoryListSelectBox(initVar('gender')),false);
    $oTpl->assign('DateYearOptions',getDateYearSelectBoxOptions(),false);
    $oTpl->assign('AgeOptions',getAgeSelectBoxOptions(),false);
    $oTpl->assign('ErrorMessage','',false);
    $oTpl->assign('ErrorMessageTable','',false);
    
    
    
    
    // Fill in the top number ranking
    if($oCustoms->runCustoms(FILE_INDEX,2)) {
    } else {
    $aCategories = $oCache->aCache[CACHE_CATEGORIES_TABLE];
    foreach($aCategories as $iId => $aCat) {
    	setTopNewTemplateVariables($iId);
    }
    }
    
    $oTpl->assign('SideLogin','',false);
    $outContent = "";
    if(!$gGlobals['user']['loggedin'] && $sDo != "login") {
    $gGlobals['showlogin'] = 1;
    $oTpl->parse('SideLogin','login-SideLogin');
    }
    
    // Code for previous photo
    $oTpl->assign('PreviousPhoto','',false);
    $iPreviousPhoto = initVar('prevphoto');
    
    if($iPreviousPhoto > 0) {
    if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    	$rResult = $oDb->select("rating,votes","users","id='".$oDb->escape($iPreviousPhoto)."'");
    }
    elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY) {
    	$rResult = $oDb->select("rating,votes","videos","id='".$oDb->escape($iPreviousPhoto)."'");
    }
    elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY) {
    	$rResult = $oDb->select("rating,votes","photos","id='".$oDb->escape($iPreviousPhoto)."'");
    }
    elseif($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS) {
    	if(initVar('v') == '1') {
    		$rResult = $oDb->select("rating,votes","videos","id='".$oDb->escape($iPreviousPhoto)."'");
    	} else {
    		$rResult = $oDb->select("rating,votes","photos","id='".$oDb->escape($iPreviousPhoto)."'");
    	}
    }
    
    if($oDb->getRowCount($rResult) > 0) {
    	$iRating = initVar('rating');
    	$aData = $oDb->getRow($rResult);
    
    	if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
    		$oTpl->assign('PreviousPhotoUserPhoto',getImageThumbnailLink(-1,false,THUMBNAIL_SIZE_PREVIOUSPHOTO,false,false,false,true,"",$iPreviousPhoto));
    	}
    	elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && initVar('v') != '1')) {
    		$oTpl->assign('PreviousPhotoUserPhoto',getImageThumbnailLink($iPreviousPhoto,false,THUMBNAIL_SIZE_PREVIOUSPHOTO));
    	}
    	elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && initVar('v') == '1')) {
    		$oTpl->assign('PreviousPhotoUserPhoto',getImageThumbnailLink($iPreviousPhoto,false,THUMBNAIL_SIZE_PREVIOUSPHOTO,false,false,true));
    	}
    
    
    	$oTpl->assign('PreviousPhotoUserAverageRating',formatRating($aData['rating'],$aData['votes'],0));
    	$oTpl->assign('PreviousPhotoUserYouRated',formatRating($iRating,1,0,false,false,false,false));
    	$oTpl->parse('PreviousPhoto','rate-PreviousPhoto');
    }
    $oDb->freeResult($rResult);
    }
    // End of code for previous photo
    
    
    $oCustoms->runCustoms(FILE_INDEX,1);
    
    
    $oTpl->assign('MemberNavBar','',false);
    $oTpl->assign('UserId','',false);
    
    if($gGlobals['user']['loggedin']) {
    $oTpl->assign('UserId',$gGlobals['user']['id'],false);
    $oTpl->assign('ControlPanelMemberNavbarUserId',$gGlobals['user']['id']);
    $oTpl->assign('ControlPanelMemberNavbarNewMessages',$iUnreadPrivateMessages,false);
    $oTpl->assign('ControlPanelMemberNavbarNewMiBuddyRequests',$oDb->getResult($oDb->select("COUNT(*)","mibuddies","approved='0' AND buddy_id='".$oDb->escape(getUserId())."'")),false);
    $oTpl->parse('MemberNavBar','controlPanel-NavBar');
    
    $sMsg = replaceVars(getConfig('welcomemessage'),'UserName',$gGlobals['user']['name']);
    $sMsg = replaceVars($sMsg,'UnreadPrivateMessages',$iUnreadPrivateMessages);
    $oTpl->assign('WelcomeMessage',$sMsg,false);
    } else {
    $oTpl->assign('WelcomeMessage',getConfig('welcomemessagenotloggedin'),false);
    }
    
    // Check to see if the user has a payment due, if so, only show them the subscriptions page when the are logged in
    if($gGlobals['product']['pro'] && getConfig('paymentpostprofile',0) && strtolower($sDo) != 'logout') {
    $aData = $oDb->getRow($oDb->select("special_flags","users","id=".getUserId()));
    if($aData['special_flags'] & USERS_SPECIAL_FLAGS_PAYMENT_DUE) {
    	$sDo = $HTTP_GET_VARS['do'] = "subscriptions";
    }
    }
    
    $oLog->logEvent(__FILE__,__LINE__,"Set global template variables");
    
    $oTpl->assign('Content','',false);
    
    switch(strtolower($sDo)) {
    case "rate": {
    	$sAct = initVar('act');
    	switch($sAct) {
    		case 'profile':
    			include(dirname(__FILE__)."/content/profile.php");
    			break;
    		case 'top':
    		case 'new':
    			include(dirname(__FILE__)."/content/top_new.php");
    			break;
    		default:
    			include(dirname(__FILE__)."/content/rate.php");
    	}
    	break;
    }
        case "login":
        case "register":
        case "search":
        case "report":
        case "contact":
        case "joinemail":
        case "pm":
        case "mystats":
        case "mypictures":
        case "myprofile":
        case "mycomments":
        case "email":
       	case "mibuddies":
       	case "deleteaccount":
       	case "myblocklist":
       	case "myvideos":
    case "activemembers":
        	include(dirname(__FILE__)."/content/{$sDo}.php");
        	break;
    case "mygalleries":
    	include(dirname(__FILE__)."/content/mypictures.gallery_requests.php");
    	break;
        case "referral":
        	include(dirname(__FILE__)."/content/referral.php");
        	break;
        case "auth":
        case "authaccount":
        	include(dirname(__FILE__)."/content/auth.php");
        	break;
        case "logout":
        	if($gGlobals['use_sessions']) {
    	    $_SESSION = array();
    		//setcookie(session_name(),'',time()-5184000,'/','.'.getConfig('siteaddress',0));
    		setcookie(session_name(),'',time()-5184000,'/');
    	    session_destroy();
        	} else {
        		//setcookie($gGlobals['cookieprefix'].'user',"",time()+1,'/','.'.getConfig('siteaddress',0));
        		//setcookie($gGlobals['cookieprefix'].'user',"",time()-5184000,'/','.'.getConfig('siteaddress',0));
        		setcookie($gGlobals['cookieprefix'].'user',"",time()-5184000,'/');
            //setcookie($gGlobals['cookieprefix'].'pass',"",time()-5184000,'/','.'.getConfig('siteaddress',0));
            setcookie($gGlobals['cookieprefix'].'pass',"",time()-5184000,'/');
            //setcookie($gGlobals['cookieprefix'].'sessionstart',"",time()+1,'/','.'.getConfig('siteaddress',0));
            //setcookie($gGlobals['cookieprefix'].'sessionstart',"",time()-5184000,'/','.'.getConfig('siteaddress',0));
            setcookie($gGlobals['cookieprefix'].'sessionstart',"",time()-5184000,'/');
        	}
        	include(dirname(__FILE__)."/content/main.php");
        	break;
        default:
        	$bShowDefault = true;
    
    	if($oCustoms->runCustoms(FILE_INDEX,3)) {
    	} else {
        	if(!empty($sDo) && $bShowDefault) {
        		$aData = $oDb->getRow($oDb->select("id,require_login","additional_pages","page_name='".$oDb->escape($sDo)."'"));
    
        		if((int)$aData['id'] > 0) {
        			if($aData['require_login'] && !$gGlobals['user']['loggedin']) {
        				include(dirname(__FILE__)."/content/login.php");
        				$bShowDefault = false;
        			} else {
        				//$oTpl->assign('Content',getFile($sDo),false);
        				$oTpl->define(array('additional_page'	=>	$sDo.'.tpl'));
        				$oTpl->parse('Content','additional_page',false);
        				$bShowDefault = false;
        			}
        		}
        	}
    
        	if($bShowDefault) {
        		if(!($cPlugins->callPluginFunction(PLUGIN_FUNCTION_CLIENT_OUTPUT))) {
        			include(dirname(__FILE__)."/content/main.php");
        		}
        	}
    	}
    }
    
    $oLog->logEvent(__FILE__,__LINE__,"Content Code Execution");
    
    // Call operation in plugins to do things since we are done
    $cPlugins->callPluginFunction(PLUGIN_FUNCTION_MAIN_END);
    
    if(MIPHOTO_DEV) {
    $oTpl->assign('SQLNumberOfQueries',$oDb->iNumQueries);
    $oTpl->assign('SQLNumberOfSelectQueries',$oDb->iSelectQueries);
    $oTpl->assign('SQLNumberOfOtherQueries',$oDb->iNumQueries - $oDb->iSelectQueries);
    
    echo "<!--\n";
    print_r($oDb->aQueriesPerTable);
    echo "\n\n\nNOW THE QUERIES\n\n\n";
    print_r($oDb->aQueries);
    echo "\n-->";
    }
    
    // See if there was an error!
    if($oTpl->getValue('ErrorMessage') != "") {
    // There was an error somewhere... lets display the error message to the user...
    $oTpl->parse('ErrorMessageTable','errorTable');
    }
    
    $oTpl->display("index");
    
    
    $oLog->logEvent(__FILE__,__LINE__,"Template Index File display");
    
    $oDb->disconnect();
    
    // Set to null so PHP knows to delete, some PHP systems where not clearing the memory unless this was here
    $oDb = NULL;
    $oTpl = NULL;
    
    $oLog->logEvent(__FILE__,__LINE__,"Execution End");
    $oLog->closeLog();
    
    ?>

  8. Well here is the full code for the function of sending comment for photos

    function returnPhotoComments($iPhotoId, $iStart = 0, $iNumberOfComments = 1) {
    global $oDb, $oTpl;
    
    $oTpl->define(array('profile-ViewProfileMyPicturesPhotoCommentsEach'	=>	'rate/view_profile_my_pictures_photo_comments_each.tpl'));
    
    if($iStart < 0) {
    	$iStart = 0;
    }
    if($iNumberOfComments < 1) {
    	$iNumberOfComments = 1;
    }
    
    $rResult = $oDb->select("added,from_user_id,comments","photo_comments","approved=1 AND photo_id='".$oDb->escape($iPhotoId)."'","ORDER BY added DESC LIMIT {$iStart}, {$iNumberOfComments}");
    while($aData = $oDb->getRow($rResult)) {
    	$oTpl->assign('RateViewProfileMyPicturesPhotoCommentsEachComment',$aData['comments']);
    	$oTpl->assign('RateViewProfileMyPicturesPhotoCommentsEachDate',formatDateTime($aData['added']));
    
    	setUserTemplateVariables($aData['from_user_id'],'RateViewProfileMyPicturesPhotoCommentsEach');
    
    	$oTpl->parse('temp','.profile-ViewProfileMyPicturesPhotoCommentsEach');
    }
    $oDb->freeResult($rResult);
    
    $sComments = $oTpl->getValue('temp');
    $oTpl->clearVars('temp');
    
    return $sComments;
    }
    

  9. Hi i'm trying to select from mysql for my photo comments on my site and I get this error on my page

    Error: 1064

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1' at line 1

    SELECT added,from_user_id,comments FROM miphoto_photo_comments WHERE approved=1 AND photo_id='' ORDER BY added DESC LIMIT , 1

     

    and here is the code that i'm trying to select from mysql also this is a custom mysql select.

    $rResult = $oDb->select("added,from_user_id,comments","photo_comments","approved=1 AND photo_id='".$oDb->escape($iPhotoId)."'","ORDER BY added DESC LIMIT {$iStart}, {$iNumberOfComments}");

     

     

     

    can anyone please help???

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.