include.ini.php 13 KB

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