common.funxxxx.php 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958
  1. <?php
  2. function checkhtml($html)
  3. {
  4. global $charset;
  5. preg_match_all('/\\<([^\\<]+)\\>/is', $html, $ms);
  6. $searchs[] = '<';
  7. $replaces[] = '&lt;';
  8. $searchs[] = '>';
  9. $replaces[] = '&gt;';
  10. if ($ms[1]) {
  11. $allowtags = 'img|a|font|div|table|tbody|caption|tr|td|th|br|p|b|strong|i|u|em|span|ol|ul|li|blockquote|object|param|embed';
  12. $ms[1] = array_unique($ms[1]);
  13. foreach ($ms[1] as $value) {
  14. $searchs[] = '&lt;' . $value . '&gt;';
  15. $value = str_replace('&', '_uch_tmp_str_', $value);
  16. $value = mhtmlspecialchars($value);
  17. $value = str_replace('_uch_tmp_str_', '&', $value);
  18. $value = str_replace(array('\\', '/*'), array('.', '/.'), $value);
  19. $skipkeys = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload', 'javascript', 'script', 'eval', 'behaviour', 'expression', 'style', 'class');
  20. $skipstr = implode('|', $skipkeys);
  21. $value = preg_replace(array('/(' . $skipstr . ')/i'), '.', $value);
  22. if (!preg_match('/^[\\/|\\s]?(' . $allowtags . ')(\\s+|$)/is', $value)) {
  23. $value = '';
  24. }
  25. $replaces[] = empty($value) ? '' : '<' . str_replace('&quot;', '"', $value) . '>';
  26. }
  27. }
  28. $html = trim(str_replace($searchs, $replaces, $html));
  29. return $html;
  30. }
  31. function mhtmlspecialchars($string, $flags = NULL)
  32. {
  33. global $charset;
  34. if (is_array($string)) {
  35. foreach ($string as $key => $val) {
  36. $string[$key] = mhtmlspecialchars($val, $flags);
  37. }
  38. }
  39. else if ($flags === NULL) {
  40. $string = str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $string);
  41. if (strpos($string, '&amp;#') !== false) {
  42. $string = preg_replace('/&amp;((#(\\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string);
  43. }
  44. }
  45. else if (PHP_VERSION < '5.4.0') {
  46. $string = htmlspecialchars($string, $flags);
  47. }
  48. else {
  49. if ($charset == 'utf-8') {
  50. $charset = 'UTF-8';
  51. }
  52. else {
  53. $charset = 'ISO-8859-1';
  54. }
  55. $string = htmlspecialchars($string, $flags, $charset);
  56. }
  57. return $string;
  58. }
  59. function get_shop_tpl($opt = '', $s_uid = '')
  60. {
  61. global $db;
  62. global $db_mymps;
  63. if ($s_uid) {
  64. $member = get_member_group('', $s_uid);
  65. $option = $member['allow_tpl'];
  66. }
  67. else {
  68. $option = $db->getAll('SELECT * FROM `' . $db_mymps . 'member_tpl`');
  69. }
  70. foreach ($option as $key => $v) {
  71. $mymps .= '<option value=' . $v[tpl_path];
  72. if (is_array($opt)) {
  73. $mymps .= in_array($v[tpl_path], $opt) ? ' style = "background-color:#6EB00C;color:white" selected>' : '>';
  74. }
  75. else {
  76. $mymps .= $opt == $v[tpl_path] ? ' style = "background-color:#6EB00C;color:white" selected>' : '>';
  77. }
  78. $mymps .= $v[tpl_name] . '</option>';
  79. }
  80. return $mymps;
  81. }
  82. function filter_str($msg)
  83. {
  84. $msg = str_replace('"', '&quot;', $msg);
  85. $msg = str_replace('\'', '&#39;', $msg);
  86. $msg = str_replace('<', '&lt;', $msg);
  87. $msg = str_replace('>', '&gt;', $msg);
  88. $msg = str_replace(' ', ' &nbsp; &nbsp;', $msg);
  89. $msg = str_replace(' ', ' &nbsp; ', $msg);
  90. return $msg;
  91. }
  92. function get_member_docu($num = 10, $userid = '', $if_check = 1, $typeid = 0)
  93. {
  94. global $db;
  95. global $db_mymps;
  96. $where = 'WHERE 1';
  97. $where .= $if_check == 1 ? ' AND a.if_check = \'1\'' : '';
  98. $where .= $typeid ? ' AND a.typeid = \'' . $typeid . '\'' : '';
  99. $where .= $userid ? ' AND a.userid = \'' . $userid . '\'' : '';
  100. $num = $num ? 'LIMIT 0,' . $num : '';
  101. $query = $db->query('SELECT a.*,b.id AS uid,b.tname FROM `' . $db_mymps . 'member_docu` AS a LEFT JOIN `' . $db_mymps . 'member` AS b ON a.userid = b.userid ' . $where . ' ORDER BY a.id DESC ' . $num);
  102. while ($row = $db->fetchRow($query)) {
  103. $arr['id'] = $row['id'];
  104. $arr['uid'] = $row['uid'];
  105. $arr['userid'] = $row['userid'];
  106. $arr['tname'] = $row['tname'];
  107. $arr['typeid'] = $row['typeid'];
  108. $arr['title'] = $row['title'];
  109. $arr['pubtime'] = $row['pubtime'];
  110. $arr['imgpath'] = $row['imgpath'];
  111. $arr['hit'] = $row['hit'];
  112. $arr['pre_imgpath'] = $row['pre_imgpath'];
  113. $arr['tname_uri'] = Rewrite('store', array('uid' => $row['uid'], 'part' => 'index'));
  114. $arr['uri'] = Rewrite('store', array('uid' => $row['uid'], 'id' => $row['id'], 'part' => 'document'));
  115. $arr['uri_m'] = mRewrite('store', array('uid' => $row['uid'], 'id' => $row['id'], 'part' => 'document'));
  116. $docu[] = $arr;
  117. $arr = NULL;
  118. }
  119. return $docu;
  120. }
  121. function msetcookie($var, $val, $life = 0)
  122. {
  123. global $cookiepre;
  124. global $cookiedomain;
  125. global $cookiepath;
  126. global $timestamp;
  127. $cookie_pre = $cookiepre . '_';
  128. $cookie_path = $cookiepath ? $cookiepath : '/';
  129. $life = $life ? $life : 3600;
  130. $life = $timestamp + $life;
  131. setcookie($cookie_pre . $var, $val, $life, $cookie_path, $cookiedomain);
  132. }
  133. function mgetcookie($var)
  134. {
  135. global $cookiepre;
  136. $cookie_pre = $cookiepre . '_';
  137. $tvar = $cookie_pre . $var;
  138. return $_COOKIE[$tvar];
  139. }
  140. function is_email($email)
  141. {
  142. return 6 < strlen($email) && preg_match('/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+$/', $email);
  143. }
  144. function html2js($str)
  145. {
  146. $str = str_replace('\\', '\\\\', $str);
  147. $str = str_replace('\'', '\\\'', $str);
  148. $str = str_replace('"', '\\"', $str);
  149. $str = str_replace('\\t', '', $str);
  150. $str = explode('
  151. ', $str);
  152. for ($i = 0; $i < count($str); $i++) {
  153. $re .= 'document.writeln("' . $str[$i] . '");
  154. ';
  155. }
  156. return $re;
  157. }
  158. function textarea_post_change($mymps_string)
  159. {
  160. return nl2br(str_replace(' ', '&nbsp;', mhtmlspecialchars(trim($mymps_string))));
  161. }
  162. function de_textarea_post_change($mymps_string)
  163. {
  164. return str_replace('<br />', ' ', str_replace('&nbsp;', ' ', trim($mymps_string)));
  165. }
  166. function random($length = 5, $strtolower = 1)
  167. {
  168. $hash = '';
  169. $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
  170. $max = strlen($chars) - 1;
  171. mt_srand((double) microtime() * 1000000);
  172. for ($i = 0; $i < $length; $i++) {
  173. $hash .= $chars[mt_rand(0, $max)];
  174. }
  175. if ($strtolower == 1) {
  176. $hash = strtolower($hash);
  177. }
  178. return $hash;
  179. }
  180. function FileExt($filename)
  181. {
  182. if ($filename) {
  183. $temp_arr = explode('.', $filename);
  184. $file_ext = array_pop($temp_arr);
  185. $file_ext = trim($file_ext);
  186. $file_ext = strtolower($file_ext);
  187. }
  188. else {
  189. $file_ext = NULL;
  190. }
  191. return $file_ext;
  192. }
  193. function createfile($file, $str)
  194. {
  195. if (is_file($file)) {
  196. @unlink($file);
  197. }
  198. $fp = fopen($file, 'w');
  199. if (!is_writable($file)) {
  200. return false;
  201. }
  202. if (!fwrite($fp, $str)) {
  203. return false;
  204. }
  205. fclose($fp);
  206. return $file;
  207. }
  208. function createdir($path)
  209. {
  210. if (!file_exists($path)) {
  211. createdir(dirname($path));
  212. mkdir($path, 511);
  213. return true;
  214. }
  215. else if (file_exists($path)) {
  216. return true;
  217. }
  218. else {
  219. return false;
  220. }
  221. }
  222. function DelDir($dirName)
  223. {
  224. if (!is_dir($dirName)) {
  225. return false;
  226. }
  227. $handle = @opendir($dirName);
  228. while (($file = @readdir($handle)) !== false) {
  229. if ($file != '.' && $file != '..') {
  230. $dir = $dirName . '/' . $file;
  231. is_dir($dir) ? DelDir($dir) : @unlink($dir);
  232. }
  233. }
  234. closedir($handle);
  235. return rmdir($dirName);
  236. }
  237. function die_msg($msg)
  238. {
  239. return '<p style="font-family: Verdana, Tahoma; font-size: 11px;"><b>Mymps info:</b>' . $msg . '</p>';
  240. }
  241. function uc_call($func, $params = NULL)
  242. {
  243. restore_error_handler();
  244. if (!function_exists($func)) {
  245. include_once MYMPS_ROOT . '/uc_client/client.php';
  246. }
  247. $res = call_user_func_array($func, $params);
  248. return $res;
  249. }
  250. function get_editor($editor_name, $type, $value = '', $width = '100%', $height = '400px', $BasePath = '../include/kindeditor')
  251. {
  252. $html = '';
  253. $html .= '<script charset="utf-8" src="' . $BasePath . '/kindeditor-min.js"></script><script charset="utf-8" src="' . $BasePath . '/lang/zh_CN.js"></script>';
  254. switch ($type) {
  255. case 'Member':
  256. $html .= '<script>
  257. var editor;
  258. KindEditor.ready(function(K) {
  259. editor = K.create(\'textarea[name="' . $editor_name . '"]\', {
  260. resizeType : 1,
  261. filterMode : true,
  262. afterBlur: function () { this.sync(); },
  263. uploadJson : \'' . $BasePath . '/upload_user.php\' // 相对于当前页面的路径
  264. });
  265. });</script>';
  266. break;
  267. case 'information':
  268. $html .= '<script>
  269. var editor;
  270. KindEditor.ready(function(K) {
  271. editor = K.create(\'textarea[name="' . $editor_name . '"]\', {
  272. resizeType : 1,
  273. filterMode : true,
  274. afterBlur: function () { this.sync(); },
  275. items : [ \'fontname\', \'fontsize\', \'|\' ,\'forecolor\',\'hilitecolor\', \'bold\',\'italic\', \'underline\', \'strikethrough\', \'removeformat\', \'clearhtml\' ]
  276. });
  277. });</script>';
  278. break;
  279. default:
  280. $html .= '<script>
  281. var editor;
  282. KindEditor.ready(function(K) {
  283. editor = K.create(\'textarea[name="' . $editor_name . '"]\', {
  284. resizeType : 1,
  285. filterMode : true,
  286. afterBlur: function () { this.sync(); },
  287. uploadJson : \'' . $BasePath . '/upload_admin.php\' // 相对于当前页面的路径
  288. });
  289. });</script>';
  290. break;
  291. }
  292. $html .= '<textarea require="true" datatype="limit" msg="请填写信息内容描述" msgid="content" name="' . $editor_name . '" style="width:' . $width . ';height:' . $height . ';visibility:hidden;">' . $value . '</textarea>';
  293. return $html;
  294. }
  295. function mymps_chk_randcode($getcode = '')
  296. {
  297. global $timestamp;
  298. session_start();
  299. $getcode = trim(strtoupper($getcode));
  300. $sessioncode = $_SESSION['chkcode']['code'];
  301. if ($timestamp < $_SESSION['chkcode']['time'] && $sessioncode == $getcode) {
  302. return true;
  303. }
  304. else {
  305. return false;
  306. }
  307. }
  308. function CheckUserID($uid, $msgtitle = '用户名')
  309. {
  310. for ($i = 0; isset($uid[$i]); $i++) {
  311. if (128 < ord($ck_uid[$i])) {
  312. if (isset($uid[$i + 1]) && 64 < ord($uid[$i + 1])) {
  313. $i++;
  314. }
  315. else {
  316. return $msgtitle . '可能含有乱码,建议你改用英文字母和数字组合!';
  317. }
  318. }
  319. }
  320. return 'ok';
  321. }
  322. function GetIP()
  323. {
  324. if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  325. $cip = $_SERVER['HTTP_CLIENT_IP'];
  326. }
  327. else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  328. $cip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  329. }
  330. else if (!empty($_SERVER['REMOTE_ADDR'])) {
  331. $cip = $_SERVER['REMOTE_ADDR'];
  332. }
  333. else if (!pcclient()) {
  334. $cip = 'wap';
  335. }
  336. else {
  337. $cip = '';
  338. }
  339. preg_match('/[\\d\\.]{7,15}/', $cip, $cips);
  340. $cip = isset($cips[0]) ? $cips[0] : 'unknown';
  341. unset($cips);
  342. return $cip;
  343. }
  344. function utf8_unserialize($serial_str)
  345. {
  346. $out = @preg_replace('!s:(\\d+):"(.*?)";!se', '\'s:\'.strlen(\'$2\').\':"$2";\'', $serial_str);
  347. return unserialize($out);
  348. }
  349. function write_admin_record($msg)
  350. {
  351. global $admin_id;
  352. global $db_mymps;
  353. global $db;
  354. global $timestamp;
  355. $db->query('INSERT INTO `' . $db_mymps . 'admin_record_action` (id,adminid,ip,pubdate,action) VALUES (\'\',\'' . $admin_id . '\',\'' . getip() . ('\',\'' . $timestamp . '\',\'' . $msg . '\')'));
  356. }
  357. function write_msg($msg = '', $url = 'javascript:history.go(-1);', $action = '')
  358. {
  359. global $charset;
  360. global $db;
  361. global $db_mymps;
  362. global $mymps_global;
  363. global $mymps_starttime;
  364. !empty($action) && write_admin_record($msg);
  365. if (defined('IN_AJAX')) {
  366. echo '<script language=javascript>alert(\'' . $msg . '\');';
  367. echo $url == 'olmsg' ? '</script>' : 'window.location.href=\'' . $url . '\';</script>';
  368. }
  369. else {
  370. $hidden = $url == 'olmsg' ? 1 : '';
  371. if (!empty($msg) && !empty($url)) {
  372. if ($url == 'javascript:history.go(-1);') {
  373. $time_echo = 'setTimeout(\'JumpUrl()\',4000);';
  374. $msg = '<img src=\'' . $mymps_global[SiteUrl] . '/images/warn.gif\' align=\'absmiddle\'> ' . $msg;
  375. $goto = '<a href=\'' . $url . '\'>如果你的浏览器没反应,请点击这里...</a>';
  376. }
  377. else if ($url == 'olmsg') {
  378. $time_echo = $goto = '';
  379. }
  380. else {
  381. $time_echo = 'setTimeout(\'JumpUrl()\',3000);';
  382. $goto = '<a href=\'' . $url . '\'>如果你的浏览器没反应,请点击这里...</a>';
  383. }
  384. include MYMPS_ROOT . '/template/global/mymps_message.html';
  385. }
  386. else {
  387. if (empty($msg) && !empty($url)) {
  388. Header('HTTP/1.1 303 See Other');
  389. Header('Location: ' . $url);
  390. }
  391. }
  392. }
  393. if (!defined('NO_EXIT')) {
  394. $mymps_global = $db = $db_mymps = $charset = $timestamp = NULL;
  395. exit();
  396. }
  397. }
  398. function show_msg($msgs, $ms = '')
  399. {
  400. global $charset;
  401. global $db;
  402. global $db_mymps;
  403. if (!empty($ms) && $ms == 'record') {
  404. while (list($k, $v) = each($msgs)) {
  405. $str .= '<br>' . $v . '<br>';
  406. }
  407. write_admin_record(SpHtml2Text($str));
  408. }
  409. else {
  410. if (!empty($ms) && $ms != 'record') {
  411. write_admin_record($ms);
  412. }
  413. }
  414. $title = $mymps_global[SiteName] . '提示信息!';
  415. include MYMPS_ROOT . '/template/global/mymps_msg.html';
  416. while (list($k, $v) = each($msgs)) {
  417. $str .= '<br>' . $v . '<br>';
  418. }
  419. echo $str . '</div></div></div></center></body></html>';
  420. }
  421. function mymps_goto($url = '')
  422. {
  423. return '<script>window.document.location.href=\'' . $url . '\';</script>';
  424. }
  425. function is_member_info($id, $type = 'public')
  426. {
  427. global $db;
  428. global $db_mymps;
  429. if (empty($id)) {
  430. write_msg('操作失败!您没有选择对象!');
  431. }
  432. $type = $type == 'public' ? 'AND a.info_level != 0' : '';
  433. $post = $db->getRow('SELECT a.*,b.modid FROM `' . $db_mymps . 'information` AS a LEFT JOIN `' . $db_mymps . 'category` AS b ON a.catid = b.catid WHERE a.id = \'' . $id . '\' ' . $type);
  434. return $post;
  435. }
  436. function setParam($param1, $rewrite = 'active', $pre = '', $htmlpath = '')
  437. {
  438. if ($rewrite == 'rewrite') {
  439. $param = $pre;
  440. foreach ($param1 as $key) {
  441. ${$key} = &$GLOBALS[$key];
  442. $param .= ${$key} != NULL ? urlencode($key) . '-' . ${$key} . '-' : '';
  443. }
  444. }
  445. else if ($rewrite == 'rewrite_py') {
  446. $param = '';
  447. foreach ($param1 as $key) {
  448. ${$key} = &$GLOBALS[$key];
  449. $param .= ${$key} != NULL ? urlencode($key) . '-' . ${$key} . '-' : '';
  450. }
  451. }
  452. else if ($rewrite == 'html') {
  453. $param = $htmlpath;
  454. }
  455. else if ($rewrite == 'active') {
  456. if (defined('IN_ADMIN')) {
  457. foreach ($param1 as $key) {
  458. ${$key} = &$GLOBALS[$key];
  459. $param .= urlencode($key) . '=' . ${$key} . '&';
  460. }
  461. }
  462. else {
  463. foreach ($param1 as $key) {
  464. ${$key} = &$GLOBALS[$key];
  465. $param .= ${$key} != NULL ? urlencode($key) . '=' . ${$key} . '&' : '';
  466. }
  467. }
  468. }
  469. return $param;
  470. }
  471. function get_page_idin2($column = 'id', $sql = '', $number = '')
  472. {
  473. global $mymps_global;
  474. global $db;
  475. global $db_mymps;
  476. $page = $number ? ' LIMIT 0,' . $number : '';
  477. $query = $db->query($sql . $page);
  478. while ($row = $db->fetchRow($query)) {
  479. $idin .= $row[$column] . ',';
  480. }
  481. $idin = $idin ? substr($idin, 0, -1) : NULL;
  482. return $idin;
  483. }
  484. function get_page_idin($column = 'id', $sql = '', $cfg_page = '')
  485. {
  486. global $page;
  487. global $per_page;
  488. global $per_screen;
  489. global $pages_num;
  490. global $rows_num;
  491. global $mymps_global;
  492. global $db;
  493. global $db_mymps;
  494. $page = empty($page) || $page < 0 || !is_numeric($page) ? 1 : $page;
  495. $per_page = $cfg_page ? $cfg_page : ($per_page ? $per_page : $mymps_global['cfg_page_line']);
  496. $per_screen = !isset($per_screen) ? 10 : $per_screen;
  497. $pages_num = ceil($rows_num / $per_page);
  498. $query = $db->query($sql . ' limit ' . ($page - 1) * $per_page . ', ' . $per_page);
  499. while ($row = $db->fetchRow($query)) {
  500. $idin .= $row[$column] . ',';
  501. }
  502. $idin = $idin ? substr($idin, 0, -1) : NULL;
  503. return $idin;
  504. }
  505. function page1($sqlstr = '', $per_page = '')
  506. {
  507. global $page;
  508. global $per_screen;
  509. global $pages_num;
  510. global $rows_num;
  511. global $mymps_global;
  512. global $db;
  513. global $db_mymps;
  514. $page = empty($page) || $page < 0 || !is_numeric($page) ? 1 : $page;
  515. $per_page = $per_page ? $per_page : $mymps_global['cfg_page_line'];
  516. $per_screen = !isset($per_screen) ? 10 : $per_screen;
  517. $pages_num = ceil($rows_num / $per_page);
  518. return $db->getAll($sqlstr . ' limit ' . ($page - 1) * $per_page . ', ' . $per_page);
  519. }
  520. function page2($rewrite = 'active', $ext = '.html')
  521. {
  522. global $rows_num;
  523. global $page;
  524. global $pages_num;
  525. global $per_page;
  526. global $param;
  527. global $per_screen;
  528. global $dir_typename;
  529. $font_size = '10pt';
  530. $mid = ceil(($per_screen + 1) / 2);
  531. $nav = '';
  532. if ($page <= $mid) {
  533. $begin = 1;
  534. }
  535. else if ($pages_num - $mid < $page) {
  536. $begin = $pages_num - $per_screen + 1;
  537. }
  538. else {
  539. $begin = $page - $mid + 1;
  540. }
  541. $begin = $begin < 0 ? 1 : $begin;
  542. if ($rewrite == 'active') {
  543. $nav .= '<span class=anum>共' . $rows_num . '记录</span> ';
  544. if (1 < $page) {
  545. $nav .= '<a href=\'?' . $param . 'page=' . ($page - 1) . '\' title=\'第' . ($page - 1) . '页\'><上一页</a>';
  546. }
  547. if ($begin != 1) {
  548. $nav .= '<a href=\'?' . $param . '\' title=\'第1页\'>1 ...</a>';
  549. }
  550. $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen;
  551. for ($i = $begin; $i < $end; $i++) {
  552. if (!empty($i)) {
  553. $nav .= $page != $i ? '<a href=\'?' . $param . ('page=' . $i . '\' title=\'第' . $i . '页\'>' . $i . '</a> ') : ' <span class=current>' . $i . '</span> ';
  554. }
  555. }
  556. if ($end != $pages_num + 1) {
  557. $nav .= '<a href=\'?' . $param . ('page=' . $pages_num . '\' title=\'第' . $pages_num . '页\'>... ' . $pages_num . '</a>');
  558. }
  559. if ($page < $pages_num) {
  560. $nav .= '<a href=\'?' . $param . 'page=' . ($page + 1) . '\' title=\'第' . ($page + 1) . '页\'>下一页></a>';
  561. }
  562. }
  563. else if ($rewrite == 'rewrite') {
  564. $nav .= '<span class=anum>共' . $rows_num . '记录</span> ';
  565. if (1 < $page) {
  566. $nav .= '<a href=\'/' . $param . 'page-' . ($page - 1) . '.html\' title=\'第' . ($page - 1) . '页\'><上一页</a>';
  567. }
  568. if ($begin != 1) {
  569. $nav .= '<a href=\'/' . $param . 'page-1.html\' title=\'第1页\'>1 ...</a>';
  570. }
  571. $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen;
  572. for ($i = $begin; $i < $end; $i++) {
  573. if (!empty($i)) {
  574. $nav .= $page != $i ? '<a href=\'/' . $param . ('page-' . $i . '.html\' title=\'第' . $i . '页\'>' . $i . '</a> ') : ' <span class=current>' . $i . '</span> ';
  575. }
  576. }
  577. if ($end != $pages_num + 1) {
  578. $nav .= '<a href=\'/' . $param . ('page-' . $pages_num . '.html\' title=\'第' . $pages_num . '页\'>... ' . $pages_num . '</a>');
  579. }
  580. if ($page < $pages_num) {
  581. $nav .= '<a href=\'/' . $param . 'page-' . ($page + 1) . '.html\' title=\'第' . ($page + 1) . '页\'>下一页></a>';
  582. }
  583. }
  584. else if ($rewrite == 'rewrite_py') {
  585. $param = '/' . $dir_typename . '/' . $param;
  586. $nav .= '<span class=anum>共' . $rows_num . '记录</span> ';
  587. if (1 < $page) {
  588. $nav .= '<a href=\'' . $param . 'page-' . ($page - 1) . '/\' title=\'第' . ($page - 1) . '页\'><上一页</a>';
  589. }
  590. if ($begin != 1) {
  591. $nav .= '<a href=\'' . $param . 'page-1/\' title=\'第1页\'>1 ...</a>';
  592. }
  593. $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen;
  594. for ($i = $begin; $i < $end; $i++) {
  595. if (!empty($i)) {
  596. $nav .= $page != $i ? '<a href=\'' . $param . ('page-' . $i . '/\' title=\'第' . $i . '页\'>' . $i . '</a> ') : ' <span class=current>' . $i . '</span> ';
  597. }
  598. }
  599. if ($end != $pages_num + 1) {
  600. $nav .= '<a href=\'' . $param . ('page-' . $pages_num . '/\' title=\'第' . $pages_num . '页\'>... ' . $pages_num . '</a>');
  601. }
  602. if ($page < $pages_num) {
  603. $nav .= '<a href=\'' . $param . 'page-' . ($page + 1) . '/\' title=\'第' . ($page + 1) . '页\'>下一页></a>';
  604. }
  605. }
  606. else if ($rewrite == 'html') {
  607. $nav .= '<span class=anum>共' . $rows_num . '记录</span> ';
  608. if (1 < $page) {
  609. $nav .= '<a href=\'' . $param . 'list_' . ($page - 1) . $ext . '\' title=\'第' . ($page - 1) . '页\'><上一页</a>';
  610. }
  611. if ($begin != 1) {
  612. $nav .= '<a href=\'' . $param . 'list_1' . $ext . '\' title=\'第1页\'>1 ...</a>';
  613. }
  614. $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen;
  615. for ($i = $begin; $i < $end; $i++) {
  616. if (!empty($i)) {
  617. $nav .= $page != $i ? '<a href=\'' . $param . ('list_' . $i) . $ext . ('\' title=\'第' . $i . '页\'>' . $i . '</a> ') : ' <span class=current>' . $i . '</span> ';
  618. }
  619. }
  620. if ($end != $pages_num + 1) {
  621. $nav .= '<a href=\'' . $param . ('list_' . $pages_num . $ext . '\' title=\'第' . $pages_num . '页\'>... ' . $pages_num . '</a>');
  622. }
  623. if ($page < $pages_num) {
  624. $nav .= '<a href=\'' . $param . 'list_' . ($page + 1) . $ext . '\' title=\'第' . ($page + 1) . '页\'>下一页></a>';
  625. }
  626. }
  627. if (defined('IN_ADMIN') && 1 < $pages_num) {
  628. $nav .= '<form action="?' . substr($param, 0, -1) . '" method="post" name="pageform" id="pageform"><input name="page" type="text" class="page_input"><input type="submit" style="float:left; margin-left:3px" class="gray" value="GO!"></form>';
  629. }
  630. return $nav;
  631. }
  632. function get_advertisement($page = 'index')
  633. {
  634. $data = read_static_cache('adv_' . $page);
  635. return $data;
  636. }
  637. function GetUrl()
  638. {
  639. global $mymps_global;
  640. $url = (strstr($mymps_global['SiteUrl'], 'https:') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];
  641. if (isset($_SERVER['REQUEST_URI'])) {
  642. $url .= $_SERVER['REQUEST_URI'];
  643. }
  644. else {
  645. $url .= $_SERVER['PHP_SELF'];
  646. if (!empty($_SERVER['QUERY_STRING'])) {
  647. $url .= '?' . $_SERVER['QUERY_STRING'];
  648. }
  649. }
  650. return $url;
  651. }
  652. function GetTime($time = '', $c = 'Y-m-d H:i:s')
  653. {
  654. return $time ? date($c, $time) : '';
  655. }
  656. function globalassign()
  657. {
  658. global $mymps_global;
  659. global $docunav;
  660. global $city;
  661. if (CURSCRIPT == 'store') {
  662. $docunav = get_member_docunav();
  663. }
  664. }
  665. function mymps_tpl($str, $curscript = '')
  666. {
  667. global $mymps_global;
  668. $mymps_global['SiteStat'] = htmlspecialchars_decode($mymps_global['SiteStat']);
  669. $mymps_global['SiteStat'] = str_replace('type=\'/javascript\'', 'type=\'text/javascript\'', $mymps_global['SiteStat']);
  670. $curscript = $curscript ? $curscript : CURSCRIPT;
  671. if (defined('IN_SMT')) {
  672. if ($curscript == 'wap') {
  673. $tpldir = 'm';
  674. $templateid = 8;
  675. $tplfile = MYMPS_ROOT . '/' . $tpldir . '/template/' . $str . '.html';
  676. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  677. }
  678. else if ($curscript == 'search') {
  679. $tpldir = 'search';
  680. $templateid = 7;
  681. $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html';
  682. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  683. }
  684. else if ($curscript == 'store') {
  685. $tpldir = 'spaces/store';
  686. $templateid = '6';
  687. $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html';
  688. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  689. }
  690. else if ($curscript == 'coupon') {
  691. $tpldir = 'plugin/coupon/template';
  692. $templateid = '5';
  693. $tplfile = MYMPS_ROOT . '/' . $tpldir . '/' . $str . '.html';
  694. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  695. }
  696. else if ($curscript == 'group') {
  697. $tpldir = 'plugin/group/template';
  698. $templateid = '4';
  699. $tplfile = MYMPS_ROOT . '/' . $tpldir . '/' . $str . '.html';
  700. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  701. }
  702. else if ($curscript == 'goods') {
  703. $tpldir = 'plugin/goods/template';
  704. $templateid = '3';
  705. $tplfile = MYMPS_ROOT . '/' . $tpldir . '/' . $str . '.html';
  706. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  707. }
  708. else if ($curscript == 'space') {
  709. $tpldir = 'spaces/person';
  710. $templateid = 2;
  711. $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html';
  712. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  713. }
  714. else {
  715. $tpldir = $tpldir ? $tpldir : TPLDIR;
  716. $templateid = $templateid ? $templateid : TEMPLATEID;
  717. $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html';
  718. $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php';
  719. }
  720. @chktplrefresh($objfile, $tplfile, filemtime($objfile), $templateid, $tpldir);
  721. return $objfile;
  722. }
  723. else {
  724. return 'template/' . $str . '.tpl.php';
  725. }
  726. }
  727. function unknown_err_msg()
  728. {
  729. $msgs = '未知错误,可能与你提交的参数有关<br /><br />获取更多帮助请前往<a href=http://mymps.com.cn target=_blank>Mymps官方网站</a>';
  730. write_msg($msgs, 'olmsg');
  731. }
  732. function Spcnw_mid($str, $start, $slen)
  733. {
  734. $str_len = strlen($str);
  735. $strs = array();
  736. for ($i = 0; $i < $str_len; $i++) {
  737. if (128 < ord($str[$i])) {
  738. if ($i + 1 < $str_len) {
  739. $strs[] = $str[$i] . $str[$i + 1];
  740. }
  741. else {
  742. $strs[] = '';
  743. }
  744. $i++;
  745. }
  746. else {
  747. $strs[] = $str[$i];
  748. }
  749. }
  750. $wlen = count($strs);
  751. if ($wlen < $start) {
  752. return '';
  753. }
  754. $restr = '';
  755. $startdd = $start;
  756. $enddd = $startdd + $slen;
  757. for ($i = $startdd; $i < $enddd; $i++) {
  758. if (!isset($strs[$i])) {
  759. break;
  760. }
  761. $restr .= $strs[$i];
  762. }
  763. return $restr;
  764. }
  765. function Text2Html($txt)
  766. {
  767. $txt = str_replace(' ', ' ', $txt);
  768. $txt = str_replace('<', '&lt;', $txt);
  769. $txt = str_replace('>', '&gt;', $txt);
  770. $txt = preg_replace('/[
  771. ]{1,}/isU', '<br/>
  772. ', $txt);
  773. return $txt;
  774. }
  775. function SpHtml2Text($str)
  776. {
  777. $str = preg_replace('/<sty(.*)\\/style>|<scr(.*)\\/script>|<!--(.*)-->/isU', '', $str);
  778. $alltext = '';
  779. $start = 1;
  780. for ($i = 0; $i < strlen($str); $i++) {
  781. if ($start == 0 && $str[$i] == '>') {
  782. $start = 1;
  783. }
  784. else if ($start == 1) {
  785. if ($str[$i] == '<') {
  786. $start = 0;
  787. $alltext .= ' ';
  788. }
  789. else if (31 < ord($str[$i])) {
  790. $alltext .= $str[$i];
  791. }
  792. }
  793. }
  794. $alltext = str_replace(' ', ' ', $alltext);
  795. $alltext = preg_replace('/&([^;&]*)(;|&)/', '', $alltext);
  796. $alltext = preg_replace('/[ ]+/s', ' ', $alltext);
  797. return $alltext;
  798. }
  799. function clear_html($str = '', $clearbr = true)
  800. {
  801. $str = preg_replace('/<style .*?<\\/style>/is', '', $str);
  802. $str = preg_replace('/<script .*?<\\/script>/is', '', $str);
  803. $str = preg_replace('/<br \\s*\\/?\\/>/i', '
  804. ', $str);
  805. $str = preg_replace('/<\\/?p>/i', '
  806. ', $str);
  807. $str = preg_replace('/<\\/?td>/i', '
  808. ', $str);
  809. $str = preg_replace('/<\\/?div>/i', '
  810. ', $str);
  811. $str = preg_replace('/<\\/?blockquote>/i', '
  812. ', $str);
  813. $str = preg_replace('/<\\/?li>/i', '
  814. ', $str);
  815. $str = preg_replace('/\\&nbsp\\;/i', ' ', $str);
  816. $str = preg_replace('/\\&nbsp/i', ' ', $str);
  817. $str = preg_replace('/\\&amp\\;/i', '&', $str);
  818. $str = preg_replace('/\\&amp/i', '&', $str);
  819. $str = preg_replace('/\\&lt\\;/i', '<', $str);
  820. $str = preg_replace('/\\&lt/i', '<', $str);
  821. $str = preg_replace('/\\&ldquo\\;/i', '"', $str);
  822. $str = preg_replace('/\\&ldquo/i', '"', $str);
  823. $str = preg_replace('/\\&lsquo\\;/i', '\'', $str);
  824. $str = preg_replace('/\\&lsquo/i', '\'', $str);
  825. $str = preg_replace('/\\&rsquo\\;/i', '\'', $str);
  826. $str = preg_replace('/\\&rsquo/i', '\'', $str);
  827. $str = preg_replace('/\\&gt\\;/i', '>', $str);
  828. $str = preg_replace('/\\&gt/i', '>', $str);
  829. $str = preg_replace('/\\&rdquo\\;/i', '"', $str);
  830. $str = preg_replace('/\\&rdquo/i', '"', $str);
  831. $str = strip_tags($str);
  832. $str = html_entity_decode($str, ENT_QUOTES);
  833. $str = preg_replace('/\\&\\#.*?\\;/i', '', $str);
  834. $str = $clearbr ? str_replace(array('
  835. ', '
  836. ', '
  837. ', ' ', ' '), '', $str) : $str;
  838. return $str;
  839. }
  840. function mymps_count($table, $where = '')
  841. {
  842. global $db;
  843. global $db_mymps;
  844. $count = $db->getOne('SELECT count(*) FROM ' . $db_mymps . $table . ' ' . $where);
  845. if ($count) {
  846. return $count;
  847. }
  848. else {
  849. return 0;
  850. exit();
  851. }
  852. }
  853. function mymps_delete($table, $where = '')
  854. {
  855. global $db;
  856. global $db_mymps;
  857. $delete = $db->query('DELETE FROM ' . $db_mymps . $table . ' ' . $where);
  858. if ($delete) {
  859. return true;
  860. }
  861. else {
  862. return false;
  863. }
  864. }
  865. function mymps_del_all($table, $id, $idor = 'id')
  866. {
  867. global $db;
  868. global $db_mymps;
  869. $id = !empty($id) ? join(',', $id) : 0;
  870. $delete = $db->query('DELETE FROM ' . $db_mymps . $table . ' WHERE ' . $idor . ' IN (' . $id . ')');
  871. if ($delete) {
  872. return $id;
  873. }
  874. else {
  875. return false;
  876. }
  877. }
  878. function substring($str, $start, $length)
  879. {
  880. $len = $length;
  881. if ($length < 0) {
  882. $str = strrev($str);
  883. $len = 0 - $length;
  884. }
  885. $len = $len < strlen($str) ? $len : strlen($str);
  886. for ($i = $start; $i < $len; $i++) {
  887. if (160 < ord(substr($str, $i, 1))) {
  888. $tmpstr .= substr($str, $i, 2);
  889. $i++;
  890. }
  891. else {
  892. $tmpstr .= substr($str, $i, 1);
  893. }
  894. }
  895. if ($length < 0) {
  896. $tmpstr = strrev($tmpstr);
  897. }
  898. return $tmpstr;
  899. }
  900. function substring_utf8($str, $start, $lenth)
  901. {
  902. $len = strlen($str);
  903. $r = array();
  904. $n = 0;
  905. $m = 0;
  906. for ($i = 0; $i < $len; $i++) {
  907. $x = substr($str, $i, 1);
  908. $a = base_convert(ord($x), 10, 2);
  909. $a = substr('00000000' . $a, -8);
  910. if ($n < $start) {
  911. if (substr($a, 0, 1) == 0) {
  912. }
  913. else if (substr($a, 0, 3) == 110) {
  914. $i += 1;
  915. }
  916. else if (substr($a, 0, 4) == 1110) {
  917. $i += 2;
  918. }
  919. $n++;
  920. }
  921. else {
  922. if (substr($a, 0, 1) == 0) {
  923. $r[] = substr($str, $i, 1);
  924. }
  925. else if (substr($a, 0, 3) == 110) {
  926. $r[] = substr($str, $i, 2);
  927. $i += 1;
  928. }
  929. else if (substr($a, 0, 4) == 1110) {
  930. $r[] = substr($str, $i, 3);
  931. $i += 2;
  932. }
  933. else {
  934. $r[] = '';
  935. }
  936. if ($lenth <= ++$m) {
  937. break;
  938. }
  939. }
  940. }
  941. return join($r);
  942. }
  943. function get_info_life_time($time)
  944. {
  945. global $timestamp;
  946. if (empty($time)) {
  947. return '<font color=green>长期有效</font>';
  948. }
  949. else if ($time < $timestamp) {
  950. return '<font color=red>已过期</font>';
  951. }
  952. }
  953. function plugin_url($flag, $params = '')
  954. {
  955. global $mymps_global;
  956. $args = array('id' => 0, 'cate_id' => 0, 'areaid' => 0, 'page' => 0, 'orderby' => 0, 'catid' => 0, 'tuijian' => 0, 'cuxiao' => 0);
  957. extract(array_merge($args, $params));
  958. $uri = $mymps_global['SiteUrl'] . '/' . $flag . '.php';
  959. if ($cate_id && $areaid) {
  960. $uri .= '?cate_id=' . $cate_id . '&areaid=' . $areaid;
  961. $uri .= $orderby ? '&orderby=' . $orderby : '';
  962. $uri .= $page ? '&page=' . $page : '';
  963. }
  964. else if ($cate_id) {
  965. $uri .= '?cate_id=' . $cate_id;
  966. $uri .= $orderby ? '&orderby=' . $orderby : '';
  967. $uri .= $page ? '&page=' . $page : '';
  968. }
  969. else if ($catid) {
  970. $uri .= '?catid=' . $catid;
  971. $uri .= $orderby ? '&orderby=' . $orderby : '';
  972. $uri .= $page ? '&page=' . $page : '';
  973. }
  974. else if ($areaid) {
  975. $uri .= '?areaid=' . $areaid;
  976. $uri .= $orderby ? '&orderby=' . $orderby : '';
  977. $uri .= $page ? '&page=' . $page : '';
  978. }
  979. else if ($id) {
  980. $uri .= '?id=' . $id;
  981. }
  982. else if ($orderby) {
  983. $uri = $orderby ? '?orderby=' . $orderby : '';
  984. $uri .= $page ? '&page=' . $page : '';
  985. }
  986. $uri .= $tuijian == 1 ? '&tuijian=1' : '';
  987. $uri .= $cuxiao == 1 ? '&cuxiao=1' : '';
  988. unset($flag);
  989. unset($orderby);
  990. unset($page);
  991. unset($cate_id);
  992. unset($areaid);
  993. unset($id);
  994. unset($params);
  995. return $uri;
  996. }
  997. function Rewrite($types, $params)
  998. {
  999. global $seo;
  1000. global $mymps_global;
  1001. global $cat_dir;
  1002. global $db;
  1003. global $db_mymps;
  1004. $args = array('id' => 0, 'catid' => 0, 'areaid' => 0, 'page' => 0, 'orderby' => 0, 'tuijian' => 0, 'cuxiao' => 0, 'part' => 0, 'user' => 0, 'typeid' => 0, 'action' => 0, 'html_path' => 0, 'dir_typename' => 0, 'html_dir' => 0, 'type' => 0, 'uid' => 0);
  1005. extract(array_merge($args, $params));
  1006. if (!$seo) {
  1007. $seo = get_seoset();
  1008. }
  1009. $uri = '';
  1010. switch ($types) {
  1011. case 'category':
  1012. $uri = $mymps_global['SiteUrl'];
  1013. if ($seo['seo_force_category'] == 'rewrite_py') {
  1014. $rewrite = 3;
  1015. }
  1016. else if ($seo['seo_force_category'] == 'rewrite') {
  1017. $rewrite = 1;
  1018. }
  1019. else {
  1020. $rewrite = 0;
  1021. }
  1022. if ($catid && $rewrite == 1) {
  1023. $uri .= '/category-catid-' . $catid;
  1024. $uri .= $areaid ? '-areaid-' . $areaid : '';
  1025. $uri .= $page ? '-page-' . $page : '';
  1026. }
  1027. else {
  1028. if ($catid && $rewrite == 3) {
  1029. $uri .= '/' . $dir_typename;
  1030. $uri .= $areaid ? '-areaid-' . $areaid : '';
  1031. $uri .= $page ? '-page-' . $page : '';
  1032. }
  1033. else if ($catid) {
  1034. $uri .= '/category.php?catid=' . $catid;
  1035. if ($areaid) {
  1036. $uri .= '&amp;areaid=' . $areaid;
  1037. }
  1038. if ($page) {
  1039. $uri .= '&amp;page=' . $page;
  1040. }
  1041. }
  1042. }
  1043. break;
  1044. case 'info':
  1045. $uri = '';
  1046. if ($seo['seo_force_info'] == 'rewrite_py') {
  1047. $rewrite = 3;
  1048. }
  1049. else if ($seo['seo_force_info'] == 'rewrite') {
  1050. $rewrite = 1;
  1051. }
  1052. else {
  1053. $rewrite = 0;
  1054. }
  1055. if ($rewrite == 1) {
  1056. $uri .= '/information-id-' . $id;
  1057. }
  1058. else if ($rewrite == 3) {
  1059. if (empty($dir_typename)) {
  1060. $cat_dir = $cat_dir ? $cat_dir : get_category_dir();
  1061. $dir_typename = $cat_dir[$catid];
  1062. }
  1063. $uri .= '/' . $dir_typename . '/' . $id . '.html';
  1064. }
  1065. else if (empty($rewrite)) {
  1066. $uri .= '/information.php?id=' . $id;
  1067. }
  1068. break;
  1069. case 'about':
  1070. $rewrite = $seo['seo_force_about'] == 'rewrite' ? 1 : 0;
  1071. if (empty($part)) {
  1072. return false;
  1073. }
  1074. else {
  1075. if ($id && empty($page)) {
  1076. if ($part == 'announce') {
  1077. $uri .= $rewrite ? '/' . $part . '.html#' . $id : '/about.php?part=' . $part . '#' . $id;
  1078. }
  1079. else {
  1080. $uri .= $rewrite ? '/' . $part . '-id-' . $id : '/about.php?part=' . $part . '&amp;id=' . $id;
  1081. }
  1082. }
  1083. else {
  1084. if ($page && empty($id)) {
  1085. $uri .= $rewrite ? '/' . $part . '-page-' . $page : '/about.php?part=' . $part . '&amp;page=' . $page;
  1086. }
  1087. else {
  1088. if (empty($id) && empty($page) && empty($action)) {
  1089. $uri .= $rewrite ? '/' . $part : '/about.php?part=' . $part;
  1090. }
  1091. else {
  1092. if (empty($id) && empty($page) && $action) {
  1093. $uri .= $rewrite ? '/' . $part . '-action-' . $action : '/about.php?part=' . $part . '&amp;action=' . $action;
  1094. }
  1095. }
  1096. }
  1097. }
  1098. }
  1099. break;
  1100. case 'corp':
  1101. $rewrite = $seo['seo_force_yp'] == 'rewrite' ? 1 : 0;
  1102. if ($action == 'index' && empty($catid) && empty($areaid)) {
  1103. $uri .= $rewrite ? '/corporation' : '/corporation.php';
  1104. }
  1105. else {
  1106. if (empty($action) && $rewrite) {
  1107. $uri .= '/corporation' . ($catid ? '-catid-' . $catid : '');
  1108. $uri .= $areaid ? '-areaid-' . $areaid : '';
  1109. $uri .= $page ? '-page-' . $page : '';
  1110. }
  1111. else {
  1112. if (empty($action) && empty($rewrite)) {
  1113. $uri .= '/corporation.php?catid=' . $catid;
  1114. if ($page) {
  1115. $uri .= '&amp;page=' . $page;
  1116. }
  1117. if ($areaid) {
  1118. $uri .= '&amp;areaid=' . $areaid;
  1119. }
  1120. }
  1121. }
  1122. }
  1123. break;
  1124. case 'goods':
  1125. $uri = $mymps_global['SiteUrl'];
  1126. $rewrite = $seo['seo_force_goods'] == 'rewrite' ? 1 : 0;
  1127. if (empty($catid) && empty($orderby) && empty($id)) {
  1128. $uri .= $rewrite ? '/goods' : '/goods.php';
  1129. }
  1130. else {
  1131. if ($id && empty($catid) && empty($orderby)) {
  1132. $uri .= $rewrite ? '/goods-id-' . $id : '/goods.php?id=' . $id;
  1133. }
  1134. else if ($rewrite) {
  1135. $uri .= '/goods' . ($catid ? '-catid-' . $catid : '');
  1136. $uri .= $orderby ? '-orderby-' . $orderby : '';
  1137. $uri .= $cuxiao ? '-cuxiao-' . $cuxiao : '';
  1138. $uri .= $tuijian ? '-tuijian-' . $tuijian : '';
  1139. $uri .= $page ? '-page-' . $page : '';
  1140. }
  1141. else if (empty($rewrite)) {
  1142. $uri .= '/goods.php?' . ($catid ? 'catid=' . $catid : '');
  1143. if ($orderby) {
  1144. $uri .= '&amp;orderby=' . $orderby;
  1145. }
  1146. if ($cuxiao) {
  1147. $uri .= '&amp;cuxiao=' . $cuxiao;
  1148. }
  1149. if ($tuijian) {
  1150. $uri .= '&amp;tuijian=' . $tuijian;
  1151. }
  1152. if ($page) {
  1153. $uri .= '&amp;page=' . $page;
  1154. }
  1155. }
  1156. }
  1157. break;
  1158. case 'news':
  1159. $rewrite = $seo['seo_force_news'] == 'rewrite' ? 1 : 0;
  1160. if ($action == 'index' && empty($catid) && empty($id)) {
  1161. $uri .= $rewrite ? '/news' : '/news.php';
  1162. }
  1163. else {
  1164. if ($id && empty($catid) && empty($action)) {
  1165. $uri .= $rewrite ? '/news-id-' . $id : '/news.php?id=' . $id;
  1166. }
  1167. else {
  1168. if ($catid && $rewrite && empty($id) && empty($action)) {
  1169. $uri .= '/news-catid-' . $catid;
  1170. $uri .= $page ? '-page-' . $page : '';
  1171. }
  1172. else {
  1173. if ($catid && empty($rewrite) && empty($id) && empty($action)) {
  1174. $uri .= '/news.php?catid=' . $catid;
  1175. if ($page) {
  1176. $uri .= '&amp;page=' . $page;
  1177. }
  1178. }
  1179. }
  1180. }
  1181. }
  1182. break;
  1183. case 'space':
  1184. $uri = $mymps_global['SiteUrl'] . '/';
  1185. $rewrite = $seo['seo_force_space'] == 'rewrite' && inchinese($user) ? 1 : 0;
  1186. if (empty($user)) {
  1187. return false;
  1188. }
  1189. else {
  1190. $uri .= $rewrite ? 'space/' . $user . '/' : 'space.php?user=' . urlencode($user);
  1191. }
  1192. break;
  1193. case 'store':
  1194. $rewrite = $seo['seo_force_store'] == 'domain' ? 2 : ($seo['seo_force_store'] == 'rewrite' ? 1 : 0);
  1195. if ($rewrite == 2) {
  1196. $rootdomain = str_replace('http://www.', '', $mymps_global[SiteUrl]);
  1197. }
  1198. else {
  1199. $rootdomain = '';
  1200. }
  1201. if (!$part) {
  1202. $part = 'index';
  1203. }
  1204. if (empty($uid)) {
  1205. return false;
  1206. }
  1207. else {
  1208. if ($uid && $part == 'index' && $rewrite == 2) {
  1209. $uri = 'http://' . $uid . '.' . $rootdomain;
  1210. }
  1211. else {
  1212. if ($uid && $part == 'index' && $rewrite == 1) {
  1213. $uri .= '/store-' . $uid . '/';
  1214. }
  1215. else {
  1216. if ($uid && $part == 'index' && !$rewrite) {
  1217. $uri .= '/store.php?uid=' . $uid;
  1218. }
  1219. else {
  1220. if ($uid && $part && $rewrite == 2) {
  1221. $uri = 'http://' . $uid . '.' . $rootdomain . '/' . $part;
  1222. $uri .= $type ? '-' . $type : '';
  1223. $uri .= $typeid ? '-typeid-' . $typeid : '';
  1224. $uri .= $id ? '-id-' . $id : '';
  1225. $uri .= $page ? '-page-' . $page : '';
  1226. }
  1227. else {
  1228. if ($uid && $part && $rewrite == 1) {
  1229. $uri .= '/store-' . $uid . '/' . $part;
  1230. $uri .= $type ? '-type-' . $type : '';
  1231. $uri .= $typeid ? '-typeid-' . $typeid : '';
  1232. $uri .= $id ? '-id-' . $id : '';
  1233. $uri .= $page ? '-page-' . $page : '';
  1234. }
  1235. else {
  1236. if ($uid && $part && !$rewrite) {
  1237. $uri .= '/store.php?uid=' . $uid . '&amp;part=' . $part;
  1238. $uri .= $type ? '&amp;type=' . $type : '';
  1239. $uri .= $typeid ? '&amp;typeid=' . $typeid : '';
  1240. $uri .= $id ? '&amp;id=' . $id : '';
  1241. $uri .= $page ? '&amp;page=' . $page : '';
  1242. }
  1243. }
  1244. }
  1245. }
  1246. }
  1247. }
  1248. }
  1249. break;
  1250. default:
  1251. return false;
  1252. break;
  1253. }
  1254. if ($rewrite == 3 && $types == 'category') {
  1255. $uri .= '/';
  1256. }
  1257. else if (in_array($rewrite, array(1, 2))) {
  1258. $uri .= (empty($part) || $part == 'index') && in_array($types, array('space', 'store')) ? '/' : $part === 'announce' && !empty($id) ? '' : '.html';
  1259. }
  1260. unset($seo);
  1261. unset($rewrite);
  1262. return $uri;
  1263. }
  1264. function mRewrite($types, $params = array())
  1265. {
  1266. global $seo;
  1267. global $mymps_global;
  1268. global $cat_dir;
  1269. global $db;
  1270. global $db_mymps;
  1271. global $mayimobile;
  1272. $args = array('id' => 0, 'catid' => 0, 'areaid' => 0, 'page' => 0, 'orderby' => 0, 'tuijian' => 0, 'cuxiao' => 0, 'part' => 0, 'user' => 0, 'typeid' => 0, 'action' => 0, 'dir_typename' => 0, 'type' => 0, 'uid' => 0);
  1273. extract(array_merge($args, $params));
  1274. if (!$mayimobile) {
  1275. $mayimobile = get_mobile_settings();
  1276. $mayimobile['mobiledomain'] = $mayimobile['mobiledomain'] ? $mayimobile['mobiledomain'] : $mymps_global['SiteUrl'] . '/m';
  1277. }
  1278. if (!$seo) {
  1279. $seo = get_seoset();
  1280. }
  1281. $uri = $mayimobile['mobiledomain'];
  1282. switch ($types) {
  1283. case 'category':
  1284. if ($seo['seo_force_category'] == 'rewrite_py') {
  1285. $rewrite = 3;
  1286. }
  1287. else if ($seo['seo_force_category'] == 'rewrite') {
  1288. $rewrite = 1;
  1289. }
  1290. else {
  1291. $rewrite = 0;
  1292. }
  1293. if ($catid && $rewrite == 1) {
  1294. $uri .= '/category-catid-' . $catid;
  1295. $uri .= $areaid ? '-areaid-' . $areaid : '';
  1296. $uri .= $page ? '-page-' . $page : '';
  1297. }
  1298. else {
  1299. if ($catid && $rewrite == 3) {
  1300. $uri .= '/' . $dir_typename;
  1301. $uri .= $areaid ? '-areaid-' . $areaid : '';
  1302. $uri .= $page ? '-page-' . $page : '';
  1303. }
  1304. else if ($catid) {
  1305. $uri .= '/index.php?mod=category&catid=' . $catid;
  1306. if ($areaid) {
  1307. $uri .= '&amp;areaid=' . $areaid;
  1308. }
  1309. if ($page) {
  1310. $uri .= '&amp;page=' . $page;
  1311. }
  1312. }
  1313. }
  1314. break;
  1315. case 'info':
  1316. if ($seo['seo_force_info'] == 'rewrite_py') {
  1317. $rewrite = 3;
  1318. }
  1319. else if ($seo['seo_force_info'] == 'rewrite') {
  1320. $rewrite = 1;
  1321. }
  1322. else {
  1323. $rewrite = 0;
  1324. }
  1325. if ($rewrite == 1) {
  1326. $uri .= '/information-id-' . $id;
  1327. }
  1328. else if ($rewrite == 3) {
  1329. if (empty($dir_typename)) {
  1330. $cat_dir = $cat_dir ? $cat_dir : get_category_dir();
  1331. $dir_typename = $cat_dir[$catid];
  1332. }
  1333. $uri .= '/' . $dir_typename . '/' . $id . '.html';
  1334. }
  1335. else if (empty($rewrite)) {
  1336. $uri .= '/index.php?mod=information&id=' . $id;
  1337. }
  1338. break;
  1339. case 'about':
  1340. $rewrite = $seo['seo_force_about'] == 'rewrite' ? 1 : 0;
  1341. if (empty($part)) {
  1342. return false;
  1343. }
  1344. else if ($id) {
  1345. $uri .= $rewrite ? '/' . $part . '-id-' . $id : '/index.php?mod=' . $part . '&amp;id=' . $id;
  1346. }
  1347. else if (empty($id)) {
  1348. $uri .= $rewrite ? '/' . $part : '/index.php?mod=' . $part;
  1349. }
  1350. break;
  1351. case 'corp':
  1352. $rewrite = $seo['seo_force_yp'] == 'rewrite' ? 1 : 0;
  1353. if ($action == 'index' && empty($catid) && empty($areaid)) {
  1354. $uri .= $rewrite ? '/corporation' : '/index.php?mod=corp';
  1355. }
  1356. else {
  1357. if (empty($action) && $rewrite) {
  1358. $uri .= '/corporation' . ($catid ? '-catid-' . $catid : '');
  1359. $uri .= $areaid ? '-areaid-' . $areaid : '';
  1360. $uri .= $page ? '-page-' . $page : '';
  1361. }
  1362. else {
  1363. if (empty($action) && empty($rewrite)) {
  1364. $uri .= '/index.php?mod=corp&catid=' . $catid;
  1365. if ($page) {
  1366. $uri .= '&amp;page=' . $page;
  1367. }
  1368. if ($areaid) {
  1369. $uri .= '&amp;areaid=' . $areaid;
  1370. }
  1371. }
  1372. }
  1373. }
  1374. break;
  1375. case 'goods':
  1376. $rewrite = $seo['seo_force_goods'] == 'rewrite' ? 1 : 0;
  1377. if (empty($catid) && empty($orderby) && empty($id)) {
  1378. $uri .= $rewrite ? '/goods' : '/index.php?mod=goods';
  1379. }
  1380. else {
  1381. if ($id && empty($catid) && empty($orderby)) {
  1382. $uri .= $rewrite ? '/goods-id-' . $id : '/index.php?mod=goods&id=' . $id;
  1383. }
  1384. else if ($rewrite) {
  1385. $uri .= '/goods' . ($catid ? '-catid-' . $catid : '');
  1386. $uri .= $orderby ? '-orderby-' . $orderby : '';
  1387. $uri .= $cuxiao ? '-cuxiao-' . $cuxiao : '';
  1388. $uri .= $tuijian ? '-tuijian-' . $tuijian : '';
  1389. $uri .= $page ? '-page-' . $page : '';
  1390. }
  1391. else if (empty($rewrite)) {
  1392. $uri .= '/index.php?mod=goods' . ($catid ? '&catid=' . $catid : '');
  1393. if ($orderby) {
  1394. $uri .= '&amp;orderby=' . $orderby;
  1395. }
  1396. if ($cuxiao) {
  1397. $uri .= '&amp;cuxiao=' . $cuxiao;
  1398. }
  1399. if ($tuijian) {
  1400. $uri .= '&amp;tuijian=' . $tuijian;
  1401. }
  1402. if ($page) {
  1403. $uri .= '&amp;page=' . $page;
  1404. }
  1405. }
  1406. }
  1407. break;
  1408. case 'news':
  1409. $rewrite = $seo['seo_force_news'] == 'rewrite' ? 1 : 0;
  1410. if ($action == 'index' && empty($catid) && empty($id)) {
  1411. $uri .= $rewrite ? '/news' : '/index.php?mod=news';
  1412. }
  1413. else {
  1414. if ($id && empty($catid) && empty($action)) {
  1415. $uri .= $rewrite ? '/news-id-' . $id : '/index.php?mod=news&id=' . $id;
  1416. }
  1417. else {
  1418. if ($catid && $rewrite && empty($id) && empty($action)) {
  1419. $uri .= '/news-catid-' . $catid;
  1420. $uri .= $page ? '-page-' . $page : '';
  1421. }
  1422. else {
  1423. if ($catid && empty($rewrite) && empty($id) && empty($action)) {
  1424. $uri .= '/index.php?mod=news&catid=' . $catid;
  1425. if ($page) {
  1426. $uri .= '&amp;page=' . $page;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. break;
  1433. case 'space':
  1434. $uri = '/';
  1435. $rewrite = $seo['seo_force_space'] == 'rewrite' && inchinese($user) ? 1 : 0;
  1436. if (empty($user)) {
  1437. return false;
  1438. }
  1439. else {
  1440. $uri .= $rewrite ? 'space/' . $user . '/' : 'index.php?mod=user&user=' . urlencode($user);
  1441. }
  1442. break;
  1443. case 'store':
  1444. $rewrite = $seo['seo_force_store'] == 'rewrite' ? 1 : 0;
  1445. if (!$part) {
  1446. $part = 'index';
  1447. }
  1448. if (empty($uid)) {
  1449. return false;
  1450. }
  1451. else {
  1452. if ($uid && $part == 'index' && $rewrite == 1) {
  1453. $uri .= '/store-' . $uid . '/';
  1454. }
  1455. else {
  1456. if ($uid && $part == 'index' && !$rewrite) {
  1457. $uri .= '/index.php?mod=store&id=' . $uid;
  1458. }
  1459. else {
  1460. if ($uid && $part && $rewrite == 1) {
  1461. $uri .= '/store-' . $uid . '/' . $part;
  1462. $uri .= $type ? '-type-' . $type : '';
  1463. $uri .= $typeid ? '-typeid-' . $typeid : '';
  1464. $uri .= $id ? '-id-' . $id : '';
  1465. $uri .= $page ? '-page-' . $page : '';
  1466. }
  1467. else {
  1468. if ($uid && $part && !$rewrite) {
  1469. $uri .= '/index.php?mod=store&id=' . $uid . '&amp;action=' . $part;
  1470. $uri .= $type ? '&amp;type=' . $type : '';
  1471. $uri .= $typeid ? '&amp;typeid=' . $typeid : '';
  1472. $uri .= $id ? '&amp;id=' . $id : '';
  1473. $uri .= $page ? '&amp;page=' . $page : '';
  1474. }
  1475. }
  1476. }
  1477. }
  1478. }
  1479. break;
  1480. default:
  1481. return false;
  1482. break;
  1483. }
  1484. if ($rewrite == 3 && $types == 'category') {
  1485. $uri .= '/';
  1486. }
  1487. else if (in_array($rewrite, array(1, 2))) {
  1488. $uri .= (empty($part) || $part == 'index') && in_array($types, array('space', 'store')) ? '/' : $part === 'announce' && !empty($id) ? '' : '.html';
  1489. }
  1490. unset($seo);
  1491. unset($rewrite);
  1492. return $uri;
  1493. }
  1494. function inchinese($text)
  1495. {
  1496. return @ereg('^[a-z0-9_.-]+$', $text);
  1497. }
  1498. function get_member_docutype()
  1499. {
  1500. $data = read_static_cache('document_type');
  1501. if ($data === false) {
  1502. $query = $GLOBALS['db']->query('SELECT * FROM `' . $GLOBALS['db_mymps'] . 'member_docutype` WHERE ifview = 2 ORDER BY displayorder,typeid DESC');
  1503. while ($row = $GLOBALS['db']->fetchRow($query)) {
  1504. $res[$row['typeid']]['typeid'] = $row['typeid'];
  1505. $res[$row['typeid']]['typename'] = $row['typename'];
  1506. $res[$row['typeid']]['arrid'] = $row['arrid'];
  1507. }
  1508. write_static_cache('document_type', $res);
  1509. }
  1510. else {
  1511. $res = $data;
  1512. }
  1513. return $res;
  1514. }
  1515. function mymps_get_lifebox($num = '12')
  1516. {
  1517. global $db;
  1518. global $db_mymps;
  1519. $query = $db->query('SELECT * FROM `' . $db_mymps . 'lifebox` WHERE if_view = 2 ORDER BY displayorder DESC LIMIT 0,' . $num);
  1520. while ($row = $db->fetchRow($query)) {
  1521. $list[$row['id']]['id'] = $row['id'];
  1522. $list[$row['id']]['lifename'] = $row['lifename'];
  1523. $list[$row['id']]['lifeurl'] = $row['lifeurl'];
  1524. }
  1525. return $list;
  1526. }
  1527. function mymps_get_links($ifindex = 2, $catid = 0)
  1528. {
  1529. global $db;
  1530. global $db_mymps;
  1531. global $mymps_global;
  1532. static $links;
  1533. $data = read_static_cache('friendlink');
  1534. if ($data === false) {
  1535. $sql = 'SELECT weblogo, webname, url FROM `' . $db_mymps . 'flink` WHERE ischeck = \'2\' AND ifindex = \'2\' ORDER BY ordernumber ASC';
  1536. $res = $db->getAll($sql);
  1537. $links['index']['img'] = $links['index']['txt'] = array();
  1538. $i = 0;
  1539. foreach ($res as $row) {
  1540. if (!empty($row['weblogo'])) {
  1541. $i++;
  1542. $links['index']['img'][] = array('name' => $row['webname'], 'url' => $row['url'], 'logo' => $row['weblogo']);
  1543. }
  1544. else {
  1545. $links['index']['txt'][] = array('name' => $row['webname'], 'url' => $row['url']);
  1546. }
  1547. }
  1548. if ($i == 0) {
  1549. $links['index']['img'] = '';
  1550. }
  1551. $sql = 'SELECT id,webname,url,catid FROM `' . $db_mymps . 'flink` WHERE ischeck = \'2\' AND catid > 0 ORDER BY ordernumber ASC';
  1552. $query = $db->query($sql);
  1553. while ($row = $db->fetchRow($query)) {
  1554. $links[$row['catid']][$row['id']]['name'] = $row['webname'];
  1555. $links[$row['catid']][$row['id']]['url'] = $row['url'];
  1556. }
  1557. write_static_cache('friendlink', $links);
  1558. }
  1559. else {
  1560. $links = $data;
  1561. }
  1562. return $ifindex == 2 ? $links['index'] : $links[$catid];
  1563. }
  1564. function mymps_get_announce($num = '12')
  1565. {
  1566. global $db;
  1567. global $db_mymps;
  1568. global $timestamp;
  1569. $query = $db->query('SELECT * FROM `' . $db_mymps . 'announce` WHERE begintime<\'' . $timestamp . '\' AND (endtime=\'0\' OR endtime>\'' . $timestamp . '\') ORDER BY id DESC LIMIT 0,' . $num);
  1570. while ($row = $db->fetchRow($query)) {
  1571. $list[$row['id']]['id'] = $row['id'];
  1572. $list[$row['id']]['title'] = $row['title'];
  1573. $list[$row['id']]['pubdate'] = $row['pubdate'];
  1574. $list[$row['id']]['begintime'] = $row['begintime'];
  1575. $list[$row['id']]['endtime'] = $row['endtime'];
  1576. $list[$row['id']]['titlecolor'] = $row['titlecolor'];
  1577. $list[$row['id']]['author'] = $row['author'];
  1578. $list[$row['id']]['content'] = $row['content'];
  1579. $list[$row['id']]['uri'] = $row['redirecturl'] ? $row['redirecturl'] : rewrite('about', array('part' => 'announce', 'id' => $row['id'], 'html_path' => '/announce/index' . $seo['seo_htmlext'] . '#' . $row['id']));
  1580. }
  1581. return $list;
  1582. }
  1583. function mymps_get_telephone($num = '20')
  1584. {
  1585. global $db;
  1586. global $db_mymps;
  1587. $query = $db->query('SELECT * FROM `' . $db_mymps . 'telephone` WHERE if_view = 2 ORDER BY displayorder DESC LIMIT 0,' . $num);
  1588. while ($row = $db->fetchRow($query)) {
  1589. $list[$row['id']]['telname'] = $row['telname'];
  1590. $list[$row['id']]['telnumber'] = $row['telnumber'];
  1591. $list[$row['id']]['if_bold'] = $row['if_bold'];
  1592. $list[$row['id']]['color'] = $row['color'];
  1593. }
  1594. return $list;
  1595. }
  1596. function get_member_docunav()
  1597. {
  1598. $data = get_member_docutype();
  1599. foreach ($data as $key => $value) {
  1600. $docu[$value['typeid']]['typename'] = $value['typename'];
  1601. $docu[$value['typeid']]['typeid'] = $value['typeid'];
  1602. $docu[$value['typeid']]['uri'] = rewrite('store', array('uid' => $GLOBALS['uid'], 'part' => 'document', 'typeid' => $value['typeid']));
  1603. }
  1604. return $docu;
  1605. }
  1606. function get_seoset()
  1607. {
  1608. $data = read_static_cache('seoset');
  1609. if ($data === false) {
  1610. $query = $GLOBALS['db']->query('SELECT description,value FROM `' . $GLOBALS['db_mymps'] . 'config` WHERE type = \'seo\'');
  1611. while ($row = $GLOBALS['db']->fetchRow($query)) {
  1612. $res[$row['description']] = $row['value'];
  1613. }
  1614. write_static_cache('seoset', $res);
  1615. }
  1616. else {
  1617. $res = $data;
  1618. }
  1619. return $res;
  1620. }
  1621. function mayi($agree_domain)
  1622. {
  1623. if (empty($HTTP_HOST)) {
  1624. if (myget('HTTP_HOST')) {
  1625. $HTTP_HOST = myget('HTTP_HOST');
  1626. }
  1627. else {
  1628. $HTTP_HOST = '';
  1629. }
  1630. }
  1631. $agree_domain = '.127.0.0.1,mayicms.com,mymps.com.cn,' . $agree_domain;
  1632. $now_domain = getRd(htmlspecialchars($HTTP_HOST));
  1633. $now_domain = str_replace(array('.www.', '.cn.'), array('', ''), $now_domain);
  1634. if (!in_array($now_domain, explode(',', $agree_domain))) {
  1635. exit();
  1636. }
  1637. }
  1638. function myget($var_name)
  1639. {
  1640. if (isset($_SERVER[$var_name])) {
  1641. return $_SERVER[$var_name];
  1642. }
  1643. if (isset($_ENV[$var_name])) {
  1644. return $_ENV[$var_name];
  1645. }
  1646. if (getenv($var_name)) {
  1647. return getenv($var_name);
  1648. }
  1649. if (function_exists('apache_getenv') && apache_getenv($var_name, true)) {
  1650. return apache_getenv($var_name, true);
  1651. }
  1652. return '';
  1653. }
  1654. function getRd($domain)
  1655. {
  1656. $suffix = array('ren', 'wang', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cq', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'es', 'et', 'ev', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gr', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'in', 'io', 'iq', 'ir', 'is', 'it', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'mg', 'mh', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nt', 'nu', 'nz', 'om', 'qa', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'pt', 'pw', 'py', 're', 'ro', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'va', 'vc', 've', 'vg', 'vn', 'vu', 'wf', 'ws', 'ye', 'yu', 'za', 'zm', 'zr', 'zw', 'com', 'edu', 'gov', 'int', 'mil', 'net', 'org');
  1657. $domainArr = explode('.', $domain);
  1658. $l = count($domainArr);
  1659. $key = 0;
  1660. for ($i = 0; $i < $l; $i++) {
  1661. if (in_array($domainArr[$i], $suffix)) {
  1662. $key = $i;
  1663. break;
  1664. }
  1665. }
  1666. $inSuffixs = '';
  1667. for ($i = $key; $i < $l; $i++) {
  1668. $inSuffixs .= '.' . $domainArr[$i];
  1669. }
  1670. return $domainArr[$key - 1] . $inSuffixs;
  1671. }
  1672. function get_location($type = 'category', $cat = 0, $str = '', $extra = '', $pdetail = '')
  1673. {
  1674. global $seo;
  1675. global $pluginsettings;
  1676. global $mymps_global;
  1677. $raquo = $mymps_global['cfg_raquo'];
  1678. $mymps_global['SiteCity'] = $mymps_global['SiteCity'] && !in_array($type, array('channel', 'news')) ? $mymps_global['SiteCity'] : '';
  1679. if (!$seo) {
  1680. $seo = get_seoset();
  1681. }
  1682. $location = '当前位置:<a href="' . $mymps_global['SiteUrl'] . '">' . $GLOBALS['mymps_global']['SiteName'] . '</a>';
  1683. if ($type == 'news') {
  1684. $page_title = $pluginsettings['news']['seotitle'] ? $pluginsettings['news']['seotitle'] : $mymps_global['SiteName'];
  1685. }
  1686. else {
  1687. $page_title = $mymps_global['SiteName'];
  1688. }
  1689. if ($seo['seo_sitename'] && $type == 'index' && empty($cat) && empty($str)) {
  1690. $page_title = $page_title . '-' . $seo['seo_sitename'];
  1691. }
  1692. if (in_array($type, array('category', 'channel', 'corp', 'news'))) {
  1693. if (0 < $cat) {
  1694. $cat_arr = get_parent_cats($type, $cat);
  1695. }
  1696. else {
  1697. $cat_arr = array();
  1698. }
  1699. if ($type == 'channel') {
  1700. $location .= ' <code>' . $raquo . '</code> <a href="' . rewrite('news', array('action' => 'index', 'html_path' => $seo['seo_htmldir'] . $seo['seo_htmlnewsdir'] . '/')) . '">热点资讯</a>';
  1701. $page_title = '热点资讯-' . $page_title;
  1702. }
  1703. else if ($type == 'corp') {
  1704. $location .= ' <code>' . $raquo . '</code> <a href="' . rewrite('corp', array('action' => 'index')) . '">商家</a>';
  1705. $page_title = '商家-' . $page_title;
  1706. }
  1707. if (!empty($cat_arr)) {
  1708. krsort($cat_arr);
  1709. foreach ($cat_arr as $val) {
  1710. $page_title = mhtmlspecialchars($GLOBALS['cat']['title'] && $GLOBALS['catid'] == $val['catid'] ? $GLOBALS['cat']['title'] : ($type == 'corp' ? $val['corpname'] : $val['catname'])) . '-' . $page_title;
  1711. $location .= ' <code> ' . $raquo . ' </code> <a href="' . $val['uri'] . '">' . mhtmlspecialchars($type == 'corp' ? $val['corpname'] : $mymps_global['SiteCity'] . $val['catname']) . '</a>';
  1712. }
  1713. }
  1714. $page_title = $extra ? $extra . $page_title : $page_title;
  1715. $page_title = $mymps_global['SiteCity'] . $page_title;
  1716. }
  1717. if (!empty($str)) {
  1718. $page_title = $str . ($type == 'space' ? '的个人空间' : '') . '-' . $page_title;
  1719. $location .= ' <code>' . $raquo . '</code> &nbsp;' . $str . ($type == 'space' ? '的个人空间' : '');
  1720. }
  1721. $page_title = $pdetail ? $pdetail : $page_title;
  1722. $cur = array('page_title' => $page_title, 'location' => $location);
  1723. unset($page_title);
  1724. unset($cat);
  1725. unset($location);
  1726. unset($type);
  1727. return $cur;
  1728. }
  1729. function get_location_m($type = 'category', $cat = 0, $str = '', $extra = '', $pdetail = '')
  1730. {
  1731. global $seo;
  1732. global $pluginsettings;
  1733. global $mymps_global;
  1734. $mymps_global['SiteCity'] = $mymps_global['SiteCity'] && !in_array($type, array('channel', 'news', 'goods')) ? $mymps_global['SiteCity'] : '';
  1735. if (!$seo) {
  1736. $seo = get_seoset();
  1737. }
  1738. if ($type == 'news') {
  1739. $page_title = $pluginsettings['news']['seotitle'] ? $pluginsettings['news']['seotitle'] : $mymps_global['SiteName'];
  1740. }
  1741. else {
  1742. $page_title = $mymps_global['SiteName'];
  1743. }
  1744. if ($seo['seo_sitename'] && $type == 'index' && empty($cat) && empty($str)) {
  1745. $page_title = $page_title . '-' . $seo['seo_sitename'];
  1746. }
  1747. if (in_array($type, array('category', 'channel', 'corp', 'news'))) {
  1748. if (0 < $cat) {
  1749. $cat_arr = get_parent_cats($type, $cat);
  1750. }
  1751. else {
  1752. $cat_arr = array();
  1753. }
  1754. if ($type == 'channel') {
  1755. $page_title = '热点资讯-' . $page_title;
  1756. }
  1757. else if ($type == 'goods') {
  1758. $page_title = '商品展示-' . $page_title;
  1759. }
  1760. if (!empty($cat_arr)) {
  1761. krsort($cat_arr);
  1762. foreach ($cat_arr as $val) {
  1763. $page_title = mhtmlspecialchars($GLOBALS['cat']['title'] && $GLOBALS['catid'] == $val['catid'] ? $GLOBALS['cat']['title'] : ($type == 'corp' ? $val['corpname'] : $val['catname'])) . '-' . $page_title;
  1764. }
  1765. }
  1766. $page_title = $extra ? $extra . $page_title : $page_title;
  1767. $page_title = $mymps_global['SiteCity'] . $page_title;
  1768. }
  1769. else if ($type == 'goods') {
  1770. $cat_arr = goods_parent_cats($catid);
  1771. $page_title = $pluginsettings['goods']['seotitle'] ? $pluginsettings['goods']['seotitle'] : $mymps_global['SiteCity'] . '商品展示-' . $GLOBALS['mymps_global']['SiteName'];
  1772. if (!empty($catid)) {
  1773. if (!empty($cat_arr)) {
  1774. krsort($cat_arr);
  1775. foreach ($cat_arr as $val) {
  1776. $page_title = $val['catname'] . '-' . $page_title;
  1777. }
  1778. }
  1779. }
  1780. }
  1781. if (!empty($str)) {
  1782. $page_title = $str . ($type == 'space' ? '的个人空间' : '') . '-' . $page_title;
  1783. }
  1784. $page_title = $pdetail ? $pdetail : $page_title;
  1785. $cur = array('page_title' => $page_title, 'location' => $location);
  1786. unset($page_title);
  1787. unset($cat);
  1788. unset($location);
  1789. unset($type);
  1790. return $cur;
  1791. }
  1792. function get_areaname($areaid)
  1793. {
  1794. global $db;
  1795. global $db_mymps;
  1796. $data = read_static_cache('area_option_static');
  1797. return $data[$areaid]['areaname'] ? $data[$areaid]['areaname'] : $db->getOne('SELECT areaname FROM `' . $db_mymps . 'area` WHERE areaid = \'' . $areaid . '\'');
  1798. }
  1799. function get_upload_image_view($if_upimg = 1, $infoid = '', $number = '')
  1800. {
  1801. global $mymps_global;
  1802. global $db;
  1803. global $db_mymps;
  1804. if ($if_upimg == 1) {
  1805. $cfg_upimg_number = $number ? $number : ($mymps_global['cfg_upimg_number'] ? $mymps_global['cfg_upimg_number'] : 4);
  1806. $mymps = '<script type="text/javascript">$(function () {';
  1807. for ($i = 0; $i < $cfg_upimg_number; $i++) {
  1808. $mymps .= '$("#mymps_img_' . $i . '").uploadPreview({ Img: "ImgPr' . $i . '", Width: 108, Height: 108, MaxSize:' . $mymps_global['cfg_upimg_size'] . ' });';
  1809. }
  1810. $mymps .= '});</script>';
  1811. for ($i = 0; $i < $cfg_upimg_number; $i++) {
  1812. $mymps .= '<div class="onea_dd">
  1813. <div class="viewarea"><img id="ImgPr' . $i . '" src="' . $mymps_global['SiteUrl'] . '/template/default/images/post/defaultimg.gif"/></div>
  1814. <div class="clearfix"></div>
  1815. <div class="a_ddarea">
  1816. <input type="file" name="mymps_img_' . $i . '" id="mymps_img_' . $i . '" class="comment-pic-upd" />
  1817. <img src="' . $mymps_global['SiteUrl'] . '/template/default/images/post/addimg.gif" alt="上传照片" title="上传图片">
  1818. </div>
  1819. </div>';
  1820. }
  1821. }
  1822. return $mymps;
  1823. }
  1824. function get_upload_image_edit($if_upimg = 1, $infoid, $number = '')
  1825. {
  1826. global $mymps_global;
  1827. global $db;
  1828. global $db_mymps;
  1829. if (empty($infoid)) {
  1830. return '';
  1831. }
  1832. if ($if_upimg == 1) {
  1833. $cfg_upimg_number = $number ? $number : ($mymps_global['cfg_upimg_number'] ? $mymps_global['cfg_upimg_number'] : 4);
  1834. $imagei = array();
  1835. $view = $db->getAll('SELECT image_id,prepath FROM `' . $db_mymps . 'info_img` WHERE infoid = \'' . $infoid . '\'');
  1836. foreach ($view as $k => $v) {
  1837. $imagei[$v['image_id']] = $mymps_global['SiteUrl'] . $v['prepath'];
  1838. }
  1839. $mymps = '<script type="text/javascript">$(function () {';
  1840. for ($i = 0; $i < $cfg_upimg_number; $i++) {
  1841. $mymps .= '$("#mymps_img_' . $i . '").uploadPreview({ Img: "ImgPr' . $i . '", Width: 108, Height: 108, MaxSize:' . $mymps_global['cfg_upimg_size'] . ' });';
  1842. }
  1843. $mymps .= '});</script>';
  1844. for ($i = 0; $i < $cfg_upimg_number; $i++) {
  1845. $mymps .= '
  1846. <div class="onea_dd">
  1847. <div class="viewarea"><img id="ImgPr' . $i . '" src="' . ($imagei[$i] ? $imagei[$i] : $mymps_global['SiteUrl'] . '/template/default/images/post/defaultimg.gif') . '"/></div>
  1848. <div class="clearfix"></div>
  1849. <div class="a_ddarea">
  1850. <input type="file" name="mymps_img_' . $i . '" id="mymps_img_' . $i . '" class="comment-pic-upd" />
  1851. <img src="' . $mymps_global['SiteUrl'] . '/template/default/images/post/addimg.gif" alt="上传照片" title="上传图片">
  1852. </div>';
  1853. $mymps .= $imagei[$i] ? '<div class="clearfix"></div><div style="text-align:center; font-weight:100; color:#000; font-size:12px; line-height:22px"><label for="label' . $i . '"><input id="label' . $i . '" name="delinfoimg[' . $i . ']" type="checkbox" class="checkbox"><font>删?</font></label></div>' : '';
  1854. $mymps .= '</div>';
  1855. }
  1856. $mymps .= '</td></tr>';
  1857. }
  1858. return $mymps;
  1859. }
  1860. function arraychange($oldarray)
  1861. {
  1862. $oldarray = explode('
  1863. ', $oldarray);
  1864. $new_array = array();
  1865. foreach ($oldarray as $t) {
  1866. $t = explode('=', $t);
  1867. if (!isset($new_array[$t[0]])) {
  1868. $new_array[$t[0]] = $t[1];
  1869. }
  1870. }
  1871. return $new_array;
  1872. }
  1873. function get_format_time($time)
  1874. {
  1875. global $timestamp;
  1876. $limit = ($timestamp ? $timestamp : time()) - $time;
  1877. if ($limit < 60) {
  1878. $strTime = $limit . '秒钟前';
  1879. }
  1880. else if ($limit / 60 < 60) {
  1881. $strTime = floor($limit / 60) . '分钟前';
  1882. }
  1883. else if ($limit / 60 / 60 < 24) {
  1884. $strTime = floor($limit / 60 / 60) . '小时前';
  1885. }
  1886. else {
  1887. if (24 < $limit / 60 / 60 && $limit / 60 / 60 < 48) {
  1888. $strTime = '昨天' . date('H:i', $time);
  1889. }
  1890. else {
  1891. if (2 < $limit / 60 / 60 / 24 && $limit / 60 / 60 / 24 < 3) {
  1892. $strTime = '前天' . date('H:i', $time);
  1893. }
  1894. else if ($limit / 60 / 60 / 24 < 7) {
  1895. $strTime = floor($limit / 60 / 60 / 24) . '天前';
  1896. }
  1897. else {
  1898. $strTime = date('m-d H:i:s', $time);
  1899. }
  1900. }
  1901. }
  1902. return $strTime;
  1903. }
  1904. function replace_html_style($html = '', $id = '')
  1905. {
  1906. $random = rand();
  1907. $year = date('Y', time());
  1908. $month = date('m', time());
  1909. $day = date('d', time());
  1910. $time = time();
  1911. return preg_replace('/\\{([0-9a-zA-Z]+)\\}/e', '$$1', $html);
  1912. }
  1913. function clearcookies()
  1914. {
  1915. global $s_uid;
  1916. global $admin_id;
  1917. foreach (array('s_uid', 'admin_id') as $k) {
  1918. msetcookie($k);
  1919. }
  1920. $s_uid = $admin_id = $credits = '';
  1921. }
  1922. function submit_check($var, $allowget = 0)
  1923. {
  1924. if ($allowget || $_SERVER['REQUEST_METHOD'] == 'POST' && (empty($_SERVER['HTTP_REFERER']) || preg_replace('/https?:\\/\\/([^\\:\\/]+).*/i', '\\1', $_SERVER['HTTP_REFERER']) == preg_replace('/([^\\:]+).*/', '\\1', $_SERVER['HTTP_HOST']))) {
  1925. return true;
  1926. }
  1927. else {
  1928. return false;
  1929. }
  1930. }
  1931. function get_sex_option($cursex = '')
  1932. {
  1933. foreach (array('男', '女') as $key) {
  1934. $mymps .= '<option value=' . $key;
  1935. $mymps .= $cursex == $key ? ' style = "background-color:#6EB00C;color:white" selected>' : '>';
  1936. $mymps .= $key . '</option>';
  1937. }
  1938. return $mymps;
  1939. }
  1940. function get_memtpl_options($opt = '')
  1941. {
  1942. $option = $GLOBALS['db']->getAll('SELECT * FROM `' . $GLOBALS['db_mymps'] . 'member_tpl` WHERE if_view = \'2\' ORDER BY displayorder ASC');
  1943. foreach ($option as $key => $v) {
  1944. $mymps .= '<option value=' . $v[tpl_path];
  1945. if (is_array($opt)) {
  1946. $mymps .= in_array($v[tpl_path], $opt) ? ' style = "background-color:#6EB00C;color:white" selected>' : '>';
  1947. }
  1948. else {
  1949. $mymps .= $opt == $v[tpl_path] ? ' style = "background-color:#6EB00C;color:white" selected>' : '>';
  1950. }
  1951. $mymps .= $v[tpl_name] . '</option>';
  1952. }
  1953. return $mymps;
  1954. }
  1955. function get_htmlpath_type($dir_type, $typename, $id, $mydir)
  1956. {
  1957. if ($dir_type == 1) {
  1958. $html_path = $id;
  1959. }
  1960. else if ($dir_type == 2) {
  1961. $html_path = GetPinyin($typename);
  1962. }
  1963. else if ($dir_type == 3) {
  1964. $html_path = GetPinyin($typename, 1);
  1965. }
  1966. else if ($dir_type == 4) {
  1967. !$mydir && write_msg('请填写自定义栏目名!');
  1968. $html_path = $mydir;
  1969. }
  1970. else {
  1971. $html_path = false;
  1972. }
  1973. return $html_path;
  1974. }
  1975. function create_in($item_list, $field = '')
  1976. {
  1977. if (empty($item_list)) {
  1978. return $field . ' IN (\'\') ';
  1979. }
  1980. else {
  1981. if (!is_array($item_list)) {
  1982. $item_list = explode(',', $item_list);
  1983. }
  1984. $item_list = array_unique($item_list);
  1985. $item_list_tmp = '';
  1986. foreach ($item_list as $item) {
  1987. if ($item !== '') {
  1988. $item_list_tmp .= $item_list_tmp ? ',\'' . $item . '\'' : '\'' . $item . '\'';
  1989. }
  1990. }
  1991. if (empty($item_list_tmp)) {
  1992. return $field . ' IN (\'\') ';
  1993. }
  1994. else {
  1995. return $field . ' IN (' . $item_list_tmp . ') ';
  1996. }
  1997. }
  1998. }
  1999. function GetInfoPostTime($posttime = '', $formname = 'posttime')
  2000. {
  2001. global $info_posttime;
  2002. $info_posttime_form = '<select name=\'' . $formname . '\' id=\'' . $formname . '\'>';
  2003. foreach ($info_posttime as $k => $v) {
  2004. if ($k == $posttime) {
  2005. $info_posttime_form .= '<option value=\'' . $k . '\' selected>' . $v . '</option>
  2006. ';
  2007. }
  2008. else {
  2009. $info_posttime_form .= '<option value=\'' . $k . '\'>' . $v . '</option>
  2010. ';
  2011. }
  2012. }
  2013. $info_posttime_form .= '</select>
  2014. ';
  2015. return $info_posttime_form;
  2016. }
  2017. function mymps_global_header()
  2018. {
  2019. global $charset;
  2020. global $mymps_global;
  2021. return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2022. <html xmlns="http://www.w3.org/1999/xhtml">
  2023. <head>
  2024. <meta http-equiv="Content-Type" content="text/html; charset=utf-8' . $charset . '" />
  2025. <meta http-equiv="Content-Language" content="zh-CN"/>
  2026. <meta name="generator" content="' . MPS_SOFTNAME . MPS_VERSION . '"/>
  2027. <meta name="author" content="' . MPS_SOFTNAME . ' DevTeam Corporation" />
  2028. <link rel="shortcut icon" href="' . $mymps_global[SiteUrl] . '/favicon.ico" />';
  2029. }
  2030. function HighLight($str, $keywords, $color = 'red')
  2031. {
  2032. if (empty($keywords)) {
  2033. return $str;
  2034. exit();
  2035. }
  2036. else {
  2037. if (is_array($keywords) && $str) {
  2038. foreach ($keywords as $k => $v) {
  2039. $str = @preg_replace('/' . $v . '/i', '<font color=' . $color . '>' . $v . '</font>', $str);
  2040. }
  2041. }
  2042. else if ($str) {
  2043. $str = @preg_replace('/' . $keywords . '/i', '<font color=' . $color . '>' . $keywords . '</font>', $str);
  2044. }
  2045. }
  2046. return $str;
  2047. }
  2048. function convertip_tiny($ip, $ipdatafile)
  2049. {
  2050. static $fp;
  2051. static $offset = array();
  2052. static $index;
  2053. $ipdot = explode('.', $ip);
  2054. $ip = pack('N', ip2long($ip));
  2055. $ipdot[0] = (int) $ipdot[0];
  2056. $ipdot[1] = (int) $ipdot[1];
  2057. if ($fp === NULL && ($fp = @fopen($ipdatafile, 'rb'))) {
  2058. $offset = unpack('Nlen', fread($fp, 4));
  2059. $index = fread($fp, $offset['len'] - 4);
  2060. }
  2061. else if ($fp == false) {
  2062. return '- Invalid IP data file';
  2063. }
  2064. $length = $offset['len'] - 1028;
  2065. $start = unpack('Vlen', $index[$ipdot[0] * 4] . $index[$ipdot[0] * 4 + 1] . $index[$ipdot[0] * 4 + 2] . $index[$ipdot[0] * 4 + 3]);
  2066. for ($start = $start['len'] * 8 + 1024; $start < $length; $start += 8) {
  2067. if ($ip <= $index[$start] . $index[$start + 1] . $index[$start + 2] . $index[$start + 3]) {
  2068. $index_offset = unpack('Vlen', $index[$start + 4] . $index[$start + 5] . $index[$start + 6] . '');
  2069. $index_length = unpack('Clen', $index[$start + 7]);
  2070. break;
  2071. }
  2072. }
  2073. fseek($fp, $offset['len'] + $index_offset['len'] - 1024);
  2074. if ($index_length['len']) {
  2075. return fread($fp, $index_length['len']);
  2076. }
  2077. else {
  2078. return '- Unknown';
  2079. }
  2080. }
  2081. function ip2area($ip = '')
  2082. {
  2083. global $charset;
  2084. global $mymps_global;
  2085. if (empty($ip) || $ip == '127.0.0.1') {
  2086. return '';
  2087. }
  2088. else {
  2089. $ip2 = @file_get_contents('http://api.map.baidu.com/location/ip?ak=' . $mymps_global['mapkey'] . '&ip=' . $ip);
  2090. $ip2 = json_decode($ip2);
  2091. $data = array();
  2092. $data['province'] = $ip2->content->address_detail->province;
  2093. $data['city'] = $ip2->content->address_detail->city;
  2094. $data['district'] = $ip2->content->address_detail->district;
  2095. $data['street'] = $ip2->content->address_detail->street;
  2096. $data['province'] = $charset == 'gbk' && $data['province'] ? iconv('UTF-8', 'GBK', $data['province']) : $data['province'];
  2097. $data['city'] = $charset == 'gbk' && $data['city'] ? iconv('UTF-8', 'GBK', $data['city']) : $data['city'];
  2098. $data['district'] = $charset == 'gbk' && $data['district'] ? iconv('UTF-8', 'GBK', $data['district']) : $data['district'];
  2099. $data['street'] = $charset == 'gbk' && $data['street'] ? iconv('UTF-8', 'GBK', $data['street']) : $data['street'];
  2100. return $data['province'] . $data['city'] . $data['district'];
  2101. }
  2102. }
  2103. function filter_bad_words($cfg_badwords, $str)
  2104. {
  2105. $cfg_bwords = explode(',', $cfg_badwords[0]);
  2106. foreach ($cfg_bwords as $i) {
  2107. $str = str_replace($cfg_bwords, $cfg_badwords[1], $str);
  2108. }
  2109. return $str;
  2110. }
  2111. function verify_badwords_filter($ifopenname, $title = '', $content = '')
  2112. {
  2113. global $mymps_global;
  2114. static $res;
  2115. $title = $title ? mhtmlspecialchars(trim($title)) : '';
  2116. $content = $content ? trim($content) : '';
  2117. if ($res === NULL) {
  2118. $data = read_static_cache('badwords');
  2119. if ($data === false) {
  2120. $query = $GLOBALS['db']->query('SELECT words,view,ifcheck FROM `' . $GLOBALS['db_mymps'] . 'badwords`');
  2121. while ($row = $GLOBALS['db']->fetchRow($query)) {
  2122. $cfg_badwords[0] = $row['words'];
  2123. $cfg_badwords[1] = $row['view'];
  2124. $cfg_badwords[2] = $row['ifcheck'];
  2125. }
  2126. write_static_cache('badwords', $cfg_badwords);
  2127. }
  2128. else {
  2129. $cfg_badwords = $data;
  2130. }
  2131. }
  2132. if ($ifopenname == 1) {
  2133. $info_level = 0;
  2134. if (is_array($cfg_badwords)) {
  2135. $title = $title ? sphtml2text(filter_bad_words($cfg_badwords, $title)) : '';
  2136. $content = $content ? filter_bad_words($cfg_badwords, $content) : '';
  2137. }
  2138. }
  2139. else if (is_array($cfg_badwords)) {
  2140. if ($cfg_badwords[0] && $cfg_badwords[2] == 1) {
  2141. foreach (explode(',', $cfg_badwords[0]) as $k => $v) {
  2142. if (strstr($title, $v) || strstr($content, $v)) {
  2143. $info_level = 0;
  2144. $title = @str_replace($v, $cfg_badwords[1], $title);
  2145. $content = @str_replace($v, $cfg_badwords[1], $content);
  2146. break;
  2147. }
  2148. else {
  2149. $info_level = 1;
  2150. }
  2151. }
  2152. }
  2153. else if ($cfg_badwords[2] == 0) {
  2154. $title = sphtml2text(filter_bad_words($cfg_badwords, $title));
  2155. $content = filter_bad_words($cfg_badwords, $content);
  2156. $info_level = 1;
  2157. }
  2158. else {
  2159. $info_level = 1;
  2160. }
  2161. }
  2162. else {
  2163. $info_level = 1;
  2164. }
  2165. $verified_result = array();
  2166. $verified_result['title'] = $title;
  2167. $verified_result['content'] = $content;
  2168. $verified_result['level'] = $info_level;
  2169. return $verified_result;
  2170. }
  2171. function get_info_option_array()
  2172. {
  2173. global $db;
  2174. global $db_mymps;
  2175. $data = read_static_cache('info_typeoptions');
  2176. if ($data === false) {
  2177. $query = $db->query('SELECT title,identifier,rules,type FROM `' . $db_mymps . 'info_typeoptions` WHERE classid >0 ORDER BY displayorder DESC');
  2178. while ($row = $db->fetchRow($query)) {
  2179. $mymps[$row['identifier']]['title'] = $row['title'];
  2180. $mymps[$row['identifier']]['rules'] = $row['rules'];
  2181. $mymps[$row['identifier']]['type'] = $row['type'];
  2182. }
  2183. write_static_cache('info_typeoptions', $mymps);
  2184. }
  2185. else {
  2186. $mymps = $data;
  2187. }
  2188. return $mymps;
  2189. }
  2190. function get_info_option_titval($option, $value, $class = 'mayi')
  2191. {
  2192. global $charset;
  2193. if (!is_array($option) || empty($option)) {
  2194. return array();
  2195. }
  2196. else {
  2197. if ($option['type'] == 'radio' || $option['type'] == 'select') {
  2198. $tmp = $charset == 'utf-8' ? utf8_unserialize($option['rules']) : unserialize($option['rules']);
  2199. $new_array = arraychange($tmp['choices']);
  2200. $new_value = $new_array[$value];
  2201. $value = $new_value;
  2202. }
  2203. else if ($option['type'] == 'checkbox') {
  2204. $value = explode(',', $value);
  2205. $tmp = $charset == 'utf-8' ? utf8_unserialize($option['rules']) : unserialize($option['rules']);
  2206. foreach ($value as $m => $n) {
  2207. $new_array = arraychange($tmp[choices]);
  2208. $nvalue .= '<font class=' . $class . '>' . $new_array[$n] . '</font>';
  2209. }
  2210. $value = $nvalue;
  2211. }
  2212. else {
  2213. $rules = $charset == 'utf-8' ? utf8_unserialize($option['rules']) : unserialize($option['rules']);
  2214. $value = $value . $rules['units'];
  2215. }
  2216. return array('title' => $option['title'], 'value' => $value);
  2217. }
  2218. }
  2219. function clear_mirror($str)
  2220. {
  2221. $str = str_replace('-', '', $str);
  2222. $str = str_replace('+', '', $str);
  2223. return $str;
  2224. }
  2225. function part_ip($ip)
  2226. {
  2227. return preg_replace('/((?:\\d+\\.){3})\\d+/', '\\1*', $ip);
  2228. }
  2229. function part_tel($num)
  2230. {
  2231. return substr_replace($num, '****', 7, 4);
  2232. }
  2233. function ajax_output($ajax_content)
  2234. {
  2235. global $charset;
  2236. @header('Expires: -1');
  2237. @header('Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0', false);
  2238. @header('Pragma: no-cache');
  2239. @header('Content-Type: text/xml');
  2240. $mymps .= '<?xml version="1.0" encoding="' . ($charset == 'gb2312' ? 'gbk' : 'utf-8') . '"?><root><![CDATA[';
  2241. $mymps .= $ajax_content;
  2242. $mymps .= ']]></root>';
  2243. return $mymps;
  2244. }
  2245. function allow_identifier()
  2246. {
  2247. $data = read_static_cache('mod_search_identifier');
  2248. if ($data === false) {
  2249. require_once MYMPS_DATA . '/info.type.inc.php';
  2250. $query = $GLOBALS['db']->query('SELECT id,options FROM `' . $GLOBALS['db_mymps'] . 'info_typemodels` ORDER BY displayorder DESC');
  2251. while ($row = $GLOBALS['db']->fetchRow($query)) {
  2252. $option = explode(',', $row[options]);
  2253. foreach ($option as $w => $u) {
  2254. $newrow = $GLOBALS['db']->getRow('SELECT identifier,search FROM `' . $GLOBALS['db_mymps'] . 'info_typeoptions` WHERE optionid=\'' . $u . '\'');
  2255. if ($newrow['search'] == 'on') {
  2256. $arr[$row[id]]['identifier'][] = $newrow['identifier'];
  2257. }
  2258. }
  2259. $res = $arr;
  2260. }
  2261. write_static_cache('mod_search_identifier', $res);
  2262. }
  2263. else {
  2264. $res = $data;
  2265. }
  2266. return $res;
  2267. }
  2268. function mod_identifier()
  2269. {
  2270. $data = read_static_cache('mod_search_option');
  2271. if ($data === false) {
  2272. require_once MYMPS_DATA . '/info.type.inc.php';
  2273. $query = $GLOBALS['db']->query('SELECT id,options FROM `' . $GLOBALS['db_mymps'] . 'info_typemodels` ORDER BY displayorder DESC');
  2274. while ($row = $GLOBALS['db']->fetchRow($query)) {
  2275. $option = explode(',', $row[options]);
  2276. foreach ($option as $w => $u) {
  2277. $nrow = $GLOBALS['db']->getRow('SELECT optionid,title,identifier,type,rules,search FROM `' . $GLOBALS['db_mymps'] . 'info_typeoptions` WHERE optionid=\'' . $u . '\'');
  2278. if ($nrow['search'] == 'on') {
  2279. $extra = $GLOBALS['charset'] == 'utf-8' ? utf8_unserialize($nrow['rules']) : unserialize($nrow['rules']);
  2280. if (in_array($nrow['type'], array('select', 'radio', 'checkbox', 'number'))) {
  2281. if (is_array($extra)) {
  2282. foreach ($extra as $k => $value) {
  2283. if ($nrow[type] == 'radio' || $nrow[type] == 'select' || $nrow[type] == 'checkbox' || $nrow[type] == 'number' && $k == 'choices') {
  2284. $extr = array_merge(array(-1 => '不限'), arraychange($value));
  2285. foreach ($extr as $ekey => $eval) {
  2286. $ar['id'] = $ekey;
  2287. $ar['name'] = $eval;
  2288. $ar['identifier'] = $nrow['identifier'];
  2289. $arr[$row['id']][$nrow['optionid']]['list'][] = $ar;
  2290. }
  2291. }
  2292. $arr[$row['id']][$nrow['optionid']]['title'] = $nrow['title'];
  2293. $arr[$row['id']][$nrow['optionid']]['type'] = $nrow['type'];
  2294. $arr[$row['id']][$nrow['optionid']]['identifier'] = $nrow['identifier'];
  2295. $arr[$row['id']][$nrow['optionid']]['publish'] = get_info_var_type($nrow['type'], $nrow['identifier'], $extr, $get_value, 'front');
  2296. }
  2297. }
  2298. }
  2299. }
  2300. }
  2301. }
  2302. $res = $arr;
  2303. write_static_cache('mod_search_option', $res);
  2304. }
  2305. else {
  2306. $res = $data;
  2307. }
  2308. return $res;
  2309. }
  2310. function mymps_get_faq($num = 5, $typeid = NULL)
  2311. {
  2312. global $db;
  2313. global $db_mymps;
  2314. global $seo;
  2315. if (!$seo) {
  2316. $seo = get_seoset();
  2317. }
  2318. $where = $typeid ? 'WHERE typeid = ' . $typeid : '';
  2319. $sql = 'SELECT id,typeid,title FROM ' . $db_mymps . 'faq ' . $where . ' ORDER BY id DESC LIMIT 0,' . $num;
  2320. $do_mymps = $db->query($sql);
  2321. while ($row = $db->fetchRow($do_mymps)) {
  2322. $arr['id'] = $row['id'];
  2323. $arr['title'] = $row['title'];
  2324. $arr['uri'] = rewrite('about', array('part' => 'faq', 'id' => $row['id']));
  2325. $faq_list[] = $arr;
  2326. }
  2327. unset($seo);
  2328. return $faq_list;
  2329. }
  2330. function mymps_get_focus($type = 'index', $num = 5)
  2331. {
  2332. global $db;
  2333. global $db_mymps;
  2334. $type_limit = $type == 'index' ? ' AND typename= \'网站首页\'' : ' AND typename = \'新闻首页\'';
  2335. $query = $db->query('SELECT image,pre_image,url,words,id FROM `' . $db_mymps . 'focus` WHERE 1 ' . $type_limit . ' ORDER BY focusorder DESC LIMIT 0,' . $num);
  2336. while ($row = $db->fetchRow($query)) {
  2337. $list[$row['id']]['id'] = $row['id'];
  2338. $list[$row['id']]['image'] = $row['image'];
  2339. $list[$row['id']]['pre_image'] = $row['pre_image'];
  2340. $list[$row['id']]['url'] = $row['url'];
  2341. $list[$row['id']]['words'] = $row['words'];
  2342. }
  2343. return $list;
  2344. }
  2345. function mymps_get_news($num = 10, $catid = NULL, $ifimg = NULL, $leftjoin = NULL, $ifhot = NULL, $orderby = 1)
  2346. {
  2347. global $city;
  2348. global $db;
  2349. global $db_mymps;
  2350. $cat_limit = empty($catid) ? '' : 'AND a.catid IN(' . get_cat_children($catid, 'channel') . ')';
  2351. $img_limit = !$ifimg ? '' : 'AND a.imgpath != \'\'';
  2352. $commend_limit = empty($ifhot) ? '' : ' AND a.iscommend = \'1\'';
  2353. $orderby = empty($orderby) ? 'ORDER BY a.hit DESC' : 'ORDER BY a.id DESC';
  2354. $res = array();
  2355. if ($leftjoin) {
  2356. $query = $db->query('SELECT a.*,b.catname FROM `' . $GLOBALS['db_mymps'] . 'news` AS a LEFT JOIN `' . $GLOBALS['db_mymps'] . 'channel` AS b ON a.catid = b.catid WHERE 1 ' . $cat_limit . ' ' . $img_limit . $city_limit . ' ' . $commend_limit . ' ' . $orderby . ' LIMIT 0,' . $num);
  2357. while ($row = $db->fetchRow($query)) {
  2358. $arr['id'] = $row['id'];
  2359. $arr['title'] = $row['title'];
  2360. $arr['iscommend'] = $row['iscommend'];
  2361. $arr['imgpath'] = $row['imgpath'];
  2362. $arr['content'] = clear_html($row['content']);
  2363. $arr['begintime'] = $row['begintime'];
  2364. $arr['catname'] = $row['catname'];
  2365. $arr['caturi'] = rewrite('news', array('catid' => $row['catid']));
  2366. $arr['caturi_m'] = mrewrite('news', array('catid' => $row['catid']));
  2367. $arr['uri'] = $row['isjump'] ? $row['redirect_url'] : rewrite('news', array('id' => $row['id']));
  2368. $arr['uri_m'] = mrewrite('news', array('id' => $row['id']));
  2369. $res[] = $arr;
  2370. }
  2371. }
  2372. else {
  2373. $query = $db->query('SELECT a.* FROM `' . $GLOBALS['db_mymps'] . 'news` AS a WHERE 1 ' . $cat_limit . ' ' . $img_limit . $city_limit . $commend_limit . $orderby . ' LIMIT 0,' . $num);
  2374. while ($row = $db->fetchRow($query)) {
  2375. $arr['id'] = $row['id'];
  2376. $arr['title'] = $row['isbold'] == 1 ? '<strong>' . $row['title'] . '</strong>' : $row['title'];
  2377. $arr['title'] = $row['title'];
  2378. $arr['iscommend'] = $row['iscommend'];
  2379. $arr['imgpath'] = $row['imgpath'];
  2380. $arr['content'] = clear_html($row['content']);
  2381. $arr['begintime'] = $row['begintime'];
  2382. $arr['uri'] = $row['isjump'] ? $row['redirect_url'] : rewrite('news', array('id' => $row['id']));
  2383. $arr['uri_m'] = mrewrite('news', array('id' => $row['id']));
  2384. $res[] = $arr;
  2385. }
  2386. }
  2387. return $res;
  2388. }
  2389. function mymps_get_members($num = NULL, $level = NULL, $orderby = NULL, $if_certify = NULL, $ifindex = NULL, $iflist = NULL, $catid = NULL)
  2390. {
  2391. global $db;
  2392. global $db_mymps;
  2393. global $mymps_global;
  2394. global $mayimobile;
  2395. if ($mymps_global['cfg_if_corp'] == 1) {
  2396. $where = $level ? ' WHERE a.levelid = \'' . $level . '\'' : ' WHERE 1';
  2397. $where .= ' AND a.status = \'1\'';
  2398. $where .= ' AND a.if_corp = \'1\'';
  2399. $where .= $if_certify ? ' AND a.com_certify = \'1\'' : ' ';
  2400. $where .= $ifindex ? ' AND a.ifindex = \'2\'' : ' ';
  2401. $where .= $iflist ? ' AND a.iflist = \'2\'' : ' ';
  2402. $where .= !empty($catid) ? ' AND catid IN(' . get_corp_children($catid) . ') ' : '';
  2403. $orderby = $orderby == 1 ? 'ORDER BY a.levelid DESC' : 'ORDER BY a.id DESC';
  2404. $limit = $num ? ' LIMIT 0,' . $num : '';
  2405. $sql = 'SELECT a.* FROM `' . $db_mymps . 'member` AS a ' . $where . ' ' . $orderby . ' ' . $limit;
  2406. $do_mymps = $db->query($sql);
  2407. while ($row = $db->fetchRow($do_mymps)) {
  2408. $arr['id'] = $row['id'];
  2409. $arr['userid'] = $row['userid'];
  2410. $arr['cname'] = $row['cname'];
  2411. $arr['hourstime'] = str_replace(':0', ':00', $row['hourstime']);
  2412. $arr['tname'] = $row['tname'] ? $row['tname'] : $row['userid'];
  2413. $row['prelogo'] = $row['prelogo'] ? $row['prelogo'] : '/images/nophoto.jpg';
  2414. $arr['prelogo'] = !strstr($row['prelogo'], 'http') ? $mymps_global['SiteUrl'] . $row['prelogo'] : $row['prelogo'];
  2415. $arr['jointime'] = $row['jointime'];
  2416. $arr['logintime'] = $row['logintime'];
  2417. $arr['tel'] = $row['tel'];
  2418. $arr['address'] = $row['address'];
  2419. $arr['qq'] = $row['qq'];
  2420. $arr['credits'] = $row['credits'];
  2421. $arr['hit'] = $row['hit'];
  2422. $arr['introduce'] = clear_html($row['introduce']);
  2423. $arr['uri'] = rewrite('store', array('uid' => $row['id']));
  2424. $arr['uri_m'] = mrewrite('store', array('uid' => $row['id']));
  2425. $member_list[] = $arr;
  2426. }
  2427. }
  2428. else {
  2429. $member_list = array();
  2430. }
  2431. return $member_list;
  2432. }
  2433. function mymps_get_member_docus($num = 10, $userid = NULL, $typeid = NULL, $orderby = 1)
  2434. {
  2435. global $db;
  2436. global $db_mymps;
  2437. global $mayimobile;
  2438. $where = 'WHERE a.if_check = \'1\'';
  2439. $where .= $userid ? ' AND a.userid = \'' . $userid . '\'' : '';
  2440. $where .= $typeid ? ' AND a.typeid = \'' . $typeid . '\'' : '';
  2441. $limit = ' LIMIT 0,' . $num;
  2442. $orderby = $orderby == 1 ? ' ORDER BY a.pubtime DESC ' : ' ORDER BY a.id DESC ';
  2443. $query = $db->query('SELECT a.*,b.id AS uid,b.tname FROM `' . $db_mymps . 'member_docu` AS a LEFT JOIN `' . $db_mymps . 'member` AS b ON a.userid = b.userid ' . $where . ' ' . $orderby . ' ' . $limit);
  2444. while ($row = $db->fetchRow($query)) {
  2445. $arr['id'] = $row['id'];
  2446. $arr['userid'] = $row['userid'];
  2447. $arr['tname'] = $row['tname'];
  2448. $arr['typeid'] = $row['typeid'];
  2449. $arr['title'] = $row['title'];
  2450. $arr['pubtime'] = $row['pubtime'];
  2451. $arr['imgpath'] = $row['imgpath'];
  2452. $arr['hit'] = $row['hit'];
  2453. $arr['pre_imgpath'] = $row['pre_imgpath'];
  2454. $arr['tname_uri'] = rewrite('store', array('uid' => $row['uid'], 'part' => 'index'));
  2455. $arr['uri'] = rewrite('store', array('uid' => $row['uid'], 'id' => $row['id'], 'part' => 'document'));
  2456. $docu[] = $arr;
  2457. }
  2458. return $docu;
  2459. }
  2460. function mymps_get_infos($num = 10, $info_level = NULL, $upgrade_type = NULL, $userid = NULL, $catid = NULL, $certify = NULL, $if_hot = NULL, $tel = NULL)
  2461. {
  2462. global $timestamp;
  2463. global $db_mymps;
  2464. global $mymps_global;
  2465. global $db;
  2466. global $city;
  2467. global $seo;
  2468. global $mayimobile;
  2469. $where .= !$info_level ? 'WHERE (a.info_level =1 OR a.info_level = 2)' : 'WHERE a.info_level = ' . $info_level;
  2470. $where .= $userid ? ' AND a.userid = "' . $userid . '" ' : '';
  2471. $where .= $certify ? ' AND a.certify = "' . $certify . '" ' : '';
  2472. $where .= $tel ? ' AND a.tel = "' . $tel . '" ' : '';
  2473. $where .= $catid ? ' AND ' . get_children($catid, 'a.catid') : '';
  2474. if ($upgrade_type == 1) {
  2475. $where .= ' AND a.upgrade_type_list = 2 ';
  2476. }
  2477. else if ($upgrade_type == 2) {
  2478. $where .= ' AND a.upgrade_type = 2 ';
  2479. }
  2480. else if ($upgrade_type == 3) {
  2481. $where .= ' AND a.upgrade_type_index = 2 ';
  2482. }
  2483. $where .= !empty($sql) ? $sql : '';
  2484. $orderby = $if_hot ? ' ORDER BY a.hit DESC ' : ' ORDER BY a.begintime DESC ';
  2485. $info_list = array();
  2486. $idin = get_page_idin('id', 'SELECT a.id FROM `' . $db_mymps . 'information` AS a ' . $where . ' ' . $orderby, $num);
  2487. if ($idin) {
  2488. $sql = 'SELECT a.id,a.email,a.tel,a.contact_who,a.title,a.content,a.begintime,a.catid,a.info_level,a.hit,a.dir_typename,a.ifred,a.ifbold,a.userid,a.catid,a.catname,a.img_path FROM `' . $GLOBALS['db_mymps'] . 'information` AS a WHERE id IN (' . $idin . ') ' . $orderby;
  2489. $do_mymps = $db->query($sql);
  2490. while ($row = $db->fetchRow($do_mymps)) {
  2491. $arr['id'] = $row['id'];
  2492. $arr['face'] = @strstr($row['face'], 'http') ? $row['face'] : $mymps_global['SiteUrl'] . $row['face'];
  2493. $arr['catid'] = $row['catid'];
  2494. $arr['title'] = $row['title'];
  2495. $arr['content'] = clear_html($row['content']);
  2496. $arr['ifred'] = $row['ifred'];
  2497. $arr['ifbold'] = $row['ifbold'];
  2498. $arr['hit'] = $row['hit'];
  2499. $arr['tel'] = $row['tel'];
  2500. $arr['email'] = $row['email'];
  2501. $arr['begintime'] = $row['begintime'];
  2502. $arr['img_path'] = $row['img_path'];
  2503. $arr['catname'] = $row['catname'];
  2504. $arr['info_level'] = $row['info_level'];
  2505. $arr['userid'] = $row['userid'];
  2506. $arr['contact_who'] = $row['contact_who'];
  2507. $arr['uri'] = rewrite('info', array('id' => $row['id'], 'dir_typename' => $row['dir_typename']));
  2508. $arr['uri_m'] = mrewrite('info', array('id' => $row['id'], 'dir_typename' => $row['dir_typename']));
  2509. $arr['uri_tname'] = rewrite('space', array('user' => $row['userid']));
  2510. $arr['uri_cat'] = rewrite('category', array('catid' => $row['catid'], 'dir_typename' => $row['dir_typename']));
  2511. $arr['uri_cat_m'] = mrewrite('category', array('catid' => $row['catid'], 'dir_typename' => $row['dir_typename']));
  2512. $info_list[] = $arr;
  2513. }
  2514. }
  2515. return $info_list ? $info_list : '';
  2516. }
  2517. function mayicms_get_infos($num = 10, $info_level = NULL, $upgrade_type = NULL, $userid = NULL, $catid = NULL, $certify = NULL, $if_hot = NULL, $tel = NULL)
  2518. {
  2519. global $timestamp;
  2520. global $db_mymps;
  2521. global $mymps_global;
  2522. global $db;
  2523. global $seo;
  2524. global $mayimobile;
  2525. $where .= !$info_level ? 'WHERE (a.info_level =1 OR a.info_level = 2)' : 'WHERE a.info_level = ' . $info_level;
  2526. $where .= $userid ? ' AND a.userid = "' . $userid . '" ' : '';
  2527. $where .= $certify ? ' AND a.certify = "' . $certify . '" ' : '';
  2528. $where .= $tel ? ' AND a.tel = "' . $tel . '" ' : '';
  2529. $where .= $catid ? ' AND ' . get_children($catid, 'a.catid') : '';
  2530. if ($upgrade_type == 1) {
  2531. $where .= ' AND a.upgrade_type_list = 2 ';
  2532. }
  2533. else if ($upgrade_type == 2) {
  2534. $where .= ' AND a.upgrade_type = 2 ';
  2535. }
  2536. else if ($upgrade_type == 3) {
  2537. $where .= ' AND a.upgrade_type_index = 2 ';
  2538. }
  2539. $where .= !empty($sql) ? $sql : '';
  2540. $orderby = $if_hot ? ' ORDER BY a.hit DESC ' : ' ORDER BY a.begintime DESC ';
  2541. $info_list = array();
  2542. $idin = get_page_idin('id', 'SELECT a.id FROM `' . $db_mymps . 'information` AS a ' . $where . ' ' . $orderby, $num);
  2543. $idin2 = $idin ? ' AND a.infoid IN (' . $idin . ') ' : '';
  2544. if ($idin) {
  2545. $sql = 'SELECT a.zan,a.id,a.face,a.tel,a.contact_who,a.title,a.content,a.begintime,a.catid,a.info_level,a.hit,a.dir_typename,a.ifred,a.ifbold,a.userid,a.catid,a.catname,a.img_path,a.upgrade_type_index,b.areaname FROM `' . $GLOBALS['db_mymps'] . 'information` AS a LEFT JOIN `' . $db_mymps . 'area` AS b ON a.areaid = b.areaid WHERE a.id IN (' . $idin . ') ' . $orderby;
  2546. $do_mymps = $db->query($sql);
  2547. while ($row = $db->fetchRow($do_mymps)) {
  2548. $arr['id'] = $row['id'];
  2549. $arr['face'] = @strstr($row['face'], 'http') ? $row['face'] : $mymps_global['SiteUrl'] . $row['face'];
  2550. $arr['areaname'] = $row['areaname'];
  2551. $arr['catid'] = $row['catid'];
  2552. $arr['title'] = $row['title'];
  2553. $arr['content'] = clear_html($row['content']);
  2554. $arr['ifred'] = $row['ifred'];
  2555. $arr['ifbold'] = $row['ifbold'];
  2556. $arr['hit'] = $row['hit'];
  2557. $arr['tel'] = $row['tel'];
  2558. $arr['zan'] = $row['zan'];
  2559. $arr['begintime'] = $row['begintime'];
  2560. $arr['img_path'] = $row['img_path'];
  2561. $arr['catname'] = $row['catname'];
  2562. $arr['info_level'] = $row['info_level'];
  2563. $arr['userid'] = $row['userid'];
  2564. $arr['upgrade_type_index'] = $row['upgrade_type_index'];
  2565. $arr['contact_who'] = $row['contact_who'];
  2566. $arr['uri'] = rewrite('info', array('id' => $row['id'], 'dir_typename' => $row['dir_typename']));
  2567. $arr['uri_m'] = mrewrite('info', array('id' => $row['id'], 'dir_typename' => $row['dir_typename']));
  2568. $arr['uri_tname'] = rewrite('space', array('user' => $row['userid']));
  2569. $arr['uri_cat'] = rewrite('category', array('catid' => $row['catid'], 'dir_typename' => $row['dir_typename']));
  2570. $arr['uri_cat_m'] = mrewrite('category', array('catid' => $row['catid'], 'dir_typename' => $row['dir_typename']));
  2571. $info_list[$row['id']] = $arr;
  2572. }
  2573. }
  2574. if ($idin2) {
  2575. $iquery = $db->query('SELECT a.infoid,a.prepath FROM `' . $db_mymps . 'info_img` AS a WHERE 1 ' . $idin2);
  2576. while ($r = $db->fetchRow($iquery)) {
  2577. $info_list[$r['infoid']]['img'][] = $r['prepath'];
  2578. }
  2579. }
  2580. return $info_list ? $info_list : '';
  2581. }
  2582. function mymps_get_groups($num = 10, $glevel = NULL)
  2583. {
  2584. global $db;
  2585. global $db_mymps;
  2586. static $res;
  2587. $limit = $num ? ' LIMIT 0,' . $num : '';
  2588. $where = $glevel ? ' WHERE glevel > \'' . $glevel . '\'' : ' WHERE glevel > \'0\'';
  2589. $query = $db->query('SELECT * FROM `' . $db_mymps . 'group` ' . $where . ' ORDER BY dateline DESC ' . $limit);
  2590. while ($row = $db->fetchRow($query)) {
  2591. $res[$row['groupid']]['groupid'] = $row['groupid'];
  2592. $res[$row['groupid']]['gname'] = $row['gname'];
  2593. $res[$row['groupid']]['picture'] = $row['picture'];
  2594. $res[$row['groupid']]['pre_picture'] = $row['pre_picture'];
  2595. $res[$row['groupid']]['userid'] = $row['userid'];
  2596. $res[$row['groupid']]['uri'] = plugin_url('group', array('id' => $row['groupid']));
  2597. $res[$row['groupid']]['gaddress'] = $row['gaddress'];
  2598. $res[$row['groupid']]['meetdate'] = $row['meetdate'];
  2599. $res[$row['groupid']]['enddate'] = $row['enddate'];
  2600. $res[$row['groupid']]['dateline'] = $row['dateline'];
  2601. }
  2602. return $res;
  2603. }
  2604. function mymps_get_goods($num = 10, $onsale = 1, $shuxing = NULL, $catid = NULL, $userid = NULL, $orderby = 1)
  2605. {
  2606. global $db;
  2607. global $db_mymps;
  2608. global $mayimobile;
  2609. $limit = $num ? ' LIMIT 0,' . $num : '';
  2610. $where = $onsale == 1 ? ' WHERE onsale = \'1\'' : ' WHERE 1';
  2611. $where .= $userid ? ' AND userid = \'' . $userid . '\'' : '';
  2612. $where .= $shuxing == 'cuxiao' ? ' AND cuxiao = \'1\'' : '';
  2613. $where .= $shuxing == 'remai' ? ' AND remai = \'1\'' : '';
  2614. $where .= $shuxing == 'tuijian' ? ' AND tuijian = \'1\'' : '';
  2615. $where .= $catid ? ' AND catid IN(' . mymps_get_goods_children($catid) . ')' : '';
  2616. $orderby = empty($orderby) ? ' ORDER BY hit DESC ' : ' ORDER BY dateline DESC ';
  2617. $query = $db->query('SELECT * FROM `' . $db_mymps . 'goods` ' . $where . ' ' . $orderby . ' ' . $limit);
  2618. while ($row = $db->fetchRow($query)) {
  2619. $res[$row['goodsid']]['goodsid'] = $row['goodsid'];
  2620. $res[$row['goodsid']]['goodsname'] = $row['goodsname'];
  2621. $res[$row['goodsid']]['oldprice'] = $row['oldprice'];
  2622. $res[$row['goodsid']]['content'] = clear_html($row['content']);
  2623. $res[$row['goodsid']]['nowprice'] = $row['nowprice'];
  2624. $res[$row['goodsid']]['pre_picture'] = $row['pre_picture'] ? $row['pre_picture'] : $mymps_global['SiteUrl'] . '/images/nophoto.gif';
  2625. $res[$row['goodsid']]['picture'] = $row['picture'] ? $row['picture'] : $mymps_global['SiteUrl'] . '/images/nophoto.gif';
  2626. $res[$row['goodsid']]['uri'] = rewrite('goods', array('id' => $row['goodsid']));
  2627. }
  2628. return $res;
  2629. }
  2630. function mymps_get_coupons($num = 10, $grade = 0)
  2631. {
  2632. global $db;
  2633. global $db_mymps;
  2634. global $city;
  2635. static $res;
  2636. $limit = $num ? ' LIMIT 0,' . $num : '';
  2637. $where = $grade ? ' WHERE grade > \'' . $grade . '\'' : ' WHERE grade > \'0\'';
  2638. $query = $db->query('SELECT * FROM `' . $db_mymps . 'coupon` ' . $where . ' ORDER BY begindate DESC ' . $limit);
  2639. while ($row = $db->fetchRow($query)) {
  2640. $res[$row['id']]['id'] = $row['id'];
  2641. $res[$row['id']]['title'] = $row['title'];
  2642. $res[$row['id']]['des'] = $row['des'];
  2643. $res[$row['id']]['picture'] = $row['picture'];
  2644. $res[$row['id']]['pre_picture'] = $row['pre_picture'];
  2645. $res[$row['id']]['userid'] = $row['userid'];
  2646. $res[$row['id']]['uri'] = plugin_url('coupon', array('id' => $row['id']));
  2647. $res[$row['id']]['begindate'] = $row['begindate'];
  2648. $res[$row['id']]['enddate'] = $row['enddate'];
  2649. $res[$row['id']]['dateline'] = $row['dateline'];
  2650. }
  2651. return 0 < count($res) ? $res : false;
  2652. }
  2653. function mymps_get_navurl($type, $num = '30')
  2654. {
  2655. $data = read_static_cache('navurl_' . $type);
  2656. if ($data === false) {
  2657. if ($type == 'foot') {
  2658. $query = 'SELECT * FROM `' . $GLOBALS['db_mymps'] . 'navurl` WHERE isview = \'2\' AND typeid = \'2\' ORDER BY displayorder ASC LIMIT 0,' . $num;
  2659. }
  2660. else if ($type == 'header') {
  2661. $query = 'SELECT * FROM `' . $GLOBALS['db_mymps'] . 'navurl` WHERE isview = \'2\' AND typeid = \'3\' ORDER BY displayorder ASC LIMIT 0,' . $num;
  2662. }
  2663. else if ($type == 'head') {
  2664. $query = 'SELECT * FROM `' . $GLOBALS['db_mymps'] . 'navurl` WHERE isview = \'2\' AND typeid = \'1\' ORDER BY displayorder ASC LIMIT 0,' . $num;
  2665. }
  2666. $res = $GLOBALS['db']->getAll($query);
  2667. write_static_cache('navurl_' . $type, $res);
  2668. }
  2669. else {
  2670. $res = $data;
  2671. }
  2672. return $res;
  2673. }
  2674. function get_aboutus($id = NULL)
  2675. {
  2676. global $seo;
  2677. if (!$seo) {
  2678. $seo = get_seoset();
  2679. }
  2680. if (!$id) {
  2681. $query = $GLOBALS['db']->query('SELECT id,typename,pubdate,dir_typename FROM `' . $GLOBALS['db_mymps'] . 'about` ORDER BY displayorder,id ASC');
  2682. while ($row = $GLOBALS['db']->fetchRow($query)) {
  2683. $arr['id'] = $row['id'];
  2684. $arr['typename'] = $row['typename'];
  2685. $arr['pubdate'] = $row['pubdate'];
  2686. $arr['uri'] = $row['redirect_url'] ? $row['redirect_url'] : rewrite('about', array('part' => 'aboutus', 'id' => $row['id'], 'html_path' => '/aboutus/' . $row['dir_typename'] . $seo['seo_htmlext']));
  2687. $arr['uri_m'] = mrewrite('about', array('part' => 'aboutus', 'id' => $row['id']));
  2688. $aboutus[] = $arr;
  2689. }
  2690. }
  2691. else {
  2692. $aboutus = $GLOBALS['db']->getRow('SELECT * FROM ' . $GLOBALS['db_mymps'] . 'about WHERE id =' . $id);
  2693. }
  2694. return $aboutus;
  2695. }
  2696. function get_faq($id = NULL)
  2697. {
  2698. global $seo;
  2699. global $db;
  2700. global $db_mymps;
  2701. if (!$seo) {
  2702. $seo = get_seoset();
  2703. }
  2704. if ($id) {
  2705. $faq = $db->getRow('SELECT id,title,content FROM `' . $db_mymps . 'faq` WHERE id = \'' . $id . '\'');
  2706. }
  2707. else {
  2708. $query = $db->query('SELECT id,typename FROM `' . $db_mymps . 'faq_type` ORDER BY id ASC');
  2709. while ($row = $db->fetchRow($query)) {
  2710. $faq[$row['id']]['typename'] = $row['typename'];
  2711. }
  2712. $query = $row = NULL;
  2713. $query = $db->query('SELECT * FROM `' . $db_mymps . 'faq` ORDER BY id DESC');
  2714. while ($row = $db->fetchRow($query)) {
  2715. $arr['id'] = $row['id'];
  2716. $arr['title'] = $row['title'];
  2717. $arr['uri'] = rewrite('about', array('part' => 'faq', 'id' => $row['id'], 'html_path' => '/faq/' . $row['id'] . $seo['seo_htmlext']));
  2718. $faq[$row['typeid']]['faq'][$row['id']] = $arr;
  2719. }
  2720. }
  2721. return $faq;
  2722. }
  2723. function get_flink()
  2724. {
  2725. global $db;
  2726. global $db_mymps;
  2727. $query = $db->query('SELECT * FROM `' . $db_mymps . 'flink_type` ORDER BY id ASC');
  2728. while ($row = $db->fetchRow($query)) {
  2729. $flink[$row['id']]['typename'] = $row['typename'];
  2730. }
  2731. $query = $row = NULL;
  2732. $query = $db->query('SELECT * FROM `' . $db_mymps . 'flink` WHERE ischeck = \'2\' ' . $city_limit . ' ORDER BY weblogo DESC,ordernumber DESC,id DESC');
  2733. while ($row = $db->fetchRow($query)) {
  2734. $arr['id'] = $row['id'];
  2735. $arr['webname'] = $row['webname'];
  2736. $arr['weblogo'] = $row['weblogo'];
  2737. $arr['url'] = $row['url'];
  2738. if ($row['weblogo']) {
  2739. $flink[$row['typeid']]['imglink'][$row['id']] = $arr;
  2740. }
  2741. else {
  2742. $flink[$row['typeid']]['txtlink'][$row['id']] = $arr;
  2743. }
  2744. }
  2745. return $flink;
  2746. }
  2747. function get_member_info($userid = '')
  2748. {
  2749. $row = $GLOBALS['db']->getRow('SELECT * FROM `' . $GLOBALS['db_mymps'] . 'member` WHERE userid = \'' . $userid . '\'');
  2750. return $row;
  2751. }
  2752. function chk_member_purview($purview)
  2753. {
  2754. global $db;
  2755. global $db_mymps;
  2756. global $s_uid;
  2757. $member = get_member_group('', $s_uid);
  2758. if (!in_array($purview, explode(',', $member['purviews']))) {
  2759. write_msg('您当前的会员级别没有该栏目的操作权限!<br />请先升级会员级别!', 'index.php?m=levelup');
  2760. }
  2761. else {
  2762. return $member;
  2763. }
  2764. }
  2765. function get_member_group($groupid = '', $userid = '')
  2766. {
  2767. if (empty($groupid)) {
  2768. $groupid = $GLOBALS['db']->getOne('SELECT levelid FROM ' . $GLOBALS['db_mymps'] . 'member WHERE userid = \'' . $userid . '\'');
  2769. }
  2770. $data = read_static_cache('member_' . $groupid);
  2771. if ($data === false) {
  2772. $res = $GLOBALS['db']->getRow('SELECT * FROM `' . $GLOBALS['db_mymps'] . 'member_level` WHERE id = \'' . $groupid . '\'');
  2773. $res['allow_tpl'] = empty($res['allow_tpl']) ? '/template/space/theme1' : $res['allow_tpl'];
  2774. $in = create_in(explode(',', $res['allow_tpl']), 'tpl_path');
  2775. $query = $GLOBALS['db']->query('SELECT * FROM `' . $GLOBALS['db_mymps'] . 'member_tpl` WHERE ' . $in . ' AND if_view = \'2\'');
  2776. $res['allow_tpl'] = array();
  2777. while ($row = $GLOBALS['db']->fetchRow($query)) {
  2778. $res['allow_tpl'][$row['id']]['tpl_name'] = $row['tpl_name'];
  2779. $res['allow_tpl'][$row['id']]['tpl_path'] = $row['tpl_path'];
  2780. }
  2781. write_static_cache('member_' . $groupid, $res);
  2782. }
  2783. else {
  2784. $res = $data;
  2785. }
  2786. return $res;
  2787. }
  2788. function write_pwd_smarty($action = '修改')
  2789. {
  2790. global $smarty;
  2791. global $post;
  2792. global $title;
  2793. global $cat;
  2794. global $part;
  2795. global $id;
  2796. $title = '输入管理密码 - ' . $action . '信息 - ' . $post[title];
  2797. $nav_bar = '<a href="../info.php?id=' . $id . '">' . $post[title] . '</a> &raquo; 输入管理密码 &raquo; ' . $action . '信息</li>';
  2798. $post['part'] = $part;
  2799. tpl_assign();
  2800. $smarty->assign('title', $title);
  2801. $smarty->assign('post', $post);
  2802. $smarty->assign('nav_bar', $nav_bar);
  2803. $smarty->assign('cat', $cat);
  2804. $smarty->assign('action', $action);
  2805. $smarty->display(mymps_tpl('info_write_pwd', 'smarty'));
  2806. }
  2807. function runcron()
  2808. {
  2809. global $timestamp;
  2810. global $db;
  2811. global $db_mymps;
  2812. include MYMPS_ROOT . '/data/cron.cache.php';
  2813. if (is_array($m_cron)) {
  2814. $i = 0;
  2815. foreach ($m_cron as $key => $cron) {
  2816. if ($cron['nextrun'] <= $timestamp) {
  2817. list($yearnow, $monthnow, $daynow) = explode('-', gmdate('Y-m-d', $timestamp + 8 * 3600));
  2818. $nextrun = @gmmktime(0, 0, 0, $monthnow, $daynow + 1, $yearnow) - 8 * 3600;
  2819. include MYMPS_ROOT . '/include/crons/' . $key . '.inc.php';
  2820. $db->query('UPDATE `' . $db_mymps . 'crons` SET lastrun=' . $timestamp . ',nextrun=' . $nextrun . (' WHERE name=\'' . $key . '\''));
  2821. $i++;
  2822. }
  2823. }
  2824. if (0 < $i) {
  2825. write_cron_cache();
  2826. }
  2827. }
  2828. else {
  2829. write_cron_cache();
  2830. }
  2831. }
  2832. function ifplugin($pluginname = '')
  2833. {
  2834. global $pluginsettings;
  2835. global $mymps_global;
  2836. if (!$pluginsettings) {
  2837. @include MYMPS_DATA . '/caches/plugin.php';
  2838. $pluginsettings = $data;
  2839. unset($data);
  2840. }
  2841. if ($mymps_global['cfg_if_corp'] != 1) {
  2842. unset($pluginsettings['coupon']);
  2843. unset($pluginsettings['group']);
  2844. unset($pluginsettings['goods']);
  2845. }
  2846. return !$pluginsettings[$pluginname] || $pluginsettings[$pluginname]['disable'] == 1 ? false : true;
  2847. unset($pluginsettings);
  2848. }
  2849. function cutstr($string, $length, $dot = '')
  2850. {
  2851. global $charset;
  2852. if (strlen($string) <= $length) {
  2853. return $string;
  2854. }
  2855. $string = str_replace(array('&amp;', '&quot;', '&lt;', '&gt;'), array('&', '"', '<', '>'), $string);
  2856. $strcut = '';
  2857. if (strtolower($charset) == 'utf-8') {
  2858. $n = $tn = $noc = 0;
  2859. while ($n < strlen($string)) {
  2860. $t = ord($string[$n]);
  2861. if ($t == 9 || $t == 10 || 32 <= $t && $t <= 126) {
  2862. $tn = 1;
  2863. $n++;
  2864. $noc++;
  2865. }
  2866. else {
  2867. if (194 <= $t && $t <= 223) {
  2868. $tn = 2;
  2869. $n += 2;
  2870. $noc += 2;
  2871. }
  2872. else {
  2873. if (224 <= $t && $t < 239) {
  2874. $tn = 3;
  2875. $n += 3;
  2876. $noc += 2;
  2877. }
  2878. else {
  2879. if (240 <= $t && $t <= 247) {
  2880. $tn = 4;
  2881. $n += 4;
  2882. $noc += 2;
  2883. }
  2884. else {
  2885. if (248 <= $t && $t <= 251) {
  2886. $tn = 5;
  2887. $n += 5;
  2888. $noc += 2;
  2889. }
  2890. else {
  2891. if ($t == 252 || $t == 253) {
  2892. $tn = 6;
  2893. $n += 6;
  2894. $noc += 2;
  2895. }
  2896. else {
  2897. $n++;
  2898. }
  2899. }
  2900. }
  2901. }
  2902. }
  2903. }
  2904. if ($length <= $noc) {
  2905. break;
  2906. }
  2907. }
  2908. if ($length < $noc) {
  2909. $n -= $tn;
  2910. }
  2911. $strcut = substr($string, 0, $n);
  2912. }
  2913. else {
  2914. for ($i = 0; $i < $length; $i++) {
  2915. $strcut .= 127 < ord($string[$i]) ? $string[$i] . $string[++$i] : $string[$i];
  2916. }
  2917. }
  2918. $strcut = str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $strcut);
  2919. return $strcut . $dot;
  2920. }
  2921. function mmd5($string, $action = 'EN', $rand = '', $db_mixcode = '')
  2922. {
  2923. global $db_mixcode;
  2924. $secret_string = $db_mixcode . $rand . '^fgfZ4_9dfjdf';
  2925. if ($string == '') {
  2926. return '';
  2927. }
  2928. if ($action == 'EN') {
  2929. $md5code = substr(md5($string), 8, 10);
  2930. }
  2931. else {
  2932. $md5code = substr($string, -10);
  2933. $string = substr($string, 0, strlen($string) - 10);
  2934. }
  2935. $key = md5($md5code . $secret_string);
  2936. $string = $action == 'EN' ? $string : base64_decode($string);
  2937. $len = strlen($key);
  2938. $code = '';
  2939. for ($i = 0; $i < strlen($string); $i++) {
  2940. $k = $i % $len;
  2941. $code .= $string[$i] ^ $key[$k];
  2942. }
  2943. $code = $action == 'DE' ? (substr(md5($code), 8, 10) == $md5code ? $code : NULL) : base64_encode($code) . $md5code;
  2944. return $code;
  2945. }
  2946. function mymps_get_goods_children($catid)
  2947. {
  2948. if ($row = $GLOBALS['db']->getAll('SELECT catid FROM `' . $GLOBALS['db_mymps'] . 'goods_category` WHERE parentid = \'' . $catid . '\'')) {
  2949. $cat = array();
  2950. foreach ($row as $k => $v) {
  2951. $cat[$v['catid']] = $v['catid'];
  2952. }
  2953. $cats = implode(',', $cat) . ',' . $catid;
  2954. return $cats;
  2955. }
  2956. else {
  2957. return $catid;
  2958. }
  2959. }
  2960. function get_groups($num = 10, $glevel = 0)
  2961. {
  2962. global $db;
  2963. global $db_mymps;
  2964. static $res;
  2965. $limit = $num ? ' LIMIT 0,' . $num : '';
  2966. $where = $glevel ? ' WHERE glevel > \'' . $glevel . '\'' : ' WHERE glevel > \'0\'';
  2967. $query = $db->query('SELECT * FROM `' . $db_mymps . 'group` ' . $where . ' ORDER BY dateline DESC ' . $limit);
  2968. while ($row = $db->fetchRow($query)) {
  2969. $res[$row['groupid']]['groupid'] = $row['groupid'];
  2970. $res[$row['groupid']]['gname'] = $row['gname'];
  2971. $res[$row['groupid']]['picture'] = $row['picture'];
  2972. $res[$row['groupid']]['pre_picture'] = $row['pre_picture'];
  2973. $res[$row['groupid']]['userid'] = $row['userid'];
  2974. $res[$row['groupid']]['uri'] = plugin_url('group', array('id' => $row['groupid']));
  2975. $res[$row['groupid']]['gaddress'] = $row['gaddress'];
  2976. $res[$row['groupid']]['meetdate'] = $row['meetdate'];
  2977. $res[$row['groupid']]['enddate'] = $row['enddate'];
  2978. $res[$row['groupid']]['dateline'] = $row['dateline'];
  2979. }
  2980. return 0 < count($res) ? $res : false;
  2981. }
  2982. function get_goods($num = 10, $onsale = 1, $shuxing = '', $catid = '', $userid = '')
  2983. {
  2984. global $db;
  2985. global $db_mymps;
  2986. $limit = $num ? ' LIMIT 0,' . $num : '';
  2987. $where = $onsale == 1 ? ' WHERE onsale = \'1\'' : ' WHERE 1';
  2988. $where .= $userid ? ' AND userid = \'' . $userid . '\'' : '';
  2989. $where .= $shuxing == 'cuxiao' ? ' AND cuxiao = \'1\'' : '';
  2990. $where .= $shuxing == 'remai' ? ' AND remai = \'1\'' : '';
  2991. $where .= $shuxing == 'tuijian' ? ' AND tuijian = \'1\'' : '';
  2992. $where .= $catid ? ' AND catid IN(' . get_goods_children($catid) . ')' : '';
  2993. $query = $db->query('SELECT * FROM `' . $db_mymps . 'goods` ' . $where . ' ORDER BY dateline DESC ' . $limit);
  2994. while ($row = $db->fetchRow($query)) {
  2995. $res[$row['goodsid']]['goodsid'] = $row['goodsid'];
  2996. $res[$row['goodsid']]['goodsname'] = $row['goodsname'];
  2997. $res[$row['goodsid']]['oldprice'] = $row['oldprice'];
  2998. $res[$row['goodsid']]['nowprice'] = $row['nowprice'];
  2999. $res[$row['goodsid']]['pre_picture'] = $row['pre_picture'] ? $row['pre_picture'] : $mymps_global['SiteUrl'] . '/images/nophoto.gif';
  3000. $res[$row['goodsid']]['uri'] = plugin_url('goods', array('id' => $row['goodsid']));
  3001. }
  3002. return 0 < count($res) ? $res : false;
  3003. }
  3004. function get_coupons($num = 10, $grade = 0)
  3005. {
  3006. global $db;
  3007. global $db_mymps;
  3008. static $res;
  3009. $limit = $num ? ' LIMIT 0,' . $num : '';
  3010. $where = $grade ? ' WHERE grade > \'' . $grade . '\'' : ' WHERE grade > \'0\'';
  3011. $query = $db->query('SELECT * FROM `' . $db_mymps . 'coupon` ' . $where . ' ORDER BY begindate DESC ' . $limit);
  3012. while ($row = $db->fetchRow($query)) {
  3013. $res[$row['id']]['id'] = $row['id'];
  3014. $res[$row['id']]['title'] = $row['title'];
  3015. $res[$row['id']]['des'] = $row['des'];
  3016. $res[$row['id']]['picture'] = $row['picture'];
  3017. $res[$row['id']]['pre_picture'] = $row['pre_picture'];
  3018. $res[$row['id']]['userid'] = $row['userid'];
  3019. $res[$row['id']]['uri'] = plugin_url('coupon', array('id' => $row['id']));
  3020. $res[$row['id']]['begindate'] = $row['begindate'];
  3021. $res[$row['id']]['enddate'] = $row['enddate'];
  3022. $res[$row['id']]['dateline'] = $row['dateline'];
  3023. }
  3024. return 0 < count($res) ? $res : false;
  3025. }
  3026. function ifsiteopen()
  3027. {
  3028. global $mymps_global;
  3029. if ($mymps_global['cfg_if_site_open'] != 1) {
  3030. $mymps_global['cfg_site_open_reason'] = str_replace('\\n', '<br />', $mymps_global['cfg_site_open_reason']);
  3031. exit('网站已关闭,关闭原因:<br><br /><b>' . $mymps_global['cfg_site_open_reason'] . '</b>');
  3032. }
  3033. }
  3034. function replace_insidelink($txt, $type = 'information')
  3035. {
  3036. $data = read_static_cache('insidelink');
  3037. if (is_array($data['detail']) && $data['settings']['forward'][$type] == 1) {
  3038. $word = $replacement = array();
  3039. foreach ($data['detail'] as $k => $v) {
  3040. $word[] = $k;
  3041. $replacement[] = '<a href="' . $v . '" target="_blank">' . $k . '</a>';
  3042. }
  3043. $txts = @preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', 'replacelight(\'\\2\', $word, $replacement, \'\\1\')', $txt, 2);
  3044. }
  3045. else {
  3046. $txts = $txt;
  3047. }
  3048. return $txts;
  3049. }
  3050. function replacelight($txt, $word, $replacement, $pre)
  3051. {
  3052. $txt = str_replace('\\"', '"', $txt);
  3053. $txt = str_replace($word, $replacement, $txt);
  3054. return $pre . $txt;
  3055. }
  3056. function pcclient()
  3057. {
  3058. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  3059. $mobile_agents = array('240x320', 'acer', 'acoon', 'acs-', 'abacho', 'ahong', 'airness', 'alcatel', 'amoi', 'android', 'anywhereyougo.com', 'applewebkit/525', 'applewebkit/532', 'asus', 'audio', 'au-mic', 'avantogo', 'becker', 'benq', 'bilbo', 'bird', 'blackberry', 'blazer', 'bleu', 'cdm-', 'compal', 'coolpad', 'danger', 'dbtel', 'dopod', 'elaine', 'eric', 'etouch', 'fly ', 'fly_', 'fly-', 'go.web', 'goodaccess', 'gradiente', 'grundig', 'haier', 'hedy', 'hitachi', 'htc', 'huawei', 'hutchison', 'inno', 'ipaq', 'ipod', 'jbrowser', 'kddi', 'kgt', 'kwc', 'lenovo', 'lg ', 'lg2', 'lg3', 'lg4', 'lg5', 'lg7', 'lg8', 'lg9', 'lg-', 'lge-', 'lge9', 'longcos', 'maemo', 'mercator', 'meridian', 'micromax', 'midp', 'mini', 'mitsu', 'mmm', 'mmp', 'mobi', 'mot-', 'moto', 'nec-', 'netfront', 'newgen', 'nexian', 'nf-browser', 'nintendo', 'nitro', 'nokia', 'nook', 'novarra', 'obigo', 'palm', 'panasonic', 'pantech', 'philips', 'phone', 'pg-', 'playstation', 'pocket', 'pt-', 'qc-', 'qtek', 'rover', 'sagem', 'sama', 'samu', 'sanyo', 'samsung', 'sch-', 'scooter', 'sec-', 'sendo', 'sgh-', 'sharp', 'siemens', 'sie-', 'softbank', 'sony', 'spice', 'sprint', 'spv', 'symbian', 'tablet', 'talkabout', 'tcl-', 'teleca', 'telit', 'tianyu', 'tim-', 'toshiba', 'tsm', 'up.browser', 'utec', 'utstar', 'verykool', 'virgin', 'vk-', 'voda', 'voxtel', 'vx', 'wap', 'wellco', 'wig browser', 'wii', 'windows ce', 'wireless', 'xda', 'xde', 'zte');
  3060. $is_mobile = true;
  3061. foreach ($mobile_agents as $device) {
  3062. if (stristr($user_agent, $device)) {
  3063. $is_mobile = false;
  3064. break;
  3065. }
  3066. }
  3067. return $is_mobile;
  3068. }
  3069. function get_smplist_cats($cats, $showstyle)
  3070. {
  3071. global $db;
  3072. global $db_mymps;
  3073. global $mymps_global;
  3074. $query = $db->query('SELECT * FROM `' . $db_mymps . 'category` WHERE catid ' . create_in($cats) . ' AND if_view = \'2\' ORDER BY catorder ASC');
  3075. while ($row = $db->fetchRow($query)) {
  3076. $listcats[$row['catid']]['catid'] = $row['catid'];
  3077. $listcats[$row['catid']]['catname'] = $row['catname'];
  3078. $listcats[$row['catid']]['icon'] = $row['icon'];
  3079. $listcats[$row['catid']]['caturi'] = rewrite('category', array('catid' => $row['catid'], 'html_dir' => $row['html_dir'], 'dir_typename' => $row['dir_typename']));
  3080. $listcats[$row['catid']]['showstyle'] = $showstyle[$row['catid']];
  3081. $listcats[$row['catid']]['color'] = $row['color'];
  3082. }
  3083. $query = $db->query('SELECT * FROM `' . $db_mymps . 'category` WHERE parentid ' . create_in($cats) . ' AND if_view = \'2\' ORDER BY catorder ASC');
  3084. while ($r = $db->fetchRow($query)) {
  3085. $listcats[$r['parentid']]['children'][$r['catid']]['catid'] = $r['catid'];
  3086. $listcats[$r['parentid']]['children'][$r['catid']]['catname'] = $r['catname'];
  3087. $listcats[$r['parentid']]['children'][$r['catid']]['color'] = $r['color'];
  3088. $listcats[$r['parentid']]['children'][$r['catid']]['caturi'] = rewrite('category', array('catid' => $r['catid'], 'html_dir' => $r['html_dir'], 'dir_typename' => $r['dir_typename']));
  3089. }
  3090. return $listcats;
  3091. }
  3092. function getbrowser()
  3093. {
  3094. global $_SERVER;
  3095. $agent = $_SERVER['HTTP_USER_AGENT'];
  3096. $browser = '';
  3097. $browser_ver = '';
  3098. if (preg_match('/OmniWeb\\/(v*)([^\\s|;]+)/i', $agent, $regs)) {
  3099. $browser = 'OmniWeb';
  3100. $browser_ver = $regs[2];
  3101. }
  3102. else if (preg_match('/Netscape([\\d]*)\\/([^\\s]+)/i', $agent, $regs)) {
  3103. $browser = 'Netscape';
  3104. $browser_ver = $regs[2];
  3105. }
  3106. else if (preg_match('/Chrome\\/([^\\s]+)/i', $agent, $regs)) {
  3107. $browser = 'Chrome';
  3108. $browser_ver = $regs[1];
  3109. }
  3110. else if (preg_match('/safari\\/([^\\s]+)/i', $agent, $regs)) {
  3111. $browser = 'Safari';
  3112. $browser_ver = $regs[1];
  3113. }
  3114. else if (preg_match('/MSIE\\s([^\\s|;]+)/i', $agent, $regs)) {
  3115. $browser = 'Internet Explorer';
  3116. $browser_ver = $regs[1];
  3117. }
  3118. else if (preg_match('/Opera[\\s|\\/]([^\\s]+)/i', $agent, $regs)) {
  3119. $browser = 'Opera';
  3120. $browser_ver = $regs[1];
  3121. }
  3122. else if (preg_match('/NetCaptor\\s([^\\s|;]+)/i', $agent, $regs)) {
  3123. $browser = '(Internet Explorer ' . $browser_ver . ') NetCaptor';
  3124. $browser_ver = $regs[1];
  3125. }
  3126. else if (preg_match('/Maxthon/i', $agent, $regs)) {
  3127. $browser = '(Internet Explorer ' . $browser_ver . ') Maxthon';
  3128. $browser_ver = '';
  3129. }
  3130. else if (preg_match('/360SE/i', $agent, $regs)) {
  3131. $browser = '(Internet Explorer ' . $browser_ver . ') 360SE';
  3132. $browser_ver = '';
  3133. }
  3134. else if (preg_match('/SE 2.x/i', $agent, $regs)) {
  3135. $browser = '(Internet Explorer ' . $browser_ver . ') 搜狗';
  3136. $browser_ver = '';
  3137. }
  3138. else if (preg_match('/FireFox\\/([^\\s]+)/i', $agent, $regs)) {
  3139. $browser = 'FireFox';
  3140. $browser_ver = $regs[1];
  3141. }
  3142. else if (preg_match('/Lynx\\/([^\\s]+)/i', $agent, $regs)) {
  3143. $browser = 'Lynx';
  3144. $browser_ver = $regs[1];
  3145. }
  3146. if ($browser != '') {
  3147. return $browser . ' ' . $browser_ver;
  3148. }
  3149. else {
  3150. return '未知浏览器版本';
  3151. }
  3152. }
  3153. function getos()
  3154. {
  3155. $agent = $_SERVER['HTTP_USER_AGENT'];
  3156. $os = false;
  3157. if (@eregi('win', $agent) && strpos($agent, '95')) {
  3158. $os = 'Windows 95';
  3159. }
  3160. else {
  3161. if (@eregi('win 9x', $agent) && strpos($agent, '4.90')) {
  3162. $os = 'Windows ME';
  3163. }
  3164. else {
  3165. if (@eregi('win', $agent) && @ereg('98', $agent)) {
  3166. $os = 'Windows 98';
  3167. }
  3168. else {
  3169. if (@eregi('win', $agent) && @eregi('nt 5.1', $agent)) {
  3170. $os = 'Windows XP';
  3171. }
  3172. else {
  3173. if (@eregi('win', $agent) && @eregi('nt 5', $agent)) {
  3174. $os = 'Windows 2000';
  3175. }
  3176. else {
  3177. if (@eregi('win', $agent) && @eregi('nt', $agent)) {
  3178. $os = 'Windows NT';
  3179. }
  3180. else {
  3181. if (@eregi('win', $agent) && @ereg('32', $agent)) {
  3182. $os = 'Windows 32';
  3183. }
  3184. else if (@eregi('linux', $agent)) {
  3185. $os = 'Linux';
  3186. }
  3187. else if (@eregi('unix', $agent)) {
  3188. $os = 'Unix';
  3189. }
  3190. else {
  3191. if (@eregi('sun', $agent) && @eregi('os', $agent)) {
  3192. $os = 'SunOS';
  3193. }
  3194. else {
  3195. if (@eregi('ibm', $agent) && @eregi('os', $agent)) {
  3196. $os = 'IBM OS/2';
  3197. }
  3198. else {
  3199. if (@eregi('Mac', $agent) && @eregi('PC', $agent)) {
  3200. $os = 'Macintosh';
  3201. }
  3202. else if (@eregi('PowerPC', $agent)) {
  3203. $os = 'PowerPC';
  3204. }
  3205. else if (@eregi('AIX', $agent)) {
  3206. $os = 'AIX';
  3207. }
  3208. else if (@eregi('HPUX', $agent)) {
  3209. $os = 'HPUX';
  3210. }
  3211. else if (@eregi('NetBSD', $agent)) {
  3212. $os = 'NetBSD';
  3213. }
  3214. else if (@eregi('BSD', $agent)) {
  3215. $os = 'BSD';
  3216. }
  3217. else if (@ereg('OSF1', $agent)) {
  3218. $os = 'OSF1';
  3219. }
  3220. else if (@ereg('IRIX', $agent)) {
  3221. $os = 'IRIX';
  3222. }
  3223. else if (@eregi('FreeBSD', $agent)) {
  3224. $os = 'FreeBSD';
  3225. }
  3226. else if (@eregi('teleport', $agent)) {
  3227. $os = 'teleport';
  3228. }
  3229. else if (@eregi('flashget', $agent)) {
  3230. $os = 'flashget';
  3231. }
  3232. else if (@eregi('webzip', $agent)) {
  3233. $os = 'webzip';
  3234. }
  3235. else if (@eregi('offline', $agent)) {
  3236. $os = 'offline';
  3237. }
  3238. else {
  3239. $os = 'Unknown';
  3240. }
  3241. }
  3242. }
  3243. }
  3244. }
  3245. }
  3246. }
  3247. }
  3248. }
  3249. }
  3250. return $os;
  3251. }
  3252. function getport()
  3253. {
  3254. return $_SERVER['REMOTE_PORT'];
  3255. }
  3256. function strexists($haystack, $needle)
  3257. {
  3258. return !(strpos($haystack, $needle) === false);
  3259. }
  3260. function is_robot()
  3261. {
  3262. $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
  3263. if (!empty($ua)) {
  3264. $spiderAgentArr = array('Baiduspider', 'Googlebot', '360Spider', 'Sosospider', 'sogou spider');
  3265. foreach ($spiderAgentArr as $val) {
  3266. $spiderAgent = strtolower($val);
  3267. if (strpos($ua, $spiderAgent) !== false) {
  3268. return true;
  3269. }
  3270. }
  3271. return false;
  3272. }
  3273. else {
  3274. return false;
  3275. }
  3276. }
  3277. function get_gid($catid)
  3278. {
  3279. global $db;
  3280. global $db_mymps;
  3281. global $mymps_global;
  3282. $sid = $db->getOne('SELECT parentid FROM `' . $db_mymps . 'category` WHERE catid=\'' . $catid . '\'');
  3283. if (empty($sid)) {
  3284. return $catid;
  3285. }
  3286. else {
  3287. $fid = $db->getOne('SELECT parentid FROM `' . $db_mymps . 'category` WHERE catid = \'' . $sid . '\'');
  3288. if (empty($fid)) {
  3289. return $sid;
  3290. }
  3291. else {
  3292. $did = $db->getOne('SELECT parentid FROM `' . $db_mymps . 'category` WHERE catid = \'' . $fid . '\'');
  3293. if (empty($did)) {
  3294. return $fid;
  3295. }
  3296. }
  3297. }
  3298. }
  3299. function mymps_chk_smsrandcode($getcode = '', $phonenum = '')
  3300. {
  3301. global $timestamp;
  3302. session_start();
  3303. $getcode = trim(strtoupper($getcode));
  3304. $sessioncode = $_SESSION['smscode']['code'];
  3305. if ($phonenum) {
  3306. if ($timestamp < $_SESSION['smscode']['time'] && $sessioncode == $getcode && $phonenum == $_SESSION['smscode']['phonenum']) {
  3307. return true;
  3308. }
  3309. }
  3310. else {
  3311. if ($timestamp < $_SESSION['smscode']['time'] && $sessioncode == $getcode) {
  3312. return true;
  3313. }
  3314. }
  3315. return false;
  3316. }
  3317. function is_mobile($phonenum)
  3318. {
  3319. return preg_match('/1[3456789]{1}\\d{9}$/', $phonenum) ? true : false;
  3320. }
  3321. function mkFolder($path)
  3322. {
  3323. if (!is_readable($path)) {
  3324. is_file($path) || mkdir($path, 511);
  3325. }
  3326. }
  3327. function GetCurSinImg($goods_desc)
  3328. {
  3329. require_once MYMPS_INC . '/upfile.fun.php';
  3330. global $mymps_global;
  3331. $host = $mymps_global['SiteUrl'];
  3332. $body = stripslashes($goods_desc);
  3333. $img_array = array();
  3334. preg_match_all('/<img.*?src="(.*?)".*?>/is', $body, $img_array);
  3335. $img_array = array_unique($img_array[1]);
  3336. $imgurl = '/editor/' . date('Ymd');
  3337. $imgpath = MYMPS_UPLOAD . $imgurl;
  3338. $millisecond = date('YmdHms') . random(5);
  3339. mkfolder($imgpath);
  3340. if (!is_array($img_array)) {
  3341. return false;
  3342. }
  3343. else {
  3344. foreach ($img_array as $key => $value) {
  3345. file_put_contents('file.log', $value . '
  3346. ', FILE_APPEND);
  3347. if (strpos($value, $host) === 0 || strpos($value, 'attachment/editor')) {
  3348. continue;
  3349. }
  3350. $value = trim($value);
  3351. $imgAttr = get_headers($value, true);
  3352. switch ($imgAttr['Content-Type']) {
  3353. case 'image/png':
  3354. $ext = 'png';
  3355. break;
  3356. case 'image/jpeg':
  3357. $ext = 'jpg';
  3358. break;
  3359. case 'image/gif':
  3360. $ext = 'gif';
  3361. break;
  3362. default:
  3363. $ext = 'jpg';
  3364. }
  3365. $get_file = @file_get_contents($value);
  3366. $rndfilename = $imgpath . '/' . $millisecond . $key . '.' . $ext;
  3367. $fileurl = $host . '/attachment' . $imgurl . '/' . $millisecond . $key . '.' . $ext;
  3368. if ($get_file) {
  3369. $fp = @fopen($rndfilename, 'w');
  3370. @fwrite($fp, $get_file);
  3371. @fclose($fp);
  3372. WaterImg($rndfilename);
  3373. }
  3374. $body = str_replace($value, $fileurl, $body);
  3375. }
  3376. }
  3377. $body = addslashes($body);
  3378. return $body;
  3379. }
  3380. if (!function_exists('htmlspecialchars_decode')) {
  3381. function htmlspecialchars_decode($text)
  3382. {
  3383. return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
  3384. }
  3385. }
  3386. ?>