include.ini.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 _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. //暂时注释掉,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. //新增手机customer查询空运函数。
  149. 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') {
  150. $tt = $user['air_customer_search_type'];
  151. $sales = $user['air_sales'];
  152. if (empty($tt)) {
  153. return "1<>1";
  154. }
  155. //error_log("_customerFilerSearchHandNew -- " . $schemas);
  156. $_contact_id = _getContactIDHandNew_Air($user, $schemas);
  157. if (empty($_contact_id)) {
  158. return "1<>1";
  159. }
  160. $sqlWhere1 = "";
  161. if (utils::checkExist($tt, 's') && !empty($s)) {
  162. if (empty($sqlWhere1)) {
  163. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  164. } else {
  165. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  166. }
  167. }
  168. if (utils::checkExist($tt, 'c') && !empty($c)) {
  169. if (empty($sqlWhere1)) {
  170. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  171. } else {
  172. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  173. }
  174. }
  175. if (utils::checkExist($tt, 'b') && !empty($b)) {
  176. if (empty($sqlWhere1)) {
  177. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  178. } else {
  179. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  180. }
  181. }
  182. if (utils::checkExist($tt, 'n') && !empty($n)) {
  183. if (empty($sqlWhere1)) {
  184. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  185. } else {
  186. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  187. }
  188. }
  189. if (empty($sqlWhere1))
  190. return "1<>1";
  191. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  192. if (!empty($user['customer_destination']) && !empty($p)) {
  193. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  194. }
  195. if (!empty($user['customer_discharge']) && !empty($d)) {
  196. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  197. }
  198. if (strtolower($sales) == 'all' || empty($sales)) {
  199. } else {
  200. if (utils::checkExist($sales, ";")) {
  201. $sql = "1!=1";
  202. $tt = explode(";", $sales);
  203. foreach ($tt as $t) {
  204. $t = trim($t);
  205. if (!empty($t))
  206. $sql .= " or sales_rep ilike '" . $t . "%'";
  207. }
  208. $sqlWhere1 .= " and ($sql)";
  209. } else
  210. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  211. }
  212. return $sqlWhere1;
  213. }
  214. function _getContactIDHandNew_Air($user, $schemas = "public") {
  215. $contact_id_user = _getCompanyContactHandNew_Air($user);
  216. $id = "";
  217. if ($schemas == "public") {
  218. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  219. } else {
  220. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  221. }
  222. foreach ($contact_id as $v) {
  223. if (empty($id))
  224. $id = trim($v['contacts_id']);
  225. else
  226. $id .= ";" . $v['contacts_id'];
  227. }
  228. if (!empty($contact_id_user)) {
  229. $id .= ";" . $contact_id_user;
  230. }
  231. return $id;
  232. }
  233. function _getCompanyContactHandNew_Air($user, $schemas = "public") {
  234. if ($schemas == "public") {
  235. return $user['air_customers'];
  236. } else {
  237. return $user[$schemas . '_ONLINE_USER']['air_customers'];
  238. }
  239. }
  240. function _getCompanyHandNew($user, $schemas = "public") {
  241. if ($schemas == "public") {
  242. return $user['company'];
  243. } else {
  244. if (empty($user['company'])) {
  245. return $user['company_name'];
  246. } else {
  247. return $user['company'];
  248. }
  249. }
  250. }
  251. function _getContactIDHandNew($user, $schemas = "public") {
  252. $contact_id_user = _getCompanyContactHandNew($user);
  253. $id = "";
  254. if ($schemas == "public") {
  255. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  256. } else {
  257. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  258. }
  259. foreach ($contact_id as $v) {
  260. if (empty($id))
  261. $id = trim($v['contacts_id']);
  262. else
  263. $id .= ";" . $v['contacts_id'];
  264. }
  265. if (!empty($contact_id_user)) {
  266. $id .= ";" . $contact_id_user;
  267. }
  268. return $id;
  269. }
  270. function _getCompanyContactHandNew($user, $schemas = "public") {
  271. if ($schemas == "public") {
  272. return $user['contact_id_user'];
  273. } else {
  274. return $user[$schemas . '_ONLINE_USER']['contact_id_user'];
  275. }
  276. }
  277. function _isDemo() {
  278. return $_SESSION['ONLINE_USER']['is_demo'] == "t";
  279. }
  280. function _is_only_vgm() {
  281. if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") {
  282. return TRUE;
  283. }
  284. return FALSE;
  285. }
  286. function _get_schemas() {
  287. return $_SESSION['schemas_list'];
  288. }
  289. function _getViewDocType($schemas = "public") {
  290. if ($schemas == "public") {
  291. return $_SESSION['ONLINE_USER']['view_doc_type'];
  292. } else {
  293. return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type'];
  294. }
  295. }
  296. function _canEdiVgm($schemas = "public") {
  297. if ($schemas == "public") {
  298. return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  299. } else {
  300. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  301. }
  302. }
  303. ?>