include.ini.php 12 KB

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