include.ini.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 _isCustomerLoginHandNew($user) {
  83. return strtolower($user["user_type"]) == 'customer';
  84. }
  85. 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') {
  86. $tt = $user['customer_search_type'];
  87. $sales = $user['ocean_sales'];
  88. if (empty($tt)) {
  89. return "1<>1";
  90. }
  91. //error_log("_customerFilerSearchHandNew -- " . $schemas);
  92. $_contact_id = _getContactIDHandNew($user, $schemas);
  93. if (empty($_contact_id)) {
  94. return "1<>1";
  95. }
  96. $sqlWhere1 = "";
  97. if (utils::checkExist($tt, 's') && !empty($s)) {
  98. if (empty($sqlWhere1)) {
  99. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  100. } else {
  101. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  102. }
  103. }
  104. if (utils::checkExist($tt, 'c') && !empty($c)) {
  105. if (empty($sqlWhere1)) {
  106. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  107. } else {
  108. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  109. }
  110. }
  111. //暂时注释掉,ocean_booking 没有这个字段
  112. // if (utils::checkExist($tt, 'b') && !empty($b)) {
  113. // if (empty($sqlWhere1)) {
  114. // $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  115. // } else {
  116. // $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  117. // }
  118. // }
  119. if (utils::checkExist($tt, 'n') && !empty($n)) {
  120. if (empty($sqlWhere1)) {
  121. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  122. } else {
  123. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  124. }
  125. }
  126. if (empty($sqlWhere1))
  127. return "1<>1";
  128. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  129. if (!empty($user['customer_destination']) && !empty($p)) {
  130. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  131. }
  132. if (!empty($user['customer_discharge']) && !empty($d)) {
  133. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  134. }
  135. if (strtolower($sales) == 'all' || empty($sales)) {
  136. } else {
  137. if (utils::checkExist($sales, ";")) {
  138. $sql = "1!=1";
  139. $tt = explode(";", $sales);
  140. foreach ($tt as $t) {
  141. $t = trim($t);
  142. if (!empty($t))
  143. $sql .= " or sales_rep ilike '" . $t . "%'";
  144. }
  145. $sqlWhere1 .= " and ($sql)";
  146. } else
  147. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  148. }
  149. return $sqlWhere1;
  150. }
  151. //新增手机customer查询空运函数。
  152. 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') {
  153. $tt = $user['air_customer_search_type'];
  154. $sales = $user['air_sales'];
  155. if (empty($tt)) {
  156. return "1<>1";
  157. }
  158. //error_log("_customerFilerSearchHandNew -- " . $schemas);
  159. $_contact_id = _getContactIDHandNew_Air($user, $schemas);
  160. if (empty($_contact_id)) {
  161. return "1<>1";
  162. }
  163. $sqlWhere1 = "";
  164. if (utils::checkExist($tt, 's') && !empty($s)) {
  165. if (empty($sqlWhere1)) {
  166. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  167. } else {
  168. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  169. }
  170. }
  171. if (utils::checkExist($tt, 'c') && !empty($c)) {
  172. if (empty($sqlWhere1)) {
  173. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  174. } else {
  175. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  176. }
  177. }
  178. if (utils::checkExist($tt, 'b') && !empty($b)) {
  179. if (empty($sqlWhere1)) {
  180. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  181. } else {
  182. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  183. }
  184. }
  185. if (utils::checkExist($tt, 'n') && !empty($n)) {
  186. if (empty($sqlWhere1)) {
  187. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  188. } else {
  189. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  190. }
  191. }
  192. if (empty($sqlWhere1))
  193. return "1<>1";
  194. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  195. if (!empty($user['customer_destination']) && !empty($p)) {
  196. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  197. }
  198. if (!empty($user['customer_discharge']) && !empty($d)) {
  199. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  200. }
  201. if (strtolower($sales) == 'all' || empty($sales)) {
  202. } else {
  203. if (utils::checkExist($sales, ";")) {
  204. $sql = "1!=1";
  205. $tt = explode(";", $sales);
  206. foreach ($tt as $t) {
  207. $t = trim($t);
  208. if (!empty($t))
  209. $sql .= " or sales_rep ilike '" . $t . "%'";
  210. }
  211. $sqlWhere1 .= " and ($sql)";
  212. } else
  213. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  214. }
  215. return $sqlWhere1;
  216. }
  217. function _getContactIDHandNew_Air($user, $schemas = "public") {
  218. $contact_id_user = _getCompanyContactHandNew_Air($user);
  219. $id = "";
  220. if ($schemas == "public") {
  221. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  222. } else {
  223. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  224. }
  225. foreach ($contact_id as $v) {
  226. if (empty($id))
  227. $id = trim($v['contacts_id']);
  228. else
  229. $id .= ";" . $v['contacts_id'];
  230. }
  231. if (!empty($contact_id_user)) {
  232. $id .= ";" . $contact_id_user;
  233. }
  234. return $id;
  235. }
  236. function _getCompanyContactHandNew_Air($user, $schemas = "public") {
  237. if ($schemas == "public") {
  238. return $user['air_customers'];
  239. } else {
  240. return $user[$schemas . '_ONLINE_USER']['air_customers'];
  241. }
  242. }
  243. function _getCompanyHandNew($user, $schemas = "public") {
  244. if ($schemas == "public") {
  245. return $user['company'];
  246. } else {
  247. if (empty($user['company'])) {
  248. return $user['company_name'];
  249. } else {
  250. return $user['company'];
  251. }
  252. }
  253. }
  254. function _getContactIDHandNew($user, $schemas = "public") {
  255. $contact_id_user = _getCompanyContactHandNew($user);
  256. $id = "";
  257. if ($schemas == "public") {
  258. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  259. } else {
  260. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  261. }
  262. foreach ($contact_id as $v) {
  263. if (empty($id))
  264. $id = trim($v['contacts_id']);
  265. else
  266. $id .= ";" . $v['contacts_id'];
  267. }
  268. if (!empty($contact_id_user)) {
  269. $id .= ";" . $contact_id_user;
  270. }
  271. return $id;
  272. }
  273. function _getCompanyContactHandNew($user, $schemas = "public") {
  274. if ($schemas == "public") {
  275. return $user['contact_id_user'];
  276. } else {
  277. return $user[$schemas . '_ONLINE_USER']['contact_id_user'];
  278. }
  279. }
  280. function _isDemo() {
  281. return $_SESSION['ONLINE_USER']['is_demo'] == "t";
  282. }
  283. function _is_only_vgm() {
  284. if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") {
  285. return TRUE;
  286. }
  287. return FALSE;
  288. }
  289. function _get_schemas() {
  290. return $_SESSION['schemas_list'];
  291. }
  292. function _getViewDocType($schemas = "public") {
  293. if ($schemas == "public") {
  294. return $_SESSION['ONLINE_USER']['view_doc_type'];
  295. } else {
  296. return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type'];
  297. }
  298. }
  299. function _canEdiVgm($schemas = "public") {
  300. if ($schemas == "public") {
  301. return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  302. } else {
  303. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  304. }
  305. }
  306. ?>