/** * TuiyoPrivacy::canRateUser() * Checks if userID can rate profileID * @param mixed $profileID * @param mixed $userID * @param mixed $IP * @return true if can rate or false if can't */ public function canRateUser($profileID, $userID = NULL, $IP = NULL) { //joomla !! jimport('joomla.filesystem.file'); jimport('joomla.filesystem.path'); $user =& TuiyoAPI::get("user", $userID); $profile =& TuiyoAPI::get("user", (int) $profileID); //**If guest || if same user if ($user->joomla->get("guest") || (int) $profile->id === (int) $user->id) { return false; } $IP = is_null($IP) || empty($IP) ? getenv('REMOTE_ADDR') : $IP; $IPfile = TUIYO_FILES . DS . "logs" . DS . strval($profile->id) . DS . "rating.log"; if (!JFile::exists($IPfile)) { JFile::write($IPfile, "#Tuiyo Rating log; Profile:" . $profile->id . "\n\n"); return TRUE; } $rateLog = TuiyoAPI::parseINI($IPfile); $rateLogKey = $user->id . "@" . $IP; if (array_key_exists($rateLogKey, $rateLog)) { return false; } //Yes user can vote return TRUE; }