include.ini.php 13 KB

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