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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/akaindir/www/crm/modules/Mobile/api.test.php
<?php
/*+**********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("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.
 ************************************************************************************/
chdir('../../');

header('Content-type: text/plain');

include_once 'vtlib/Vtiger/Net/Client.php';
include_once 'include/Zend/Json.php';

$mobileAPITestController = new Mobile_API_TestController();
$mobileAPITestController->doLoginAndFetchModules('admin','admin');
//$mobileAPITestController->doLogin('standarduser', 'standarduser');
//$mobileAPITestController->doFetchModuleFilters('Leads');
//$mobileAPITestController->doFilterDetailsWithCount('1');
//$mobileAPITestController->doFetchAllAlerts();
//$mobileAPITestController->doAlertDetailsWithMessage(5);
//$mobileAPITestController->doListModuleRecords('Calendar');
//$mobileAPITestController->doFetchRecord('9x0', true);
//$mobileAPITestController->doDescribe('Documents');
//$mobileAPITestController->doSave('Leads', '2x0', array('lastname'=>'Testing', 'company'=>'Company'));
//$mobileAPITestController->doSync('HelpDesk');//, 0, 1277646523, 'public');//, 0, 1277234885);// 1271240542);
//$mobileAPITestController->doScanImage();
//$mobileAPITestController->doFetchRecordsWithGrouping('Potentials', 'alertid', '4')
//$mobileAPITestController->doQuery('Contacts', "SELECT firstname,lastname,account_id FROM Contacts LIMIT 1,2;");
//$mobileAPITestController->doQuery('Contacts', "SELECT * FROM Contacts;", 0, true);
//$mobileAPITestController->doRelatedRecordsWithGrouping('3x2', 'Contacts', 1);
//$mobileAPITestController->doDeleteRecords(array('1x198', '18x198'));

//$mobileAPITestController->doHistory('Home');

$mobileAPITestController->doFetchRecord('16x196', false);

class Mobile_API_TestController {
	
	private $URL;
	private $userid;
	private $session;
	private $listing;
	
	function doPost($parameters, $printResponse = false) {
		$client = new Vtiger_Net_Client($this->URL);
		$response = $client->doPost($parameters);
		if($printResponse) echo $response;
		$responseJSON = Zend_Json::decode($response);
		return $responseJSON;
	}
	
	function doLoginAndFetchModules($username, $password) {
		$responseJSON = $this->doPost(array(
				'_operation' => 'loginAndFetchModules',
				'username' => $username,
				'password' => $password
			));
			
		$modules = array();
			
		if($responseJSON['success']) {
			$result = $responseJSON['result'];
			
			$this->userid = $result['login']['userid'];
			$this->session= $result['login']['session'];
			$this->listing= $result['modules'];
			
			echo sprintf("Login success - User ID: %s - Session %s\n", $this->userid, $this->session);
			echo "Accessible modules\n";
			foreach($this->listing as $moduleinfo) {
				echo sprintf("  %s - %s\n", $moduleinfo['id'], $moduleinfo['name']);
				$modules[] = $moduleinfo['name'];
			}
			
		} else {
			$error = $responseJSON['error'];
			echo sprintf("Login failed - %s: %s\n", $error['code'], $error['message']);
		}
		return $modules;
	}
	
	function doLogin($username, $password) {
		$responseJSON = $this->doPost(array(
				'_operation' => 'login',
				'username' => $username,
				'password' => $password
			), true);
			
		$modules = array();
			
		if($responseJSON['success']) {
			$result = $responseJSON['result'];
			
			$this->userid = $result['login']['userid'];
			$this->session= $result['login']['session'];
			$this->listing= $result['modules'];
			
			echo sprintf("Login success - User ID: %s - Session %s\n", $this->userid, $this->session);
			
		} else {
			$error = $responseJSON['error'];
			echo sprintf("Login failed - %s: %s\n", $error['code'], $error['message']);
		}
		return $modules;
	}
	
	function doFetchModuleFilters($moduleName) {
		$responseJSON = $this->doPost(array(
				'_operation' => 'fetchModuleFilters',
				'_session'=> $this->session,
				'module' => $moduleName,
			), true);
		//print_r($responseJSON);
	}
	
