include.ini.php 13 KB

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