include.ini.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. session_start();
  10. error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
  11. error_reporting(0);
  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 _isNewUser() {
  45. return _isCustomerLogin() && empty($_SESSION['ONLINE_USER']['permission']);
  46. }
  47. function _isCustomerLogin() {
  48. return strtolower($_SESSION['ONLINE_USER']['user_type']) == 'customer';
  49. }
  50. function _getLoginName() {
  51. return $_SESSION['ONLINE_USER']['user_login'];
  52. }
  53. function _getLoginEamil() {
  54. return $_SESSION['ONLINE_USER']['email'];
  55. }
  56. function _isAdminHandNew($user) {
  57. return $user['is_super'] == 't';
  58. }
  59. function _canViewAMSLog($schemas = "public") {
  60. if ($schemas == "public") {
  61. return strtolower($_SESSION['ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
  62. } else {
  63. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
  64. }
  65. }
  66. function _canViewISFLog($schemas = "public") {
  67. if ($schemas == "public") {
  68. return strtolower($_SESSION['ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
  69. } else {
  70. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
  71. }
  72. }
  73. function _isDocAdmin($username) {
  74. return strtolower($username) == "doc.alice" || strtolower($username) == "apexdoc.admin"
  75. || strtolower($username) == "doc.patty1" || strtolower($username) == "maria" || strtolower($username) == "it.andywu"
  76. || strtolower($username) == "doc.riley" || strtolower($username) == "doc.amy" || strtolower($username) == "doc.vicky"
  77. || strtolower($username) == "doc.leah" || strtolower($username) == "doc.yuki" || strtolower($username) == "doc.yoyo";
  78. }
  79. function _isCustomerLoginHandNew($user) {
  80. return strtolower($user["user_type"]) == 'customer';
  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. if (utils::checkExist($tt, 'b') && !empty($b)) {
  109. if (empty($sqlWhere1)) {
  110. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  111. } else {
  112. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  113. }
  114. }
  115. if (utils::checkExist($tt, 'n') && !empty($n)) {
  116. if (empty($sqlWhere1)) {
  117. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  118. } else {
  119. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  120. }
  121. }
  122. if (empty($sqlWhere1))
  123. return "1<>1";
  124. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  125. if (!empty($user['customer_destination']) && !empty($p)) {
  126. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  127. }
  128. if (!empty($user['customer_discharge']) && !empty($d)) {
  129. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  130. }
  131. if (strtolower($sales) == 'all' || empty($sales)) {
  132. } else {
  133. if (utils::checkExist($sales, ";")) {
  134. $sql = "1!=1";
  135. $tt = explode(";", $sales);
  136. foreach ($tt as $t) {
  137. $t = trim($t);
  138. if (!empty($t))
  139. $sql .= " or sales_rep ilike '" . $t . "%'";
  140. }
  141. $sqlWhere1 .= " and ($sql)";
  142. } else
  143. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  144. }
  145. return $sqlWhere1;
  146. }
  147. //新增手机customer查询空运函数。
  148. function _customerFilerSearchHandNew_Air($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') {
  149. $tt = $user['air_customer_search_type'];
  150. $sales = $user['air_sales'];
  151. if (empty($tt)) {
  152. return "1<>1";
  153. }
  154. //error_log("_customerFilerSearchHandNew -- " . $schemas);
  155. $_contact_id = _getContactIDHandNew_Air($user, $schemas);
  156. if (empty($_contact_id)) {
  157. return "1<>1";
  158. }
  159. $sqlWhere1 = "";
  160. if (utils::checkExist($tt, 's') && !empty($s)) {
  161. if (empty($sqlWhere1)) {
  162. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  163. } else {
  164. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  165. }
  166. }
  167. if (utils::checkExist($tt, 'c') && !empty($c)) {
  168. if (empty($sqlWhere1)) {
  169. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  170. } else {
  171. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  172. }
  173. }
  174. if (utils::checkExist($tt, 'b') && !empty($b)) {
  175. if (empty($sqlWhere1)) {
  176. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  177. } else {
  178. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  179. }
  180. }
  181. if (utils::checkExist($tt, 'n') && !empty($n)) {
  182. if (empty($sqlWhere1)) {
  183. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  184. } else {
  185. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  186. }
  187. }
  188. if (empty($sqlWhere1))
  189. return "1<>1";
  190. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  191. if (!empty($user['customer_destination']) && !empty($p)) {
  192. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  193. }
  194. if (!empty($user['customer_discharge']) && !empty($d)) {
  195. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  196. }
  197. if (strtolower($sales) == 'all' || empty($sales)) {
  198. } else {
  199. if (utils::checkExist($sales, ";")) {
  200. $sql = "1!=1";
  201. $tt = explode(";", $sales);
  202. foreach ($tt as $t) {
  203. $t = trim($t);
  204. if (!empty($t))
  205. $sql .= " or sales_rep ilike '" . $t . "%'";
  206. }
  207. $sqlWhere1 .= " and ($sql)";
  208. } else
  209. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  210. }
  211. return $sqlWhere1;
  212. }
  213. function _getContactIDHandNew_Air($user, $schemas = "public") {
  214. $contact_id_user = _getCompanyContactHandNew_Air($user);
  215. $id = "";
  216. if ($schemas == "public") {
  217. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  218. } else {
  219. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  220. }
  221. foreach ($contact_id as $v) {
  222. if (empty($id))
  223. $id = trim($v['contacts_id']);
  224. else
  225. $id .= ";" . $v['contacts_id'];
  226. }
  227. if (!empty($contact_id_user)) {
  228. $id .= ";" . $contact_id_user;
  229. }
  230. return $id;
  231. }
  232. function _getCompanyContactHandNew_Air($user, $schemas = "public") {
  233. if ($schemas == "public") {
  234. return $user['air_customers'];
  235. } else {
  236. return $user[$schemas . '_ONLINE_USER']['air_customers'];
  237. }
  238. }
  239. function _getCompanyHandNew($user, $schemas = "public") {
  240. if ($schemas == "public") {
  241. return $user['company'];
  242. } else {
  243. if (empty($user['company'])) {
  244. return $user['company_name'];
  245. } else {
  246. return $user['company'];
  247. }
  248. }
  249. }
  250. function _getContactIDHandNew($user, $schemas = "public") {
  251. $contact_id_user = _getCompanyContactHandNew($user);
  252. $id = "";
  253. if ($schemas == "public") {
  254. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  255. } else {
  256. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  257. }
  258. foreach ($contact_id as $v) {
  259. if (empty($id))
  260. $id = trim($v['contacts_id']);
  261. else
  262. $id .= ";" . $v['contacts_id'];
  263. }
  264. if (!empty($contact_id_user)) {
  265. $id .= ";" . $contact_id_user;
  266. }
  267. return $id;
  268. }
  269. function _getCompanyContactHandNew($user, $schemas = "public") {
  270. if ($schemas == "public") {
  271. return $user['contact_id_user'];
  272. } else {
  273. return $user[$schemas . '_ONLINE_USER']['contact_id_user'];
  274. }
  275. }
  276. function _isDemo() {
  277. return $_SESSION['ONLINE_USER']['is_demo'] == "t";
  278. }
  279. function _is_only_vgm() {
  280. if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") {
  281. return TRUE;
  282. }
  283. return FALSE;
  284. }
  285. function _get_schemas() {
  286. return $_SESSION['schemas_list'];
  287. }
  288. function _getViewDocType($schemas = "public") {
  289. if ($schemas == "public") {
  290. return $_SESSION['ONLINE_USER']['view_doc_type'];
  291. } else {
  292. return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type'];
  293. }
  294. }
  295. function _canEdiVgm($schemas = "public") {
  296. if ($schemas == "public") {
  297. return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  298. } else {
  299. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  300. }
  301. }
  302. ?>