	function doFilterDetailsWithCount($filterId) {
		$responseJSON = $this->doPost(array(
				'_operation' => 'filterDetailsWithCount',
				'_session'=> $this->session,
				'filterid' => $filterId,
			), true);
		//print_r($responseJSON);
	}
	
	function doFetchAllAlerts() {
		$responseJSON = $this->doPost(array(
				'_operation' => 'fetchAllAlerts',
				'_session'=> $this->session,
			), true);
		//print_r($responseJSON);
	}
	
	function doAlertDetailsWithMessage($alertid) {
		$responseJSON = $this->doPost(array(
				'_operation' => 'alertDetailsWithMessage',
				'_session'=> $this->session,
				'alertid' => $alertid,
			), true);
		//print_r($responseJSON);
	}
	
	function doListModuleRecords($module) {
		$responseJSON = $this->doPost(array(
				'_operation' => 'listModuleRecords',
				'_session'=> $this->session,
				'module' => $module,
				//'alertid'=> '1'
				//'filterid' => '2'
				'search' => Zend_Json::encode(array('_sort'=>'ORDER BY modifiedtime desc')),
			), true);
		//print_r($responseJSON);
	}
	
	function doFetchRecord($recordid, $withGrouping = false) {
		$parameters = array(
				'_session' => $this->session,
				'_operation' => 'fetchRecord',
				'record' => $recordid
			);
			
		if($withGrouping) {
			$parameters['_operation'] = 'fetchRecordWithGrouping';
		}
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doDescribe($module) {
		$responseJSON = $this->doPost(array(
				'_session' => $this->session,
				'_operation' => 'describe',
				'module' => $module
			), true);
	}
	
	function doSave($module, $record, $values) {
		$parameters = array(
				'_session' => $this->session,
				'_operation' => 'saveRecord',
				'module' => $module,
				'record' => $record,
				'values' => Zend_Json::encode($values)
			);
			
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doSync($module, $page=false, $lastSyncTime = false, $mode='PUBLIC') {
		$parameters = array(
				'_session' => $this->session,
				'_operation' => 'syncModuleRecords',
				'module' => $module,
			);
		if ($page !== false) {
			$parameters['page'] = $page;
		}
		if ($lastSyncTime !== false) {
			$parameters['syncToken'] = $lastSyncTime;
		}
		$parameters['mode'] = $mode;
			
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doScanImage($module) {
		$parameters = array(
				'_session' => $this->session,
				'_operation' => 'scanImage'
			);
			
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doFetchRecordsWithGrouping($module, $key, $value) {
		$parameters = array(
				'_session' => $this->session,
				'_operation' => 'fetchRecordsWithGrouping',
				'module' => $module,
				$key => $value
			);
			
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doQuery($module, $query, $page=0, $withGrouping = false) {
		$parameters = array(
				'_session' => $this->session,
				'_operation' => ($withGrouping? 'queryWithGrouping' : 'query'),
				'module' => $module,
				'page' => $page,
				'query' => $query
			);
			
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doRelatedRecordsWithGrouping($record, $relatedmodule, $page=0) {
		$parameters = array(
				'_session' => $this->session,
				'_operation' => 'relatedRecordsWithGrouping',
				'record' => $record,
				'relatedmodule' => $relatedmodule,
				'page' => $page
			);
			
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doDeleteRecords($recordids) {
		$key = 'record'; $value = $recordids;
		if (is_array($recordids)) {
			$key = 'records';
			$value = Zend_Json::encode($recordids);
		}
		$parameters = array(
				'_session' => $this->session,
				'_operation' => 'deleteRecords',
				$key => $value
			);
			
		$responseJSON = $this->doPost($parameters, true);
	}
	
	function doHistory($module, $record='') {
		$parameters = array(
			'_session' => $this->session,
			'_operation' => 'history',
			'module' => empty($record) ? $module : '',
			'record' => $record,
			'mode'   => 'All' , // Private (not supported yet)
		);
		$responseJSON = $this->doPost($parameters, true);
	}
	
}


haha - 2025