include.ini.php 13 KB

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