include.ini.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?php
  2. if (extension_loaded('zlib')) {
  3. ini_set('zlib.output_compression', 'On');
  4. ini_set('zlib.output_compression_level', '9');
  5. }
  6. if (!empty($_REQUEST['sessionid'])) {
  7. session_id($_REQUEST['sessionid']);
  8. }
  9. error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
  10. error_reporting(0);
  11. session_start();
  12. ini_set("magic_quotes_runtime", 0);
  13. define('IN_ONLINE', TRUE);
  14. define('DS', DIRECTORY_SEPARATOR);
  15. define('WEB_ROOT', str_replace(DS, '/', str_replace(str_replace("/", DS, $_SERVER['DOCUMENT_ROOT']), '', realpath(dirname(__FILE__)))));
  16. define('ONLINE_ROOT', realpath(dirname(__FILE__)) . DS);
  17. define('ADODB_PATH', ONLINE_ROOT . 'libs' . DS . 'ADOdb-5.20.17' . DS);
  18. define('C_PATH', ONLINE_ROOT . 'service' . DS);
  19. define('FILE_UPLOAD_PAHT', "upload" . DS);
  20. // define('DOCUMENT_AIR_UPLOAD_PATH', "D:" . DS . "DOC_AIR" . DS);
  21. // define('DOCUMENT_OCEAN_UPLOAD_PATH', "D:" . DS . "DOC" . DS);
  22. // define('DOCUMENT_SFSAIR_UPLOAD_PATH', "D:" . DS . "DOC_AIR" . DS);
  23. // define('DOCUMENT_SFSOCEAN_UPLOAD_PATH', "D:" . DS . "DOC" . DS);
  24. define('DOCUMENT_AIR_UPLOAD_PATH', "/DOC_AIR" . DS);
  25. define('DOCUMENT_OCEAN_UPLOAD_PATH', "/DOC" . DS);
  26. define('DOCUMENT_SFSAIR_UPLOAD_PATH', "/DOC_AIR" . DS);
  27. define('DOCUMENT_SFSOCEAN_UPLOAD_PATH', "/DOC" . DS);
  28. //define('SERVER_PAHT', 'http://192.168.0.161/k_new_online/');
  29. define('SERVER_PAHT', 'https://online-beta.kln.com/');
  30. if (preg_match("/(bot|crawl|spider|slurp)/i", $_SERVER['HTTP_USER_AGENT'])) {
  31. header('HTTP/1.1 403 Forbidden');
  32. exit;
  33. }
  34. if (function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get"))
  35. @date_default_timezone_set(@date_default_timezone_get());
  36. header('Content-type: text/html; Charset=utf-8');
  37. include_once ADODB_PATH . 'toexport.inc.php';
  38. include_once ADODB_PATH . 'adodb.inc.php';
  39. include_once ONLINE_ROOT . 'libs' . DS . 'config.ini.php';
  40. include_once ONLINE_ROOT . 'utils' . DS . 'utils.class.php';
  41. include_once ONLINE_ROOT . 'utils' . DS . 'common.class.php';
  42. //测试服务器
  43. if(utils::startWith($_SERVER["HTTP_HOST"],"online-beta.kln.com")){
  44. define('SERVER_PAHT', 'https://online-beta.kln.com/online_backend/');
  45. }elseif(utils::startWith($_SERVER["HTTP_HOST"],"online.kln.com")){
  46. define('SERVER_PAHT', 'https://online.kln.com/online_backend/');
  47. }else{
  48. //本地测试demo
  49. define('SERVER_PAHT', 'http://192.168.0.161/Customer_Service_Online/');
  50. }
  51. $tar = common::excuteObjectSql("select item_value from config where item='Current_Used_Company'");
  52. if (!empty($tar["item_value"])&&$tar["item_value"]=="TOPOCEAN") {
  53. define("Soure", 'TopOcean');
  54. }else{
  55. define("Soure", 'Apex');
  56. }
  57. function _isApexLogin() {
  58. return strtolower($_SESSION['ONLINE_USER']['user_type']) == "employee";
  59. }
  60. function _isAdmin() {
  61. return $_SESSION['ONLINE_USER']['is_super'] == 't';
  62. }
  63. function _isRevenueDisplay() {
  64. return $_SESSION['ONLINE_USER']['revenue_active'] == 't';
  65. }
  66. function _isNewUser() {
  67. return _isCustomerLogin() && empty($_SESSION['ONLINE_USER']['permission']);
  68. }
  69. function _isCustomerLogin() {
  70. return strtolower($_SESSION['ONLINE_USER']['user_type']) == 'customer';
  71. }
  72. function _getLoginName() {
  73. return $_SESSION['ONLINE_USER']['user_login'];
  74. }
  75. function _getLoginEamil() {
  76. return $_SESSION['ONLINE_USER']['email'];
  77. }
  78. function _isAdminHandNew($user) {
  79. return $user['is_super'] == 't';
  80. }
  81. function _canViewAMSLog($schemas = "public") {
  82. if ($schemas == "public") {
  83. return strtolower($_SESSION['ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
  84. } else {
  85. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
  86. }
  87. }
  88. function _canViewISFLog($schemas = "public") {
  89. if ($schemas == "public") {
  90. return strtolower($_SESSION['ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
  91. } else {
  92. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
  93. }
  94. }
  95. function _isDocAdmin($username) {
  96. return strtolower($username) == "doc.alice" || strtolower($username) == "apexdoc.admin"
  97. || strtolower($username) == "doc.patty1" || strtolower($username) == "maria" || strtolower($username) == "it.andywu"
  98. || strtolower($username) == "doc.riley" || strtolower($username) == "doc.amy" || strtolower($username) == "doc.vicky"
  99. || strtolower($username) == "doc.leah" || strtolower($username) == "doc.yuki" || strtolower($username) == "doc.yoyo";
  100. }
  101. function _customerFilerSearchHandNew($user, $schemas = "public", $p = 'place_of_delivery', $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id', $d = 'port_of_discharge_code') {
  102. $tt = $user['customer_search_type'];
  103. $sales = $user['ocean_sales'];
  104. if (empty($tt)) {
  105. return "1<>1";
  106. }
  107. //error_log("_customerFilerSearchHandNew -- " . $schemas);
  108. $_contact_id = _getContactIDHandNew($user, $schemas);
  109. if (empty($_contact_id)) {
  110. return "1<>1";
  111. }
  112. $sqlWhere1 = "";
  113. if (utils::checkExist($tt, 's') && !empty($s)) {
  114. if (empty($sqlWhere1)) {
  115. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  116. } else {
  117. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  118. }
  119. }
  120. if (utils::checkExist($tt, 'c') && !empty($c)) {
  121. if (empty($sqlWhere1)) {
  122. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  123. } else {
  124. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  125. }
  126. }
  127. //暂时注释掉,ocean_booking 没有这个字段
  128. // if (utils::checkExist($tt, 'b') && !empty($b)) {
  129. // if (empty($sqlWhere1)) {
  130. // $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  131. // } else {
  132. // $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  133. // }
  134. // }
  135. if (utils::checkExist($tt, 'n') && !empty($n)) {
  136. if (empty($sqlWhere1)) {
  137. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  138. } else {
  139. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  140. }
  141. }
  142. if (empty($sqlWhere1))
  143. return "1<>1";
  144. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  145. if (!empty($user['customer_destination']) && !empty($p)) {
  146. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  147. }
  148. if (!empty($user['customer_discharge']) && !empty($d)) {
  149. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  150. }
  151. if (strtolower($sales) == 'all' || empty($sales)) {
  152. } else {
  153. if (utils::checkExist($sales, ";")) {
  154. $sql = "1!=1";
  155. $tt = explode(";", $sales);
  156. foreach ($tt as $t) {
  157. $t = trim($t);
  158. if (!empty($t))
  159. $sql .= " or sales_rep ilike '" . $t . "%'";
  160. }
  161. $sqlWhere1 .= " and ($sql)";
  162. } else
  163. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  164. }
  165. return $sqlWhere1;
  166. }
  167. function _getContactIDHandNew_Air($user, $schemas = "public") {
  168. $contact_id_user = _getCompanyContactHandNew_Air($user);
  169. $id = "";
  170. if ($schemas == "public") {
  171. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  172. } else {
  173. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  174. }
  175. foreach ($contact_id as $v) {
  176. if (empty($id))
  177. $id = trim($v['contacts_id']);
  178. else
  179. $id .= ";" . $v['contacts_id'];
  180. }
  181. if (!empty($contact_id_user)) {
  182. $id .= ";" . $contact_id_user;
  183. }
  184. return $id;
  185. }
  186. function _getCompanyContactHandNew_Air($user, $schemas = "public") {
  187. if ($schemas == "public") {
  188. return $user['air_customers'];
  189. } else {
  190. return $user[$schemas . '_ONLINE_USER']['air_customers'];
  191. }
  192. }
  193. function _getCompanyHandNew($user, $schemas = "public") {
  194. if ($schemas == "public") {
  195. return $user['company'];
  196. } else {
  197. if (empty($user['company'])) {
  198. return $user['company_name'];
  199. } else {
  200. return $user['company'];
  201. }
  202. }
  203. }
  204. function _getContactIDHandNew($user, $schemas = "public") {
  205. $contact_id_user = _getCompanyContactHandNew($user);
  206. $id = "";
  207. if ($schemas == "public") {
  208. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  209. } else {
  210. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  211. }
  212. foreach ($contact_id as $v) {
  213. if (empty($id))
  214. $id = trim($v['contacts_id']);
  215. else
  216. $id .= ";" . $v['contacts_id'];
  217. }
  218. if (!empty($contact_id_user)) {
  219. $id .= ";" . $contact_id_user;
  220. }
  221. return $id;
  222. }
  223. function _getCompanyContactHandNew($user, $schemas = "public") {
  224. if ($schemas == "public") {
  225. return $user['contact_id_user'];
  226. } else {
  227. return $user[$schemas . '_ONLINE_USER']['contact_id_user'];
  228. }
  229. }
  230. function _isDemo() {
  231. return $_SESSION['ONLINE_USER']['is_demo'] == "t";
  232. }
  233. function _is_only_vgm() {
  234. if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") {
  235. return TRUE;
  236. }
  237. return FALSE;
  238. }
  239. function _get_schemas() {
  240. return $_SESSION['schemas_list'];
  241. }
  242. function _getViewDocType($schemas = "public") {
  243. if ($schemas == "public") {
  244. return $_SESSION['ONLINE_USER']['view_doc_type'];
  245. } else {
  246. return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type'];
  247. }
  248. }
  249. function _getAirViewDocType($schemas = "public") {
  250. if ($schemas == "public") {
  251. return $_SESSION['ONLINE_USER']['view_air_doc_type'];
  252. } else {
  253. return $_SESSION[$schemas . '_ONLINE_USER']['view_air_doc_type'];
  254. }
  255. }
  256. function _canEdiVgm($schemas = "public") {
  257. if ($schemas == "public") {
  258. return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  259. } else {
  260. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  261. }
  262. }
  263. function _getAirStation($schemas = "public") {
  264. if ($schemas == "public") {
  265. return $_SESSION['ONLINE_USER']['air_station'];
  266. } else {
  267. return $_SESSION[$schemas . '_ONLINE_USER']['air_station'];
  268. }
  269. }
  270. function _getAirStationOr($schemas = "public") {
  271. if ($schemas == "public") {
  272. return $_SESSION['ONLINE_USER']['air_station_or'];
  273. } else {
  274. return $_SESSION[$schemas . '_ONLINE_USER']['air_station_or'];
  275. }
  276. }
  277. function _getAirSales($schemas = "public") {
  278. if ($schemas == "public") {
  279. return $_SESSION['ONLINE_USER']['air_sales'];
  280. } else {
  281. return $_SESSION[$schemas . '_ONLINE_USER']['air_sales'];
  282. }
  283. }
  284. function _getAirSalesOr($schemas = "public") {
  285. if ($schemas == "public") {
  286. return $_SESSION['ONLINE_USER']['air_sales_or'];
  287. } else {
  288. return $_SESSION[$schemas . '_ONLINE_USER']['air_sales_or'];
  289. }
  290. }
  291. function _customerAirSearchType($schemas = "public") {
  292. if ($schemas == "public") {
  293. return $_SESSION['ONLINE_USER']['air_customer_search_type'];
  294. } else {
  295. return $_SESSION[$schemas . '_ONLINE_USER']['air_customer_search_type'];
  296. }
  297. }
  298. function _getAirContactID($schemas = "public") {
  299. if ($schemas == "public") {
  300. return $_SESSION['ONLINE_USER']['air_customers'];
  301. } else {
  302. return $_SESSION[$schemas . '_ONLINE_USER']['air_customers'];
  303. }
  304. }
  305. function _customerAirFilerSearch($schemas = "public", $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id') {
  306. $tt = _customerAirSearchType($schemas);
  307. if (empty($tt))
  308. return "1<>1";
  309. $_contact_id = _getAirContactID($schemas);
  310. if (empty($_contact_id)) {
  311. return "1<>1";
  312. }
  313. $sqlWhere1 = "";
  314. if (utils::checkExist($tt, 's') && !empty($s)) {
  315. if (empty($sqlWhere1)) {
  316. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  317. } else {
  318. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  319. }
  320. }
  321. if (utils::checkExist($tt, 'c') && !empty($c)) {
  322. if (empty($sqlWhere1)) {
  323. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  324. } else {
  325. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  326. }
  327. }
  328. if (utils::checkExist($tt, 'b') && !empty($b)) {
  329. if (empty($sqlWhere1)) {
  330. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  331. } else {
  332. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  333. }
  334. }
  335. if (utils::checkExist($tt, 'n') && !empty($n)) {
  336. if (empty($sqlWhere1)) {
  337. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  338. } else {
  339. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  340. }
  341. }
  342. if (empty($sqlWhere1))
  343. return "1<>1";
  344. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  345. return $sqlWhere1;
  346. }
  347. function _isCustomerLoginHandNew($user) {
  348. return strtolower($user["user_type"]) == 'customer';
  349. }
  350. ?>