1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870 |
- <?php
-
-
-
- use think\Db;
-
- error_reporting(0);
-
- include_once EXTEND_PATH."function.php";
-
-
-
- if (!function_exists('switch_exception'))
- {
-
- function switch_exception() {
- $web_exception = tpCache('web.web_exception');
- if (!empty($web_exception)) {
- config('ey_config.web_exception', $web_exception);
- error_reporting(-1);
- }
- }
- }
-
- if (!function_exists('adminLog'))
- {
-
-
- function adminLog($log_info = ''){
-
- try {
- $ajaxLogic = new \app\admin\logic\AjaxLogic;
- $ajaxLogic->del_adminlog();
-
- $admin_id = session('admin_id');
- $admin_id = !empty($admin_id) ? $admin_id : -1;
- if ($admin_id > 0) {
- $add['log_time'] = getTime();
- $add['admin_id'] = $admin_id;
- $add['log_info'] = htmlspecialchars($log_info);
- $add['log_ip'] = clientIP();
- $add['log_url'] = request()->baseUrl() ;
- M('admin_log')->add($add);
- }
- } catch (\Exception $e) {
-
- }
- }
- }
-
- if (!function_exists('login_third_type'))
- {
-
-
- function login_third_type()
- {
- $redata = [
- 'type' => '',
- 'data' => [],
- ];
-
- if (is_dir('./weapp/EyouGzhLogin/')) {
- $EyouGzhLoginRow = model('Weapp')->getWeappList('EyouGzhLogin');
- $status = !empty($EyouGzhLoginRow['status']) ? intval($EyouGzhLoginRow['status']) : 0;
- $data = !empty($EyouGzhLoginRow['data']) ? $EyouGzhLoginRow['data'] : [];
- if (1 == $status && !empty($data['is_open'])) {
- $redata['type'] = $data['mode'];
- if ('EyouGzhLogin' == $data['mode']) {
- $data['gzh']['switch'] = 1;
- $redata['data'] = $data['gzh'];
- }
- else if ('WechatLogin' == $data['mode']) {
- $security = tpSetting('security');
- $redata['data'] = $security;
- }
- }
- }
-
- return $redata;
- }
- }
-
- if (!function_exists('tpCache'))
- {
-
-
- function tpCache($config_key,$data = array(), $lang = '', $options = null){
- $tableName = 'config';
- $table_db = \think\Db::name($tableName);
-
- $lang = !empty($lang) ? $lang : get_current_lang();
- $param = explode('.', $config_key);
- $cache_inc_type = "{$tableName}-{$lang}-{$param[0]}";
- if (empty($options['path'])) {
- $options['path'] = DATA_PATH.'runtime'.DS.'cache'.DS.$lang.DS;
- }
- if(empty($data)){
-
-
- $config = cache($cache_inc_type,'',$options);
- if(empty($config)){
-
- if ($param[0] == 'global') {
- $param[0] = 'global';
- $res = $table_db->where([
- 'lang' => $lang,
- 'is_del' => 0,
- ])->select();
- } else {
- $res = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- 'is_del' => 0,
- ])->select();
- }
- if($res){
- foreach($res as $k=>$val){
- $config[$val['name']] = $val['value'];
- }
- cache($cache_inc_type,$config,$options);
- }
-
- }
- if(!empty($param) && count($param)>1){
- $newKey = strtolower($param[1]);
- return isset($config[$newKey]) ? $config[$newKey] : '';
- }else{
- return $config;
- }
- }else{
-
- $result = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- 'is_del' => 0,
- ])->select();
- if($result){
- foreach($result as $val){
- $temp[$val['name']] = $val['value'];
- }
- $add_data = array();
- foreach ($data as $k=>$v){
- $newK = strtolower($k);
- $newArr = array(
- 'name'=>$newK,
- 'value'=>trim($v),
- 'inc_type'=>$param[0],
- 'lang' => $lang,
- 'update_time' => getTime(),
- );
- if(!isset($temp[$newK])){
- array_push($add_data, $newArr);
- }else{
- if ($v != $temp[$newK]) {
- $table_db->where([
- 'name' => $newK,
- 'lang' => $lang,
- ])->save($newArr);
- }
- }
- }
- if (!empty($add_data)) {
- $table_db->insertAll($add_data);
- }
-
- $newRes = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- 'is_del' => 0,
- ])->select();
- foreach ($newRes as $rs){
- $newData[$rs['name']] = $rs['value'];
- }
- }else{
- if ($param[0] != 'global') {
- foreach($data as $k=>$v){
- $newK = strtolower($k);
- $newArr[] = array(
- 'name'=>$newK,
- 'value'=>trim($v),
- 'inc_type'=>$param[0],
- 'lang' => $lang,
- 'update_time' => getTime(),
- );
- }
- !empty($newArr) && $table_db->insertAll($newArr);
- }
- $newData = $data;
- }
-
- $result = false;
- $res = $table_db->where([
- 'lang' => $lang,
- 'is_del' => 0,
- ])->select();
- if($res){
- $global = array();
- foreach($res as $k=>$val){
- $global[$val['name']] = $val['value'];
- }
- $result = cache("{$tableName}-{$lang}-global",$global,$options);
- }
-
- if ($param[0] != 'global') {
- $result = cache($cache_inc_type,$newData,$options);
- }
-
- return $result;
- }
- }
- }
-
- if (!function_exists('tpSetting'))
- {
-
-
- function tpSetting($config_key,$data = array(), $lang = '', $options = null){
- $tableName = 'setting';
- $table_db = \think\Db::name($tableName);
-
- $lang = !empty($lang) ? $lang : get_current_lang();
- $param = explode('.', $config_key);
- $cache_inc_type = "{$tableName}-{$lang}-{$param[0]}";
- if (empty($options['path'])) {
- $options['path'] = DATA_PATH.'runtime'.DS.'cache'.DS.$lang.DS;
- }
- if(empty($data)){
-
-
- $config = cache($cache_inc_type,'',$options);
- if(empty($config)){
-
- if ($param[0] == 'global') {
- $param[0] = 'global';
- $res = $table_db->where([
- 'lang' => $lang,
- ])->select();
- } else {
- $res = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- ])->select();
- }
- if($res){
- foreach($res as $k=>$val){
- $config[$val['name']] = $val['value'];
- }
- cache($cache_inc_type,$config,$options);
- }
-
- }
- if(!empty($param) && count($param)>1){
- $newKey = strtolower($param[1]);
- return isset($config[$newKey]) ? $config[$newKey] : '';
- }else{
- return $config;
- }
- }else{
-
- $result = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- ])->select();
- if($result){
- foreach($result as $val){
- $temp[$val['name']] = $val['value'];
- }
- $add_data = array();
- foreach ($data as $k=>$v){
- $newK = strtolower($k);
- $newArr = array(
- 'name'=>$newK,
- 'value'=>trim($v),
- 'inc_type'=>$param[0],
- 'lang' => $lang,
- 'update_time' => getTime(),
- );
- if(!isset($temp[$newK])){
- array_push($add_data, $newArr);
- }else{
- if ($v != $temp[$newK]) {
- $table_db->where([
- 'name' => $newK,
- 'lang' => $lang,
- ])->save($newArr);
- }
- }
- }
- if (!empty($add_data)) {
- $table_db->insertAll($add_data);
- }
-
- $newRes = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- ])->select();
- foreach ($newRes as $rs){
- $newData[$rs['name']] = $rs['value'];
- }
- }else{
- if ($param[0] != 'global') {
- foreach($data as $k=>$v){
- $newK = strtolower($k);
- $newArr[] = array(
- 'name'=>$newK,
- 'value'=>trim($v),
- 'inc_type'=>$param[0],
- 'lang' => $lang,
- 'update_time' => time(),
- );
- }
- $table_db->insertAll($newArr);
- }
- $newData = $data;
- }
-
- $result = false;
- $res = $table_db->where([
- 'lang' => $lang,
- ])->select();
- if($res){
- $global = array();
- foreach($res as $k=>$val){
- $global[$val['name']] = $val['value'];
- }
- $result = cache("{$tableName}-{$lang}-global",$global,$options);
- }
-
- if ($param[0] != 'global') {
- $result = cache($cache_inc_type,$newData,$options);
- }
-
- return $result;
- }
- }
- }
-
- if (!function_exists('write_global_params'))
- {
-
-
- function write_global_params($lang = '', $options = null)
- {
- empty($lang) && $lang = get_admin_lang();
- $webConfigParams = \think\Db::name('config')->where([
- 'inc_type' => 'web',
- 'lang' => $lang,
- 'is_del' => 0,
- ])->getAllWithIndex('name');
- $web_basehost = !empty($webConfigParams['web_basehost']) ? $webConfigParams['web_basehost']['value'] : '';
- $web_cmspath = !empty($webConfigParams['web_cmspath']) ? $webConfigParams['web_cmspath']['value'] : '';
-
- $web_multi_site = !empty($webConfigParams['web_multi_site']) ? $webConfigParams['web_multi_site']['value'] : '';
- if($web_multi_site == 1)
- {
- $web_mainsite = $web_basehost.$web_cmspath;
- }
- else
- {
- $web_mainsite = '';
- }
-
-
- $param['web_cmsurl'] = $web_mainsite;
-
-
- $web_tpl_theme = !empty($webConfigParams['web_tpl_theme']) ? $webConfigParams['web_tpl_theme']['value'] : '';
- !empty($web_tpl_theme) && $web_tpl_theme = '/'.trim($web_tpl_theme, '/');
- $param['web_templets_dir'] = '/template'.$web_tpl_theme;
- $param['web_templeturl'] = $web_mainsite.$param['web_templets_dir'];
- $param['web_templets_pc'] = $web_mainsite.$param['web_templets_dir'].'/pc';
- $param['web_templets_m'] = $web_mainsite.$param['web_templets_dir'].'/mobile';
- $param['web_eyoucms'] = str_replace('#', '', '#h#t#t#p#:#/#/#w#w#w#.#e#y#o#u#c#m#s#.#c#o#m#');
-
-
- $inc_type = 'web';
- foreach ($param as $key => $val) {
- if (preg_match("/^".$inc_type."_(.)+/i", $key) !== 1) {
- $nowKey = strtolower($inc_type.'_'.$key);
- $param[$nowKey] = $val;
- }
- }
- tpCache($inc_type, $param, $lang, $options);
-
- }
- }
-
- if (!function_exists('write_html_cache'))
- {
-
-
- function write_html_cache($html = '', $result = []){
-
- $html_cache_status = config('HTML_CACHE_STATUS');
- $html_cache_arr = config('HTML_CACHE_ARR');
-
-
-
-
-
-
- if ($html_cache_status && !empty($html_cache_arr) && !empty($html)) {
-
-
-
-
- $home_lang = 'cn';
- $home_site = '';
- $city_switch_on = config('city_switch_on');
- if (!empty($city_switch_on)) {
- $home_site = get_home_site();
- } else {
- $home_lang = get_home_lang();
- }
-
- $request = \think\Request::instance();
- $param = input('param.');
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $uiset = input('param.uiset/s', 'off');
- $uiset = trim($uiset, '/');
- $url_screen_var = config('global.url_screen_var');
- $arcrank = !empty($result['arcrank']) ? intval($result['arcrank']) : 0;
- $admin_id = input('param.admin_id/d');
- if (isset($param[$url_screen_var]) || 'on' == $uiset || 'admin' == $request->module() || -1 == $arcrank || !empty($admin_id)) {
- return false;
- }
-
-
- $seo_pseudo = config('ey_config.seo_pseudo');
-
-
- if (2 == $seo_pseudo && !isMobile()) {
- return false;
- }
-
-
- if (1 == $seo_pseudo) {
-
-
- isset($param['tid']) && $param['tid'] = input('param.tid/d');
- } else {
- isset($param['tid']) && $param['tid'] = input('param.tid/s');
- }
-
- isset($param['page']) && $param['page'] = input('param.page/d');
-
-
- if (isset($param['aid'])) {
- if (!preg_match('/^([\w\-]+)$/', $param['aid'])) {
- to_index();
- }
- }
-
- $m_c_a_str = $request->module().'_'.$request->controller().'_'.$request->action();
- $m_c_a_str = strtolower($m_c_a_str);
-
-
-
-
-
-
-
-
- foreach($html_cache_arr as $mca=>$val)
- {
- $mca = strtolower($mca);
- if($mca != $m_c_a_str)
- continue;
-
-
-
-
-
-
-
-
-
-
-
-
-
- foreach ($param as $index=>$row){
- if(!in_array($index,$val['p'])){
- $val['p'][] = $index;
- }
- }
-
-
-
-
-
-
-
-
- if (empty($val['filename'])) {
- continue;
- }
-
-
-
- $cache_tag = '';
- $filename = '';
-
- if(isset($val['p']))
- {
- $tid = '';
- if (in_array('tid', $val['p'])) {
- $tid = !empty($param['tid']) ? $param['tid'] : '';
- if (strval(intval($tid)) != strval($tid)) {
- $where = [
- 'dirname' => $tid,
- ];
- if (empty($city_switch_on)) {
- $where['lang'] =$home_lang;
- }
- $tid = \think\Db::name('arctype')->where($where)->getField('id');
- $param['tid'] = $tid;
- }
- }
-
- foreach ($val['p'] as $k=>$v) {
- if (isset($param[$v])) {
- if (preg_match('/\/$/i', $filename)) {
- $filename .= $param[$v];
- } else {
- if (!empty($filename) || is_numeric($filename)) {
- $filename .= '_';
- }
- $filename .= $param[$v];
- }
- }
- }
- !empty($tid) && $cache_tag = $tid;
- !empty($param['aid']) && $cache_tag = $param['aid'];
- }
-
-
-
- empty($filename) && $filename = 'index';
-
-
- $is_mobile_domain = false;
- $web_mobile_domain = config('tpcache.web_mobile_domain');
- $goto = $request->param('goto');
- $goto = trim($goto, '/');
- $subDomain = $request->subDomain();
- if ('m' == $goto || (!empty($subDomain) && $subDomain == $web_mobile_domain)) {
- $is_mobile_domain = true;
- } else {
-
- if (3 == $seo_pseudo) {
- $pathinfo = $request->pathinfo();
- if (!empty($pathinfo)) {
- $s_arr = explode('/', $pathinfo);
- if ('m' == $s_arr[0]) {
- $is_mobile_domain = true;
- }
- }
- }
- }
-
-
-
-
- !empty($home_site) && $home_site = '_'.$home_site;
-
-
-
- $web_cmsmode = 1;
-
- if (1 == intval($web_cmsmode)) {
-
- $path = HTML_ROOT.$val['filename'].DS;
- $new_filename = TCP_SCHEME.'_'.$home_lang.$home_site;
- if (isMobile() || $is_mobile_domain) {
- $new_filename .= "_mobile";
- } else {
- $new_filename .= "_pc";
- }
- $new_filename .= '_'.$filename;
-
-
-
-
-
-
-
- $url = request()->url();
-
- $nurl = str_replace('/','_',$url);
- $domain = request()->domain();
- $domain = str_replace('https://','',$domain);
- $domain = str_replace('http://','',$domain);
- $ndomain = str_replace('.','_',$domain);
-
- $new_filename .= '_'.$ndomain.$nurl;
-
-
- $filename = preg_replace('/([^\w\-]+)/i', '', $new_filename);
- $filename = $path."{$filename}.html";
-
-
-
-
-
- tp_mkdir(dirname($filename));
- !empty($html) && file_put_contents($filename, $html);
- } else {
- $path = HTML_PATH.$val['filename'].DS.$home_lang.DS.trim($home_site, '_');
- if (isMobile()) {
- $path .= "_mobile";
- } else {
- $path .= "_pc";
- }
- $path .= '_cache'.DS;
- $web_htmlcache_expires_in = config('tpcache.web_htmlcache_expires_in');
- $options = array(
- 'path' => $path,
- 'expire'=> intval($web_htmlcache_expires_in),
- 'prefix' => $cache_tag,
- );
-
- }
- }
- }
- }
- }
-
- if (!function_exists('read_html_cache'))
- {
-
-
- function read_html_cache(){
- $html_cache_status = config('HTML_CACHE_STATUS');
- $html_cache_arr = config('HTML_CACHE_ARR');
- if ($html_cache_status && !empty($html_cache_arr)) {
-
- $home_lang = 'cn';
- $home_site = '';
- $city_switch_on = config('city_switch_on');
- if (!empty($city_switch_on)) {
- $home_site = get_home_site();
- } else {
- $home_lang = get_home_lang();
- }
-
- $request = \think\Request::instance();
- $seo_pseudo = config('ey_config.seo_pseudo');
- $param = input('param.');
-
-
- $url_screen_var = config('global.url_screen_var');
- if (isset($param[$url_screen_var])) {
- return false;
- }
-
-
- if (1 == $seo_pseudo) {
- isset($param['tid']) && $param['tid'] = input('param.tid/d');
- } else {
- isset($param['tid']) && $param['tid'] = input('param.tid/s');
- }
- isset($param['page']) && $param['page'] = input('param.page/d');
-
-
- if (isset($param['aid'])) {
- if (!preg_match('/^([\w\-]+)$/', $param['aid'])) {
- to_index();
- }
- }
-
- $m_c_a_str = $request->module().'_'.$request->controller().'_'.$request->action();
- $m_c_a_str = strtolower($m_c_a_str);
-
- foreach($html_cache_arr as $mca=>$val)
- {
- $mca = strtolower($mca);
- if($mca != $m_c_a_str)
- continue;
-
- if (empty($val['filename'])) {
- continue;
- }
-
-
- foreach ($param as $index=>$row){
- if(!in_array($index,$val['p'])){
- $val['p'][] = $index;
- }
- }
-
-
- $cache_tag = '';
- $filename = '';
-
- if(isset($val['p']))
- {
- $tid = '';
- if (in_array('tid', $val['p'])) {
- $tid = !empty($param['tid']) ? $param['tid'] : '';
- if (strval(intval($tid)) != strval($tid)) {
- $where = [
- 'dirname' => $tid,
- ];
- if (empty($city_switch_on)) {
- $where['lang'] =$home_lang;
- }
- $tid = \think\Db::name('arctype')->where($where)->getField('id');
- $param['tid'] = $tid;
- }
- }
-
- foreach ($val['p'] as $k=>$v) {
- if (isset($param[$v])) {
- if (preg_match('/\/$/i', $filename)) {
- $filename .= $param[$v];
- } else {
- if (!empty($filename) || is_numeric($filename)) {
- $filename .= '_';
- }
- $filename .= $param[$v];
- }
- }
- }
- !empty($tid) && $cache_tag = $tid;
- !empty($param['aid']) && $cache_tag = $param['aid'];
- }
- empty($filename) && $filename = 'index';
-
-
-
-
-
-
- $is_mobile_domain = false;
- $web_mobile_domain = config('tpcache.web_mobile_domain');
- $goto = $request->param('goto');
- $goto = trim($goto, '/');
- $subDomain = $request->subDomain();
- if ('m' == $goto || (!empty($subDomain) && $subDomain == $web_mobile_domain)) {
- $is_mobile_domain = true;
- } else {
- if (3 == $seo_pseudo) {
- $pathinfo = $request->pathinfo();
- if (!empty($pathinfo)) {
- $s_arr = explode('/', $pathinfo);
- if ('m' == $s_arr[0]) {
- $is_mobile_domain = true;
- }
- }
- }
- }
-
-
-
- !empty($home_site) && $home_site = '_'.$home_site;
-
-
- $web_cmsmode = 1;
-
- if (1 == intval($web_cmsmode)) {
- $path = HTML_ROOT.$val['filename'].DS;
- $new_filename = TCP_SCHEME.'_'.$home_lang.$home_site;
- if (isMobile() || $is_mobile_domain) {
- $new_filename .= "_mobile";
- } else {
- $new_filename .= "_pc";
- }
- $new_filename .= '_'.$filename;
-
-
-
-
-
-
- $url = request()->url();
-
- $nurl = str_replace('/','_',$url);
- $domain = request()->domain();
- $domain = str_replace('https://','',$domain);
- $domain = str_replace('http://','',$domain);
- $ndomain = str_replace('.','_',$domain);
-
- $new_filename .= '_'.$ndomain.$nurl;
-
-
- $filename = preg_replace('/([^\w\-]+)/i', '', $new_filename);
- $filename = $path."{$filename}.html";
-
-
-
- if(is_file($filename) && file_exists($filename))
- {
- echo file_get_contents($filename);
- exit();
- }
- } else {
- $path = HTML_PATH.$val['filename'].DS.$home_lang.DS.trim($home_site, '_');
- if (isMobile()) {
- $path .= "_mobile";
- } else {
- $path .= "_pc";
- }
- $path .= '_cache'.DS;
- $web_htmlcache_expires_in = config('tpcache.web_htmlcache_expires_in');
- $options = array(
- 'path' => $path,
- 'expire'=> intval($web_htmlcache_expires_in),
- 'prefix' => $cache_tag,
- );
- $html = html_cache($filename, '', $options);
-
- if($html)
- {
- echo $html;
- exit();
- }
- }
- }
- }
- }
- }
-
- if (!function_exists('is_local_images'))
- {
-
-
- function is_local_images($pic_url = '', $returnbool = false)
- {
- if (stristr($pic_url, '//'.request()->host().'/')) {
- $picPath = parse_url($pic_url, PHP_URL_PATH);
- $picPath = preg_replace('#^(/[/\w\-]+)?(/public/upload/|/public/static/|/uploads/|/weapp/)#i', '$2', $picPath);
- if (!empty($picPath) && file_exists('.'.$picPath)) {
- $pic_url = ROOT_DIR.$picPath;
- if (true == $returnbool) {
- return $pic_url;
- }
- }
- }
-
- if (true == $returnbool) {
- return false;
- } else {
- return $pic_url;
- }
- }
- }
-
- if (!function_exists('get_head_pic'))
- {
-
-
- function get_head_pic($pic_url = '', $is_admin = false, $sex = '保密')
- {
- if ($is_admin) {
- $default_pic = ROOT_DIR . '/public/static/admin/images/admint.png';
- } else {
- if ($sex == '女') {
- $default_pic = ROOT_DIR . '/public/static/common/images/dfgirl.png';
- } else {
- $default_pic = ROOT_DIR . '/public/static/common/images/dfboy.png';
- }
- }
-
- if (empty($pic_url)) {
- $pic_url = $default_pic;
- } else if (!is_http_url($pic_url)) {
- $pic_url = handle_subdir_pic($pic_url);
- } else if (is_http_url($pic_url)) {
- $pic_url = str_ireplace(['http://thirdqq.qlogo.cn','http://qzapp.qlogo.cn'], ['https://thirdqq.qlogo.cn','https://qzapp.qlogo.cn'], $pic_url);
- }
-
- return $pic_url;
- }
- }
- if (!function_exists('get_absolute_url'))
- {
-
-
- function get_absolute_url($str, $type = 'default',$is_absolute = false)
- {
- if (!is_http_url($str)) {
- static $absolute_path_open = null;
- if ($is_absolute){
- $absolute_path_open = true;
- }else{
- null === $absolute_path_open && $absolute_path_open = tpCache('web.absolute_path_open');
- }
- if (!empty($absolute_path_open)) {
- static $domain = null;
- if (null == $domain) {
- $domain = preg_replace('/^(([^\:]+):)?(\/\/)?([^\/\:]*)(.*)$/i', '${1}${3}${4}', request()->domain());
- }
- $root_dir = $domain.ROOT_DIR;
- switch ($type) {
- case 'html':
- $str = preg_replace('#(.*)(\#39;|"|"|\')(/[/\w\-]+)?(/public/upload/|/public/plugins|/public/static/|/uploads/)(.*)#iU', '$1$2'.$root_dir.'$4$5', $str);
- break;
- case 'url':
- $str = $domain.$str;
- break;
- default:
- if (preg_match('#^(/[/\w\-]+)?(/public/(upload|plugins|static)/|/uploads/|/weapp/)#i', $str)) {
- $str = preg_replace('#^(/[/\w\-]+)?(/public/(upload|plugins|static)/|/uploads/|/weapp/)#i', $root_dir.'$2', $str);
- } else {
- $str = $domain.$str;
- }
- break;
- }
- }
- }
-
- return $str;
- }
- }
- if (!function_exists('get_default_pic'))
- {
-
-
- function get_default_pic($pic_url = '', $domain = false)
- {
- if (is_http_url($pic_url)) {
- $pic_url = handle_subdir_pic($pic_url, 'img', $domain);
- }
-
- if (!is_http_url($pic_url)) {
- if (!$domain){
- static $absolute_path_open = null;
- null === $absolute_path_open && $absolute_path_open = tpCache('web.absolute_path_open');
- if ($absolute_path_open && request()->module() != 'admin'){
- $domain = true;
- }
- }
- if (true === $domain) {
- $domain = request()->domain();
- } else if (false === $domain) {
- $domain = '';
- }
-
- $pic_url = preg_replace('#^(/[/\w\-]+)?(/public/upload/|/public/static/|/uploads/|/weapp/)#i', '$2', $pic_url);
- $realpath = realpath(ROOT_PATH.trim($pic_url, '/'));
- if ( is_file($realpath) && file_exists($realpath) ) {
- $pic_url = $domain . ROOT_DIR . $pic_url;
- } else {
- $pic_url = $domain . ROOT_DIR . '/public/static/common/images/not_adv.jpg';
- }
- }
-
- return $pic_url;
- }
- }
-
- if (!function_exists('handle_subdir_pic'))
- {
-
-
- function handle_subdir_pic($str = '', $type = 'img', $domain = false, $clear_root_dir = false)
- {
- static $request = null;
- if (null === $request) {
- $request = \think\Request::instance();
- }
-
- $root_dir = $add_root_dir = ROOT_DIR;
- if ($clear_root_dir == true && $domain == false) {
- $add_root_dir = '';
- }else{
- static $absolute_path_open = null;
- null === $absolute_path_open && $absolute_path_open = tpCache('web.absolute_path_open');
- if ($absolute_path_open && $request->module() != 'admin'){
- $add_root_dir = $request->domain().$add_root_dir;
- $domain = false;
- }
- }
- switch ($type) {
- case 'img':
- if (!is_http_url($str) && !empty($str)) {
- $str = preg_replace('#^(/[/\w\-]+)?(/public/upload/|/public/static/|/uploads/|/weapp/)#i', $add_root_dir.'$2', $str);
- }else if (is_http_url($str) && !empty($str)) {
- $StrData = parse_url($str);
- if (empty($StrData['scheme']) && $request->host(true) != $StrData['host']) {
- $StrData['path'] = preg_replace('#^(/[/\w\-]+)?(/public/upload/|/uploads/|/public/static/)#i', '$2', $StrData['path']);
- if (preg_match('#^(/public/upload/|/public/static/|/uploads/|/weapp/)#i', $StrData['path']) && file_exists('.'.$StrData['path'])) {
-
- static $weappList = null;
- if (null == $weappList) {
- $weappList = \think\Db::name('weapp')->where([
- 'status' => 1,
- ])->cache(true, EYOUCMS_CACHE_TIME, 'weapp')
- ->getAllWithIndex('code');
- }
-
- if (!empty($weappList['Qiniuyun']) && 1 == $weappList['Qiniuyun']['status']) {
- $qnyData = json_decode($weappList['Qiniuyun']['data'], true);
- $weappConfig = json_decode($weappList['Qiniuyun']['config'], true);
- if (!empty($weappConfig['version']) && 'v1.0.6' <= $weappConfig['version']) {
- $qiniuyunModel = new \weapp\Qiniuyun\model\QiniuyunModel;
- $str = $qiniuyunModel->handle_subdir_pic($qnyData, $StrData, $str);
- } else {
- if ($qnyData['domain'] == $StrData['host']) {
- $tcp = !empty($qnyData['tcp']) ? $qnyData['tcp'] : '';
- switch ($tcp) {
- case '2':
- $tcp = 'https://';
- break;
-
- case '3':
- $tcp = '//';
- break;
-
- case '1':
- default:
- $tcp = 'http://';
- break;
- }
- $str = $tcp.$qnyData['domain'].$StrData['path'];
- }else{
-
- $str = $add_root_dir.$StrData['path'];
- }
- }
- }
- else if (!empty($weappList['AliyunOss']) && 1 == $weappList['AliyunOss']['status']) {
- $ossData = json_decode($weappList['AliyunOss']['data'], true);
- $aliyunOssModel = new \weapp\AliyunOss\model\AliyunOssModel;
- $str = $aliyunOssModel->handle_subdir_pic($ossData, $StrData, $str);
- }
- else if (!empty($weappList['Cos']) && 1 == $weappList['Cos']['status']) {
- $cosData = json_decode($weappList['Cos']['data'], true);
- $cosModel = new \weapp\Cos\model\CosModel;
- $str = $cosModel->handle_subdir_pic($cosData, $StrData, $str);
- }
- else {
-
- $str = $add_root_dir.$StrData['path'];
- }
- } else {
- $str = preg_replace('/^\/\//i', $request->scheme().'://', $str);
- }
- }
- }
- break;
-
- case 'html':
- preg_match_all('/(\<\;|\<)img.*(\/)?(\>|\>\;)/iUs', $str, $imginfo);
- $imgArr = empty($imginfo[0]) ? [] : $imginfo[0];
- if (!empty($imgArr)) {
- foreach ($imgArr as $key => $value) {
- preg_match_all("#src=('|\")(.*)('|\")#isU", $value, $img_val);
- if (isset($img_val[2][0]) && !is_http_url($img_val[2][0])) {
- $handle_img = preg_replace('#(/[/\w\-]+)?(/public/upload/|/public/static/|/uploads/|/weapp/)#i', $add_root_dir.'$2', $value);
- $str = str_ireplace($value, $handle_img, $str);
- }
- }
- }
-
-
- break;
-
- case 'soft':
- if (!is_http_url($str) && !empty($str)) {
- $str = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i', $add_root_dir.'$2', $str);
- } else if (is_http_url($str) && !empty($str)) {
- $StrData = parse_url($str);
- $StrData['path'] = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i', '$2', $StrData['path']);
- if ($request->host(true) != $StrData['host'] && preg_match('#^(/public/upload/soft/|/uploads/soft/)#i', $StrData['path'])) {
-
- static $weappList = null;
- if (null == $weappList) {
- $weappList = \think\Db::name('weapp')->where([
- 'status' => 1,
- ])->cache(true, EYOUCMS_CACHE_TIME, 'weapp')
- ->getAllWithIndex('code');
- }
-
- if (!empty($weappList['Qiniuyun']) && 1 == $weappList['Qiniuyun']['status']) {
- $qnyData = json_decode($weappList['Qiniuyun']['data'], true);
- $weappConfig = json_decode($weappList['Qiniuyun']['config'], true);
- if (!empty($weappConfig['version']) && 'v1.0.6' <= $weappConfig['version']) {
- $qiniuyunModel = new \weapp\Qiniuyun\model\QiniuyunModel;
- $str = $qiniuyunModel->handle_subdir_pic($qnyData, $StrData, $str);
- } else {
- if ($qnyData['domain'] == $StrData['host']) {
- $tcp = !empty($qnyData['tcp']) ? $qnyData['tcp'] : '';
- switch ($tcp) {
- case '2':
- $tcp = 'https://';
- break;
-
- case '3':
- $tcp = '//';
- break;
-
- case '1':
- default:
- $tcp = 'http://';
- break;
- }
- $str = $tcp.$qnyData['domain'].$StrData['path'];
- }else{
-
- if (file_exists('.'.$StrData['path'])) {
- $str = $add_root_dir.$StrData['path'];
- }
- }
- }
- }
- else if (!empty($weappList['AliyunOss']) && 1 == $weappList['AliyunOss']['status']) {
- $ossData = json_decode($weappList['AliyunOss']['data'], true);
- $aliyunOssModel = new \weapp\AliyunOss\model\AliyunOssModel;
- $str = $aliyunOssModel->handle_subdir_pic($ossData, $StrData, $str);
- }
- else if (!empty($weappList['Cos']) && 1 == $weappList['Cos']['status']) {
- $cosData = json_decode($weappList['Cos']['data'], true);
- $cosModel = new \weapp\Cos\model\CosModel;
- $str = $cosModel->handle_subdir_pic($cosData, $StrData, $str);
- }
- }
- }
- break;
-
- case 'media':
- if (!is_http_url($str) && !empty($str)) {
- $str = preg_replace('#^(/[/\w\-]+)?(/uploads/media/)#i', $add_root_dir.'$2', $str);
- }
- break;
-
- default:
-
- break;
- }
-
- if (!empty($str) && !is_http_url($str)) {
- if (false !== $domain) {
- if (true === $domain) {
- static $domain_new = null;
- if (null === $domain_new) {
- $domain_new = $request->domain();
- }
- $domain = $domain_new;
- }
- $str = $domain.$str;
- }
- }
-
- return $str;
- }
- }
-
-
- if ( ! function_exists('get_arcrank_list'))
- {
- function get_arcrank_list()
- {
- $result = \think\Db::name('arcrank')->where([
- 'lang' => get_admin_lang(),
- ])
- ->order('id asc')
- ->cache(true, EYOUCMS_CACHE_TIME, "arcrank")
- ->getAllWithIndex('rank');
-
-
- $LevelData = \think\Db::name('users_level')->field('level_name as `name`, level_value as `rank`')->order('level_value asc, level_id asc')->cache(true, EYOUCMS_CACHE_TIME, "users_level")->select();
- if (!empty($LevelData)) {
- $result = array_merge($result, $LevelData);
- }
- return $result;
- }
- }
-
- if (!function_exists('thumb_img'))
- {
-
-
- function thumb_img($original_img = '', $width = '', $height = '', $thumb_mode = '')
- {
-
- static $thumbConfig = null;
- if (null === $thumbConfig) {
- @ini_set('memory_limit', '-1');
- $thumbConfig = tpCache('thumb');
- }
- $thumbextra = config('global.thumb');
-
- if (!empty($width) || !empty($height) || !empty($thumb_mode)) {
-
- } else {
- if (empty($thumbConfig['thumb_open'])) {
- return $original_img;
- }
- }
-
-
- $original_img = is_local_images($original_img);
-
- if (is_http_url($original_img)) {
- return $original_img;
- } else if (empty($original_img)) {
- return ROOT_DIR.'/public/static/common/images/not_adv.jpg';
- }
-
-
- $filename = '';
- $imgArr = explode('/', $original_img);
- $imgArr = end($imgArr);
- $filename = preg_replace("/\.([^\.]+)$/i", "", $imgArr);
- $file_ext = preg_replace("/^(.*)\.([^\.]+)$/i", "$2", $imgArr);
-
-
- if (preg_match('/\/uploads\/thumb\/\d{1,}_\d{1,}\//i', $original_img)) {
- $pattern = UPLOAD_PATH.'allimg/*/'.$filename;
- if (in_array(strtolower($file_ext), ['jpg','jpeg'])) {
- $pattern .= '.jp*g';
- } else {
- $pattern .= '.'.$file_ext;
- }
- $original_img_tmp = glob($pattern);
- if (!empty($original_img_tmp)) {
- $original_img = '/'.current($original_img_tmp);
- }
- } else {
- if ('bmp' == $file_ext && version_compare(PHP_VERSION,'7.2.0','<')) {
- return $original_img;
- }
- }
-
-
-
- $original_img1 = preg_replace('#^'.ROOT_DIR.'#i', '', handle_subdir_pic($original_img, 'img',false,true));
-
- $original_img1 = '.' . $original_img1;
-
- $info = @getimagesize($original_img1);
-
-
- if (false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))) {
- return $original_img;
- } else {
- if (!empty($info['mime']) && stristr($info['mime'], 'bmp') && version_compare(PHP_VERSION,'7.2.0','<')) {
- return $original_img;
- }
- }
-
-
- $is_auto_mode = 0;
- if (empty($width)) {
- if (is_numeric($thumbConfig['thumb_width']) && 0 == $thumbConfig['thumb_width']) {
- $width = !empty($info[0]) ? $info[0] : 1000000;
- $is_auto_mode = 1;
- } else {
- $width = !empty($thumbConfig['thumb_width']) ? $thumbConfig['thumb_width'] : $thumbextra['width'];
- }
- }
- if (empty($height)) {
- if (is_numeric($thumbConfig['thumb_height']) && 0 == $thumbConfig['thumb_height']) {
- $height = !empty($info[0]) ? $info[0] : 1000000;
- $is_auto_mode = 1;
- } else {
- $height = !empty($thumbConfig['thumb_height']) ? $thumbConfig['thumb_height'] : $thumbextra['height'];
- }
- }
- $width = intval($width);
- $height = intval($height);
-
-
- $path = UPLOAD_PATH."thumb/{$width}_{$height}/";
- $img_thumb_name = "{$filename}";
-
-
- if (is_file($path . $img_thumb_name . '.jpg')) return get_absolute_url(ROOT_DIR.'/' . $path . $img_thumb_name . '.jpg');
- if (is_file($path . $img_thumb_name . '.jpeg')) return get_absolute_url(ROOT_DIR.'/' . $path . $img_thumb_name . '.jpeg');
- if (is_file($path . $img_thumb_name . '.gif')) return get_absolute_url(ROOT_DIR.'/' . $path . $img_thumb_name . '.gif');
- if (is_file($path . $img_thumb_name . '.png')) return get_absolute_url(ROOT_DIR.'/' . $path . $img_thumb_name . '.png');
- if (is_file($path . $img_thumb_name . '.bmp')) return get_absolute_url(ROOT_DIR.'/' . $path . $img_thumb_name . '.bmp');
- if (is_file($path . $img_thumb_name . '.webp')) return get_absolute_url(ROOT_DIR.'/' . $path . $img_thumb_name . '.webp');
-
- if (!is_file($original_img1)) {
- return get_absolute_url(ROOT_DIR.'/public/static/common/images/not_adv.jpg');
- }
-
- try {
- vendor('topthink.think-image.src.Image');
- vendor('topthink.think-image.src.image.Exception');
- if(stristr($original_img1,'.gif'))
- {
- vendor('topthink.think-image.src.image.gif.Encoder');
- vendor('topthink.think-image.src.image.gif.Decoder');
- vendor('topthink.think-image.src.image.gif.Gif');
- }
- $image = \think\Image::open($original_img1);
-
- $img_thumb_name = $img_thumb_name . '.' . $image->type();
-
- !is_dir($path) && mkdir($path, 0777, true);
-
- $thumb_color = !empty($thumbConfig['thumb_color']) ? $thumbConfig['thumb_color'] : $thumbextra['color'];
-
- if (!empty($thumb_mode)) {
- $thumb_mode = intval($thumb_mode);
- } else {
- $thumb_mode = !empty($thumbConfig['thumb_mode']) ? $thumbConfig['thumb_mode'] : $thumbextra['mode'];
- }
-
- if (1 == $is_auto_mode) {
- $thumb_mode = 1;
- } else {
- 1 == $thumb_mode && $thumb_mode = 6;
- 2 == $thumb_mode && $thumb_mode = 2;
- if (3 == $thumb_mode) {
- $img_width = $image->width();
- $img_height = $image->height();
- if ($width < $img_width && $height < $img_height) {
-
- $min_width = ($img_width < $img_height) ? $img_width : 0;
- $min_height = ($img_width > $img_height) ? $img_height : 0;
- if ($min_width > $width || $min_height > $height) {
- if (0 < intval($min_width)) {
- $scale = $min_width / min($width, $height);
- } else if (0 < intval($min_height)) {
- $scale = $min_height / $height;
- } else {
- $scale = $min_width / $width;
- }
- $s_width = $img_width / $scale;
- $s_height = $img_height / $scale;
- $image->thumb($s_width, $s_height, 1, $thumb_color)->save($path . $img_thumb_name, NULL, 100);
- }
- }
- $thumb_mode = 3;
- }
- }
-
- $image->thumb($width, $height, $thumb_mode, $thumb_color)->save($path . $img_thumb_name, NULL, 100);
-
- $water = tpCache('water');
- if($water['is_mark']==1 && $water['is_thumb_mark'] == 1 && $image->width()>$water['mark_width'] && $image->height()>$water['mark_height']){
- $imgresource = './' . $path . $img_thumb_name;
- if($water['mark_type'] == 'text'){
-
- $ttf = ROOT_PATH.'public/static/common/font/hgzb.ttf';
- if (file_exists($ttf)) {
- $size = $water['mark_txt_size'] ? $water['mark_txt_size'] : 30;
- $color = $water['mark_txt_color'] ?: '#000000';
- if (!preg_match('/^#[0-9a-fA-F]{6}$/', $color)) {
- $color = '#000000';
- }
- $transparency = intval((100 - $water['mark_degree']) * (127/100));
- $color .= dechex($transparency);
- $image->open($imgresource)->text($water['mark_txt'], $ttf, $size, $color, $water['mark_sel'])->save($imgresource);
- $return_data['mark_txt'] = $water['mark_txt'];
- }
- }else{
-
- $water['mark_img'] = preg_replace('#^(/[/\w\-]+)?(/public/upload/|/uploads/)#i', '$2', $water['mark_img']);
-
-
- $waterPath = "." . $water['mark_img'];
- if (eyPreventShell($waterPath) && file_exists($waterPath)) {
- $quality = $water['mark_quality'] ? $water['mark_quality'] : 80;
- $waterTempPath = dirname($waterPath).'/temp_'.basename($waterPath);
- $image->open($waterPath)->save($waterTempPath, null, $quality);
- $image->open($imgresource)->water($waterTempPath, $water['mark_sel'], $water['mark_degree'])->save($imgresource);
- @unlink($waterTempPath);
- }
- }
- }
- $img_url = ROOT_DIR.'/' . $path . $img_thumb_name;
- $img_url = get_absolute_url($img_url);
-
- return $img_url;
-
- } catch (think\Exception $e) {
-
- return $original_img;
- }
- }
- }
-
- if (!function_exists('get_controller_byct')) {
-
-
- function get_controller_byct($current_channel)
- {
- $channeltype_info = model('Channeltype')->getInfo($current_channel);
- return $channeltype_info['ctl_name'];
- }
- }
-
- if (!function_exists('ui_read_bidden_inc')) {
-
-
- function ui_read_bidden_inc($filename)
- {
- $data = false;
- if (file_exists($filename)) {
- $data = @file($filename);
- $data = json_decode($data[1], true);
- }
-
- if (empty($data)) {
-
- $params = explode('/', $filename);
- $page = $params[count($params) - 1];
- $pagearr = explode('.', $page);
- reset($pagearr);
- $page = current($pagearr);
- $map = array(
- 'page' => $page,
- 'theme_style' => THEME_STYLE_PATH,
- );
- $result = M('ui_config')->where($map)->cache(true,EYOUCMS_CACHE_TIME,"ui_config")->select();
- if ($result) {
- $dataArr = array();
- foreach ($result as $key => $val) {
- $k = "{$val['lang']}_{$val['type']}_{$val['name']}";
- $dataArr[$k] = $val['value'];
- }
- $data = $dataArr;
- } else {
- $data = false;
- }
-
-
- if (!empty($data)) {
-
- tp_mkdir(dirname($filename));
- $nowData = $data;
- $setting = "<?php die('forbidden'); ?>\n";
- $setting .= json_encode($nowData);
- $setting = str_replace("\/", "/",$setting);
- $incFile = fopen($filename, "w+");
- if ($incFile != false && fwrite($incFile, $setting)) {
- fclose($incFile);
- }
-
- }
- }
-
- return $data;
- }
- }
-
- if (!function_exists('ui_write_bidden_inc')) {
-
-
- function ui_write_bidden_inc($data, $filename, $is_append = false)
- {
- $data2 = $data;
- if (!empty($filename)) {
-
-
- reset($data2);
- $value = current($data2);
- $tmp_val = json_decode($value, true);
- $name = $tmp_val['id'];
- $type = $tmp_val['type'];
- $page = $tmp_val['page'];
- $lang = !empty($tmp_val['lang']) ? $tmp_val['lang'] : cookie(config('global.home_lang'));
- $idcode = $tmp_val['idcode'];
- if (empty($lang)) {
- $lang = model('language')->order('id asc')
- ->limit(1)
- ->cache(true, EYOUCMS_CACHE_TIME, 'language')
- ->getField('mark');
- }
- $theme_style = THEME_STYLE_PATH;
- $md5key = md5($name.$page.$theme_style.$lang);
- $savedata = array(
- 'md5key' => $md5key,
- 'theme_style' => $theme_style,
- 'page' => $page,
- 'type' => $type,
- 'name' => $name,
- 'value' => $value,
- 'lang' => $lang,
- 'idcode'=> $idcode,
- );
- $map = array(
- 'name' => $name,
- 'page' => $page,
- 'theme_style' => $theme_style,
- 'lang' => $lang,
- );
- $count = M('ui_config')->where($map)->count('id');
- if ($count > 0) {
- $savedata['update_time'] = getTime();
- $r = M('ui_config')->where($map)->cache(true,EYOUCMS_CACHE_TIME,'ui_config')->update($savedata);
- } else {
- $savedata['add_time'] = getTime();
- $savedata['update_time'] = getTime();
- $r = M('ui_config')->insert($savedata);
- \think\Cache::clear('ui_config');
- }
-
- if ($r) {
-
-
- tp_mkdir(dirname($filename));
-
-
- if ($is_append) {
- $inc = ui_read_bidden_inc($filename);
- if ($inc) {
- $oldarr = (array)$inc;
- $data = array_merge($oldarr, $data);
- }
- }
-
- $setting = "<?php die('forbidden'); ?>\n";
- $setting .= json_encode($data);
- $setting = str_replace("\/", "/",$setting);
- $incFile = fopen($filename, "w+");
- if ($incFile != false && fwrite($incFile, $setting)) {
- fclose($incFile);
- }
-
-
- return true;
- }
- }
-
- return false;
- }
- }
-
- if (!function_exists('get_ui_inc_params')) {
-
-
- function get_ui_inc_params($page)
- {
- $e_page = $page;
- $filename = RUNTIME_PATH.'ui/'.THEME_STYLE_PATH.'/'.$e_page.'.inc.php';
- $inc = ui_read_bidden_inc($filename);
-
- return $inc;
- }
- }
-
- if (!function_exists('allow_release_arctype'))
- {
-
-
- function allow_release_arctype($selected = 0, $allow_release_channel = array(), $selectform = true, $release_typeids = [],$users_release = false,$catid = 0)
- {
-
- $release_typeids_pre = [];
- if ($users_release){
- $release_typeids_pre = $release_typeids;
- $topids = Db::name('arctype')->where([
- 'id' => ['IN', $release_typeids],
- 'topid' => ['gt', 0],
- 'lang' => get_current_lang(),
- ])->column('topid');
- $topid_arr = Db::name('arctype')->where([
- 'topid|id' => ['IN', $topids],
- 'lang' => get_current_lang(),
- ])->column('id');
- $release_typeids = array_merge($release_typeids,$topid_arr);
- }
- $where = [];
-
- $where['c.weapp_code'] = '';
- $where['c.lang'] = get_current_lang();
- $where['c.is_del'] = 0;
- $current_channel = [51];
- $php_servicemeal = tpCache('php.php_servicemeal');
- if (1.5 > $php_servicemeal) {
- array_push($current_channel, 5);
- }
- $current_channel_str = implode(',', $current_channel);
- $where['c.current_channel'] = ['notin', $current_channel];
-
-
- $admin_info = session('admin_info');
- if (0 < intval($admin_info['role_id'])) {
- $auth_role_info = $admin_info['auth_role_info'];
- if(! empty($auth_role_info)){
- if(! empty($auth_role_info['permission']['arctype'])){
- $where['c.id'] = array('IN', $auth_role_info['permission']['arctype']);
- }
- }
- }
-
-
-
- if (!empty($release_typeids)) $where['c.id'] = ['IN', $release_typeids];
-
-
- if (!is_array($selected)) $selected = [$selected];
-
- $cacheKey = md5(json_encode($selected).json_encode($allow_release_channel).$selectform.json_encode($where));
- $select_html = cache($cacheKey);
- if (empty($select_html) || false == $selectform) {
-
- $allow_release_channel = !empty($allow_release_channel) ? $allow_release_channel : config('global.allow_release_channel');
-
-
- $where['c.status'] = 1;
- $fields = "c.id, c.parent_id, c.current_channel, c.typename, c.grade, '' as children";
-
-
- if((int)$catid > 0){
- $where1 = [
- 'c.area_id' => (int)$catid,
- 'c.is_del' => 0,
- ];
- $res = $res2 = \think\Db::name('arctype')
- ->field($fields)
- ->alias('c')
- ->where($where)
- ->where('c.topid','<>',38)
- ->whereOr(function($query) use ($where1){
- $query->where($where1);
- })
- ->order('c.parent_id asc, c.sort_order asc, c.id asc')
-
- ->select();
- }else{
- $res = $res2 = \think\Db::name('arctype')
- ->field($fields)
- ->alias('c')
- ->where($where)
- ->order('c.parent_id asc, c.sort_order asc, c.id asc')
- ->cache(true,EYOUCMS_CACHE_TIME,"arctype")
- ->select();
- }
-
- if (empty($res)) {
- return '';
- }
-
-
- $arctypeSublist = [];
- foreach ($res as $key => $val) {
- if (!empty($val['parent_id'])) {
- $arctypeSublist[$val['parent_id']][] = $val['id'];
- }
- }
-
- $grade_arr = [];
- $i = 0;
- foreach ($res as $key=>$val) {
- $res[$key]['has_children'] = $res2[$key]['has_children'] = !empty($arctypeSublist[$val['id']]) ? count($arctypeSublist[$val['id']]) : 0;
- $grade_arr[] = $val['grade'];
- $res2[$key]['new_sort_order'] = $i++;
- }
- $max_grade = max($grade_arr);
- array_multisort($grade_arr, SORT_DESC, SORT_NUMERIC, $res2);
-
- $res3 = $new_sort_order_arr = [];
- foreach ($res2 as $key=>$val) {
- $res3[$val['id']] = $val;
- $new_sort_order_arr[$val['id']] = $val['new_sort_order'];
- }
-
-
- for ($i=0; $i <= $max_grade; $i++) {
- foreach ($res3 as $key => $val) {
- if (!in_array($val['current_channel'], $allow_release_channel)) {
- $tmp_val = $res3[$key];
- if ( $tmp_val['has_children'] <= 0 ) {
- unset($res3[$key]);
- unset($new_sort_order_arr[$key]);
- if (!empty($tmp_val['parent_id'])) {
- if (!empty($res3[$tmp_val['parent_id']]['has_children'])) {
- $res3[$tmp_val['parent_id']]['has_children'] -= 1;
- }
- }
- }
- }
- }
- }
-
-
- if ($users_release){
- duplicate_removal($res3,$new_sort_order_arr,$release_typeids_pre);
- if (empty($res3)){
- return '';
- }
- }
-
- array_multisort($new_sort_order_arr, SORT_ASC, SORT_NUMERIC, $res3);
-
- $arr = group_same_key($res3, 'parent_id');
- for ($i=0; $i <= $max_grade; $i++) {
- foreach ($arr as $key => $val) {
- foreach ($arr[$key] as $key2 => $val2) {
- if (!isset($arr[$val2['id']])) {
- $arr[$key][$key2]['has_children'] = 0;
- continue;
- }
- $val2['children'] = $arr[$val2['id']];
- $arr[$key][$key2] = $val2;
- }
- }
- }
-
-
- $nowArr = $arr[0];
-
-
- $select_html = '';
- if (false == $selectform) {
- $select_html = $nowArr;
- } else if (true == $selectform) {
-
- handle_arctype_data($select_html, $nowArr, $selected, $allow_release_channel,$release_typeids_pre);
- cache($cacheKey, $select_html, null, 'arctype');
- }
- }
-
- return $select_html;
- }
- }
- if (!function_exists('duplicate_removal'))
- {
-
- function duplicate_removal(&$data_arr = [],&$new_sort_order_arr = [],$ids = []){
- $circulate = false;
- foreach ($data_arr as $k => $v){
- if (0 == $v['has_children'] && !in_array($v['id'],$ids)){
- $circulate = true;
- if (!empty($data_arr[$v['parent_id']])){
- $data_arr[$v['parent_id']]['has_children'] -= 1;
- }
- unset($data_arr[$k]);
- unset($new_sort_order_arr[$k]);
- }
- }
- if ($circulate){
- duplicate_removal($data_arr,$new_sort_order_arr,$ids);
- }
-
- }
- }
- if (!function_exists('handle_arctype_data'))
- {
-
- function handle_arctype_data(&$select_html = '', $nowArr = [], $selected = 0, $allow_release_channel = [],$release_typeids_pre = [])
- {
- foreach ($nowArr AS $key => $val)
- {
-
- if (!empty($release_typeids_pre) && !in_array($val['id'], $release_typeids_pre) && $val['has_children'] == 0){
- continue;
- }
- $select_html .= '<option value="' . $val['id'] . '" data-grade="' . $val['grade'] . '" data-current_channel="' . $val['current_channel'] . '"';
- $select_html .= (in_array($val['id'], $selected)) ? ' selected="true"' : '';
- if ((!empty($allow_release_channel) && !in_array($val['current_channel'], $allow_release_channel)) || (!empty($release_typeids_pre) && !in_array($val['id'], $release_typeids_pre) ) ) {
- $select_html .= ' disabled="true" style="background-color:#f5f5f5;"';
- }
- $select_html .= '>';
- if ($val['grade'] > 0)
- {
- $select_html .= str_repeat(' ', $val['grade'] * 4);
- }
- $select_html .= htmlspecialchars_decode($val['typename']) . '</option>';
-
- if (empty($val['children'])) {
- continue;
- }
- handle_arctype_data($select_html, $val['children'], $selected, $allow_release_channel,$release_typeids_pre);
- }
- }
- }
-
- if (!function_exists('every_top_dirname_list'))
- {
-
-
- function every_top_dirname_list() {
- $arctypeModel = new \app\common\model\Arctype();
- $result = $arctypeModel->getEveryTopDirnameList();
-
- return $result;
- }
- }
-
- if (!function_exists('getalltype')){
-
-
- function getalltype($typeid, $field = '')
- {
- $parent_list = model('Arctype')->getAllPid($typeid);
-
- if (!empty($field)){
- $parent_list = get_arr_column($parent_list,$field);
- }
- return $parent_list;
- }
- }
-
- if (!function_exists('gettoptype'))
- {
-
-
- function gettoptype($typeid, $field = 'typename')
- {
- $parent_list = model('Arctype')->getAllPid($typeid);
- $result = current($parent_list);
- if (isset($result[$field]) && !empty($result[$field])) {
- return handle_subdir_pic($result[$field]);
- } else {
- return '';
- }
- }
- }
-
- if (!function_exists('getparenttype'))
- {
-
-
- function getparenttype($typeid, $field = 'typename')
- {
- $parent_list = model('Arctype')->getAllPid($typeid);
- if (!empty($parent_list)) {
- array_pop($parent_list);
- }
- $result = end($parent_list);
- if (isset($result[$field]) && !empty($result[$field])) {
- return handle_subdir_pic($result[$field]);
- } else {
- return '';
- }
- }
- }
-
- if (!function_exists('get_main_lang'))
- {
-
-
- function get_main_lang($is_force = false)
- {
- static $main_lang = null;
- if (null === $main_lang || $is_force) {
- $keys = 'common_get_main_lang';
- $main_lang = \think\Cache::get($keys);
- if ($is_force || empty($main_lang) || (!empty($main_lang) && !preg_match('/^[a-z]{2}$/i', $main_lang))) {
- $main_lang = \think\Db::name('language')->order('id asc')
- ->limit(1)
- ->cache(true, EYOUCMS_CACHE_TIME, 'language')
- ->getField('mark');
- \think\Cache::set($keys, $main_lang);
- }
- $main_lang = preg_replace('/([^a-z])/i', '', $main_lang);
- }
-
- return $main_lang;
- }
- }
-
- if (!function_exists('get_default_lang'))
- {
-
-
- function get_default_lang($is_force = false)
- {
- static $default_lang = null;
- if (null === $default_lang || $is_force) {
- $request = \think\Request::instance();
- if (!stristr($request->baseFile(), 'index.php')) {
- $default_lang = get_admin_lang($is_force);
- } else {
- $default_lang = \think\Config::get('ey_config.system_home_default_lang');
- }
- }
-
- return $default_lang;
- }
- }
-
- if (!function_exists('get_current_lang'))
- {
-
-
- function get_current_lang($is_force = false)
- {
- static $current_lang = null;
- if (null === $current_lang || $is_force) {
- $request = \think\Request::instance();
- if (!stristr($request->baseFile(), 'index.php')) {
- $current_lang = get_admin_lang($is_force);
- } else {
- $current_lang = get_home_lang($is_force);
- }
- }
-
- return $current_lang;
- }
- }
-
- if (!function_exists('get_admin_lang'))
- {
-
-
- function get_admin_lang($is_force = false)
- {
- static $admin_lang = null;
- if (null === $admin_lang || $is_force) {
- $keys = \think\Config::get('global.admin_lang');
- $admin_lang = \think\Cookie::get($keys);
- $admin_lang = addslashes($admin_lang);
- if ($is_force || empty($admin_lang) || (!empty($admin_lang) && !preg_match('/^[a-z]{2}$/i', $admin_lang))) {
- $admin_lang = input('param.lang/s');
- empty($admin_lang) && $admin_lang = get_main_lang($is_force);
- \think\Cookie::set($keys, $admin_lang);
- }
- $admin_lang = preg_replace('/([^a-z])/i', '', $admin_lang);
- }
-
- return $admin_lang;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
- if (!function_exists('get_home_lang'))
- {
-
-
- function get_home_lang($is_force = false)
- {
- static $home_lang = null;
- if (null === $home_lang || $is_force) {
- $keys = \think\Config::get('global.home_lang');
- $home_lang = input('param.lang/s');
- if ($is_force || empty($home_lang)){
- $home_lang = \think\Cookie::get($keys);
- $home_lang = addslashes($home_lang);
- if ($is_force || empty($home_lang) || (!empty($home_lang) && !preg_match('/^[a-z]{2}$/i', $home_lang))) {
- if ($is_force || empty($home_lang)) {
- $home_lang = \think\Db::name('language')->where([
- 'is_home_default' => 1,
- ])->getField('mark');
- }
- }
- }
- $home_lang = preg_replace('/([^a-z])/i', '', $home_lang);
- \think\Cookie::set($keys, $home_lang);
-
- }
-
- return $home_lang;
- }
- }
-
- if (!function_exists('is_language'))
- {
-
-
- function is_language()
- {
- static $value = null;
- if (null === $value) {
- $module = \think\Request::instance()->module();
- if (empty($module)) {
- $system_langnum = tpCache('system.system_langnum');
- } else {
- $system_langnum = config('ey_config.system_langnum');
- }
-
- if (1 < intval($system_langnum)) {
- $value = $system_langnum;
- } else {
- $value = false;
- }
- }
-
- return $value;
- }
- }
-
- if (!function_exists('switch_language'))
- {
-
-
- function switch_language()
- {
- static $execute_end = false;
- if (true === $execute_end) {
- return true;
- }
-
- static $request = null;
- if (null == $request) {
- $request = \think\Request::instance();
- }
-
- $pathinfo = $request->pathinfo();
-
- $var_lang = $request->param('lang/s');
- $var_lang = trim($var_lang, '/');
- if (!empty($var_lang)) {
- if (!preg_match('/^([a-z]+)$/i', $var_lang)) {
- to_index();
- }
- }
-
-
- $lang_switch_on = config('lang_switch_on');
- if (!$lang_switch_on) {
- return true;
- }
-
- static $language_db = null;
- if (null == $language_db) {
- $language_db = \think\Db::name('language');
- }
-
- $is_admin = false;
- if (!stristr($request->baseFile(), 'index.php')) {
- $is_admin = true;
- $langCookieVar = \think\Config::get('global.admin_lang');
- } else {
- $langCookieVar = \think\Config::get('global.home_lang');
- }
- \think\Lang::setLangCookieVar($langCookieVar);
-
-
- $langRow = $language_db->field('title,mark,is_home_default')
- ->order('id asc')
- ->cache(true, EYOUCMS_CACHE_TIME, 'language')
- ->select();
- if (1 >= count($langRow)) {
- $langRow = current($langRow);
- $lang = $langRow['mark'];
- \think\Config::set('cache.path', CACHE_PATH.$lang.DS);
- \think\Cookie::set($langCookieVar, $lang);
- cookie('site_info', null);
- return true;
- }
-
-
- $current_lang = '';
-
- if (!empty($pathinfo)) {
- $s_arr = explode('/', $pathinfo);
- if ('m' == $s_arr[0]) {
- $s_arr[0] = $s_arr[1];
- }
- $count = $language_db->where(['mark'=>$s_arr[0]])->cache(true, EYOUCMS_CACHE_TIME, 'language')->count();
- if (!empty($count)) {
- $current_lang = $s_arr[0];
- }
- }
-
-
-
- if (empty($current_lang)) {
- if ($is_admin) {
- $current_lang = !empty($langRow[0]['mark']) ? $langRow[0]['mark'] : 'cn';
- } else {
- foreach ($langRow as $key => $val) {
- if (1 == $val['is_home_default']) {
- $current_lang = $val['mark'];
- break;
- }
- }
- empty($current_lang) && $current_lang = !empty($langRow[0]['mark']) ? $langRow[0]['mark'] : 'cn';
- }
- }
-
-
- $lang = $request->param('lang/s', $current_lang);
- $lang = trim($lang, '/');
- if (!empty($lang)) {
-
- $lang = $language_db->where('mark',$lang)->cache(true, EYOUCMS_CACHE_TIME, 'language')->getField('mark');
- }
- if (empty($lang)) {
- if ($is_admin) {
- $lang = !empty($langRow[0]['mark']) ? $langRow[0]['mark'] : 'cn';
-
- } else {
- to_index();
- }
- }
- $lang_info = [];
- foreach ($langRow as $key => $val) {
- if ($val['mark'] == $lang) {
- $lang_info['lang_title'] = $val['title'];
-
- $inletStr = (1 == config('ey_config.seo_inlet')) ? '' : '/index.php';
- $url = $val['url'];
- if (empty($url)) {
- if (1 == $val['is_home_default']) {
- $url = ROOT_DIR.'/';
- } else {
- $seoConfig = tpCache('seo', [], $val['mark']);
- $seo_pseudo = !empty($seoConfig['seo_pseudo']) ? $seoConfig['seo_pseudo'] : config('ey_config.seo_pseudo');
- if (1 == $seo_pseudo) {
- $url = $request->domain().ROOT_DIR.$inletStr;
- if (!empty($inletStr)) {
- $url .= '?';
- } else {
- $url .= '/?';
- }
- $url .= http_build_query(['lang'=>$val['mark']]);
- } else {
- $url = ROOT_DIR.$inletStr.'/'.$val['mark'];
- }
- }
- }
-
- $lang_info['lang_url'] = $url;
- cookie('lang_info', $lang_info);
- break;
- }
- }
- \think\Config::set('cache.path', CACHE_PATH.$lang.DS);
- $pre_lang = \think\Cookie::get($langCookieVar);
- \think\Cookie::set($langCookieVar, $lang);
- if ($pre_lang != $lang) {
- if ($is_admin) {
- \think\Db::name('admin')->where('admin_id', \think\Session::get('admin_id'))->update([
- 'mark_lang' => $lang,
- 'update_time' => getTime(),
- ]);
- }
- }
-
- $execute_end = true;
- }
- }
-
- if (!function_exists('get_default_site'))
- {
-
-
- function get_default_site()
- {
- static $default_site = null;
- if (null === $default_site) {
- $default_site = \think\Config::get('ey_config.site_default_home');
- if (!empty($default_site)) {
- $default_site = \think\Db::name('citysite')->where(['id'=>$default_site])->getField('domain');
- }
- }
-
- return $default_site;
- }
- }
-
- if (!function_exists('get_home_site'))
- {
-
-
- function get_home_site()
- {
- static $home_site = null;
- if (null === $home_site) {
- $home_site = input('param.site/s');
- if (empty($home_site)) {
-
- $subDomain = request()->subDomain();
- if (!empty($subDomain) && 'www' != $subDomain) {
- $siteInfo = \think\Db::name('citysite')->where('domain',$subDomain)->cache(true, EYOUCMS_CACHE_TIME, 'citysite')->find();
- if (!empty($siteInfo['is_open'])) {
- $home_site = $siteInfo['domain'];
- }
- }
-
- empty($home_site) && $home_site = get_default_site();
- }
- $home_site = preg_replace('/([^\w\-\_])/i', '', $home_site);
- }
-
- return $home_site;
- }
- }
-
- if (!function_exists('switch_citysite'))
- {
-
-
- function switch_citysite()
- {
- static $execute_end = false;
- if (true === $execute_end) {
- return true;
- }
-
- $request = \think\Request::instance();
-
- if (!stristr($request->baseFile(), 'index.php')) {
- return true;
- }
-
- $pathinfo = $request->pathinfo();
-
- $var_site = $request->param('site/s');
- $var_site = trim($var_site, '/');
- if (!empty($var_site)) {
- if (!preg_match('/^([\w\-\_]+)$/i', $var_site)) {
- to_index();
- }
- }
-
-
- $lang_switch_on = config('lang_switch_on');
- $city_switch_on = config('city_switch_on');
- if ($lang_switch_on || !$city_switch_on) {
- return true;
- }
-
- static $citysite_db = null;
- if (null == $citysite_db) {
- $citysite_db = \think\Db::name('citysite');
- }
-
- $current_site = '';
-
- if (!empty($pathinfo)) {
- $s_arr = explode('/', $pathinfo);
- if ('m' == $s_arr[0]) {
- $s_arr[0] = $s_arr[1];
- }
- $count = $citysite_db->where(['domain'=>$s_arr[0]])->cache(true, EYOUCMS_CACHE_TIME, 'citysite')->count();
- if (!empty($count)) {
- $current_site = $s_arr[0];
- }
- }
-
-
- $site = $request->param('site/s', $current_site);
- $site = trim($site, '/');
- if (!empty($site)) {
-
- $siteInfo = $citysite_db->where('domain',$site)->cache(true, EYOUCMS_CACHE_TIME, 'citysite')->find();
- if (empty($siteInfo['domain'])) {
- to_index();
- } else {
- $site_default_home = tpCache('site.site_default_home');
- if ($siteInfo['id'] == $site_default_home) {
- header('Location: '.ROOT_DIR.'/');
- exit;
- }
- }
- } else {
- $subDomain = $request->subDomain();
- $web_basehost = tpCache('web.web_basehost');
- $web_subDomain = $request->subDomain('', true, $web_basehost);
- if (!empty($subDomain) && !in_array($subDomain, ['www', $web_subDomain])) {
- $siteInfo = $citysite_db->where('domain',$subDomain)->cache(true, EYOUCMS_CACHE_TIME, 'citysite')->find();
- if (!empty($siteInfo['is_open'])) {
- $site_default_home = tpCache('site.site_default_home');
- if ($site_default_home == $siteInfo['id']) {
- $domain = preg_replace('/^(http(s)?:)?(\/\/)?([^\/\:]*)(.*)$/i', '${4}', $web_basehost);
- $url = $request->scheme().'://'.$domain;
- if (stristr($request->host(), ':')) {
- $url .= ":".$request->port();
- }
- $url .= ROOT_DIR;
- header('Location: '.$url);
- exit;
- } else {
- $site = $siteInfo['domain'];
- }
- } else {
- to_index();
- }
- }
- empty($site) && $site = 'www';
- }
-
- \think\Config::set('cache.path', CACHE_PATH.$site.DS);
- $execute_end = true;
- }
- }
-
- if (!function_exists('getUsersConfigData'))
- {
-
-
-
-
-
-
-
- function getUsersConfigData($config_key,$data=array(),$lang='', $options = null){
- $tableName = 'users_config';
- $table_db = \think\Db::name($tableName);
-
- $lang = !empty($lang) ? $lang : get_current_lang();
- $param = explode('.', $config_key);
- $cache_inc_type = "{$tableName}-{$lang}-{$param[0]}";
- if (empty($options['path'])) {
- $options['path'] = DATA_PATH.'runtime'.DS.'cache'.DS.$lang.DS;
- }
- if(empty($data)){
-
-
- $config = cache($cache_inc_type,'',$options);
- if(empty($config)){
-
- if ($param[0] == 'all') {
- $param[0] = 'all';
- $res = $table_db->where([
- 'lang' => $lang,
- ])->select();
- } else {
- $res = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- ])->select();
- }
- if($res){
- foreach($res as $k=>$val){
- $config[$val['name']] = $val['value'];
- }
- cache($cache_inc_type,$config,$options);
- }
- }
- if(!empty($param) && count($param)>1){
- $newKey = strtolower($param[1]);
- return isset($config[$newKey]) ? $config[$newKey] : '';
- }else{
- return $config;
- }
- }else{
-
- $result = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- ])->select();
- if($result){
- foreach($result as $val){
- $temp[$val['name']] = $val['value'];
- }
- $add_data = array();
- foreach ($data as $k=>$v){
- $newK = strtolower($k);
- $newArr = array(
- 'name'=>$newK,
- 'value'=>trim($v),
- 'inc_type'=>$param[0],
- 'lang' => $lang,
- 'update_time' => getTime(),
- );
- if(!isset($temp[$newK])){
- array_push($add_data, $newArr);
- }else{
- if ($v != $temp[$newK]) {
- $table_db->where([
- 'name' => $newK,
- 'lang' => $lang,
- ])->save($newArr);
- }
- }
- }
- if (!empty($add_data)) {
- $table_db->insertAll($add_data);
- }
-
- $newRes = $table_db->where([
- 'inc_type' => $param[0],
- 'lang' => $lang,
- ])->select();
- foreach ($newRes as $rs){
- $newData[$rs['name']] = $rs['value'];
- }
- }else{
- if ($param[0] != 'all') {
- foreach($data as $k=>$v){
- $newK = strtolower($k);
- $newArr[] = array(
- 'name'=>$newK,
- 'value'=>trim($v),
- 'inc_type'=>$param[0],
- 'lang' => $lang,
- 'update_time' => getTime(),
- );
- }
- !empty($newArr) && $table_db->insertAll($newArr);
- }
- $newData = $data;
- }
-
- $result = false;
- $res = $table_db->where([
- 'lang' => $lang,
- ])->select();
- if($res){
- $global = array();
- foreach($res as $k=>$val){
- $global[$val['name']] = $val['value'];
- }
- $result = cache("{$tableName}-{$lang}-all",$global,$options);
- }
-
- if ($param[0] != 'all') {
- $result = cache($cache_inc_type,$newData,$options);
- }
-
- return $result;
- }
- }
- }
-
- if (!function_exists('send_email'))
- {
-
-
- function send_email($to='', $subject='', $data=array(), $scene=0, $smtp_config = []){
-
- $emailLogic = new \app\common\logic\EmailLogic($smtp_config);
- $res = $emailLogic->send_email($to, $subject, $data, $scene);
- return $res;
- }
- }
-
- if (!function_exists('sendSms'))
- {
-
-
- function sendSms($scene, $sender, $params,$unique_id=0,$sms_config = [])
- {
- $smsLogic = new \app\common\logic\SmsLogic($sms_config);
- return $smsLogic->sendSms($scene, $sender, $params, $unique_id);
- }
- }
-
- if (!function_exists('get_region_list')){
-
-
- function get_region_list()
- {
- $result = extra_cache('global_get_region_list');
- if ($result == false) {
- $result = \think\Db::name('region')->field('id, name')->getAllWithIndex('id');
- extra_cache('global_get_region_list', $result);
- }
-
- return $result;
- }
- }
-
- if (!function_exists('get_province_list')){
-
-
- function get_province_list()
- {
- $result = extra_cache('global_get_province_list');
- if ($result == false) {
- $result = \think\Db::name('region')->field('id, name')
- ->where('level',1)
- ->getAllWithIndex('id');
- extra_cache('global_get_province_list', $result);
- }
-
- return $result;
- }
- }
-
- if (!function_exists('get_city_list')){
-
-
- function get_city_list()
- {
- $result = extra_cache('global_get_city_list');
- if ($result == false) {
- $result = \think\Db::name('region')->field('id, name')
- ->where('level',2)
- ->getAllWithIndex('id');
- extra_cache('global_get_city_list', $result);
- }
-
- return $result;
- }
- }
-
- if (!function_exists('get_area_list')){
-
-
- function get_area_list()
- {
- $result = extra_cache('global_get_area_list');
- if ($result == false) {
- $result = \think\Db::name('region')->field('id, name')
- ->where('level',3)
- ->getAllWithIndex('id');
- extra_cache('global_get_area_list', $result);
- }
-
- return $result;
- }
- }
-
- if (!function_exists('get_region_name')){
-
-
- function get_region_name($id = 0)
- {
- $result = get_region_list();
- return empty($result[$id]['name']) ? '' : $result[$id]['name'];
- }
- }
-
- if (!function_exists('get_province_name')){
-
-
- function get_province_name($id = 0)
- {
- $result = get_province_list();
- return empty($result[$id]['name']) ? '' : $result[$id]['name'];
- }
- }
-
- if (!function_exists('get_city_name')){
-
-
- function get_city_name($id = 0)
- {
- $result = get_city_list();
- return empty($result[$id]['name']) ? '' : $result[$id]['name'];
- }
- }
-
- if (!function_exists('get_area_name')){
-
-
- function get_area_name($id = 0)
- {
- $result = get_area_list();
- return empty($result[$id]['name']) ? '' : $result[$id]['name'];
- }
- }
-
- if (!function_exists('get_citysite_list')){
-
-
- function get_citysite_list()
- {
- $result = extra_cache('global_get_citysite_list');
- if (empty($result)) {
- $result = \think\Db::name('citysite')->field('id, name, level, parent_id, topid, domain, initial, is_open')
- ->where(['status'=>1])
- ->order("sort_order asc, id asc")
- ->getAllWithIndex('id');
- extra_cache('global_get_citysite_list', $result);
- }
-
- return $result;
- }
- }
-
- if (!function_exists('get_site_province_list')){
-
-
- function get_site_province_list()
- {
- $result = extra_cache('global_get_site_province_list');
- if (empty($result)) {
- $result = \think\Db::name('citysite')->field('id, name, domain, parent_id')
- ->where(['level'=>1, 'status'=>1])
- ->order("sort_order asc, id asc")
- ->getAllWithIndex('id');
-
- extra_cache('global_get_site_province_list', $result);
- }
- return $result;
- }
- }
-
- if (!function_exists('get_site_city_list')){
-
-
- function get_site_city_list()
- {
- $result = extra_cache('global_get_site_city_list');
- if (empty($result)) {
- $result = \think\Db::name('citysite')->field('id, name, parent_id')
- ->where(['level'=>2, 'status'=>1])
- ->order("sort_order asc, id asc")
- ->getAllWithIndex('id');
- extra_cache('global_get_site_city_list', $result);
- }
-
- return $result;
- }
- }
-
- if (!function_exists('get_site_area_list')){
-
-
- function get_site_area_list()
- {
- $result = extra_cache('global_get_site_area_list');
- if (empty($result)) {
- $result = \think\Db::name('citysite')->field('id, name, parent_id')
- ->where(['level'=>3, 'status'=>1])
- ->order("sort_order asc, id asc")
- ->getAllWithIndex('id');
- extra_cache('global_get_site_area_list', $result);
- }
-
- return $result;
- }
- }
-
- if (!function_exists('AddOrderAction'))
- {
-
-
- function AddOrderAction($OrderId, $UsersId = 0, $ActionUsers = 0, $OrderStatus = 0, $ExpressStatus = 0, $PayStatus = 0, $ActionDesc = '提交订单', $ActionNote = '会员提交订单成功')
- {
- if (is_array($OrderId) && 4 == $OrderStatus) {
-
- foreach ($OrderId as $key => $value) {
- $ActionData[] = [
- 'order_id' => $value['order_id'],
- 'users_id' => $UsersId,
- 'action_user' => $ActionUsers,
- 'order_status' => $OrderStatus,
- 'express_status' => $ExpressStatus,
- 'pay_status' => $PayStatus,
- 'action_desc' => $ActionDesc,
- 'action_note' => $ActionNote,
- 'lang' => get_home_lang(),
- 'add_time' => getTime(),
- ];
- }
-
- M('shop_order_log')->insertAll($ActionData);
- } else if (is_array($OrderId)) {
-
- foreach ($OrderId as $key => $value) {
- $ActionData[] = [
- 'order_id' => is_array($value) && !empty($value['order_id']) ? $value['order_id'] : $value,
- 'users_id' => $UsersId,
- 'action_user' => $ActionUsers,
- 'order_status' => $OrderStatus,
- 'express_status' => $ExpressStatus,
- 'pay_status' => $PayStatus,
- 'action_desc' => $ActionDesc,
- 'action_note' => $ActionNote,
- 'lang' => get_home_lang(),
- 'add_time' => getTime(),
- ];
- }
-
- M('shop_order_log')->insertAll($ActionData);
- } else {
-
- $ActionData = [
- 'order_id' => $OrderId,
- 'users_id' => $UsersId,
- 'action_user' => $ActionUsers,
- 'order_status' => $OrderStatus,
- 'express_status' => $ExpressStatus,
- 'pay_status' => $PayStatus,
- 'action_desc' => $ActionDesc,
- 'action_note' => $ActionNote,
- 'lang' => get_home_lang(),
- 'add_time' => getTime(),
- ];
-
- M('shop_order_log')->add($ActionData);
- }
- }
- }
-
- if (!function_exists('UsersMoneyAction'))
- {
-
-
- function UsersMoneyAction($OrderCode = null, $UsersId = null, $UsersMoney = null, $Cause = '订单支付')
- {
- if (empty($OrderCode) || empty($UsersId) || empty($UsersMoney)) return false;
- $Time = getTime();
-
- $UsersNewMoney = sprintf("%.2f", $UsersId['users_money'] -= $UsersMoney);
- $MoneyData = [
- 'users_id' => $UsersId['users_id'],
- 'money' => $UsersMoney,
- 'users_money' => $UsersNewMoney,
- 'cause' => $Cause,
- 'cause_type' => 3,
- 'status' => 3,
- 'pay_details' => '',
- 'order_number' => $OrderCode,
- 'add_time' => $Time,
- 'update_time' => $Time,
- ];
- M('users_money')->add($MoneyData);
-
- }
- }
-
- if (!function_exists('GetEamilSendData'))
- {
-
-
- function GetEamilSendData($SmtpConfig = [], $users = [], $sendContent = [], $type = 1, $pay_method = null)
- {
-
- if (empty($SmtpConfig) || empty($users) || empty($sendContent)) return false;
-
-
- if (in_array($type, [1, 3])) {
-
- $send_scene = 1 === intval($type) ? 5 : 20;
- $where = [
- 'lang' => get_admin_lang(),
- 'send_scene' => $send_scene
- ];
- $SmtpOpen = \think\Db::name('smtp_tpl')->where($where)->getField('is_open');
-
-
- $email = !empty($SmtpConfig['smtp_from_eamil']) ? $SmtpConfig['smtp_from_eamil'] : null;
- } else if (in_array($type, [2])) {
- $send_scene = 6;
- $where = [
- 'lang' => get_admin_lang(),
- 'send_scene' => $send_scene
- ];
- $SmtpOpen = \think\Db::name('smtp_tpl')->where($where)->getField('is_open');
-
-
- $email = !empty($users['email']) ? $users['email'] : null;
- }
-
-
- if (empty($SmtpOpen) || empty($email)) return false;
-
-
- if (!empty($SmtpConfig['smtp_server']) && !empty($SmtpConfig['smtp_user']) && !empty($SmtpConfig['smtp_pwd'])) {
- $Result = [];
- $url = ROOT_DIR . '/index.php?m=user&c=Smtpmail&a=send_email&_ajax=1';
-
- if (in_array($type, [1, 2])) {
- switch ($type) {
- case '1':
- $title = '订单支付';
- break;
- case '2':
- $title = '订单发货';
- break;
- }
- $Result = [
- 'url' => $url,
- 'data' => [
- 'email' => $email,
- 'title' => $title,
- 'type' => 'order_msg',
- 'scene' => $send_scene,
- 'data' => [
- 'type' => $type,
- 'nickname' => !empty($users['nickname']) ? $users['nickname'] : $users['username'],
- 'pay_method' => $pay_method,
- 'order_id' => !empty($sendContent['order_id']) ? $sendContent['order_id'] : '',
- 'order_code' => !empty($sendContent['order_code']) ? $sendContent['order_code'] : '',
- 'service_id' => !empty($sendContent['service_id']) ? $sendContent['service_id'] : ''
- ],
- ]
- ];
- }
-
- else if (in_array($type, [3])) {
- $Result = [
- 'url' => $url,
- 'data' => [
- 'email' => $email,
- 'title' => '投稿提醒',
- 'type' => 'usersRelease',
- 'scene' => $send_scene,
- 'data' => [
- 'type' => $type,
- 'nickname' => !empty($users['nickname']) ? $users['nickname'] : $users['username'],
- 'title' => !empty($sendContent['title']) ? $sendContent['title'] : '',
- 'content' => !empty($sendContent['seo_description']) ? $sendContent['seo_description'] : '',
- 'add_time' => date('Y-m-d H:i:s', $sendContent['add_time']),
- 'arcrank' => isset($sendContent['arcrank']) && -1 === intval($sendContent['arcrank']) ? '未审核' : '自动审核',
- ],
- ]
- ];
- }
- return $Result;
- }
- return false;
- }
- }
-
- if (!function_exists('GetMobileSendData'))
- {
-
-
- function GetMobileSendData($SmsConfig = [], $users = [], $sendContent = [], $type = 1, $pay_method = null)
- {
-
- if (empty($SmsConfig) || empty($users) || empty($sendContent)) return false;
-
-
- $sms_type = tpCache('sms.sms_type') ? tpCache('sms.sms_type') : 0;
-
-
- if (in_array($type, [1, 3])) {
-
- $send_scene = 1 === intval($type) ? 5 : 20;
- $where = [
- 'sms_type' => $sms_type,
- 'lang' => get_admin_lang(),
- 'send_scene' => $send_scene
- ];
- $SmsOpen = \think\Db::name('sms_template')->where($where)->getField('is_open');
-
-
- $mobile = !empty($SmsConfig['sms_test_mobile']) ? $SmsConfig['sms_test_mobile'] : null;
- } else if (in_array($type, [2])) {
- $send_scene = 6;
- $where = [
- 'sms_type' => $sms_type,
- 'lang' => get_admin_lang(),
- 'send_scene' => $send_scene
- ];
- $SmsOpen = \think\Db::name('sms_template')->where($where)->getField('is_open');
-
-
- $mobile = !empty($users['mobile']) ? $users['mobile'] : null;
- if (empty($mobile)) {
- $mobile = \think\Db::name('shop_order')->where('order_code', $sendContent['order_code'])->getField('mobile');
- }
- }
-
-
- if (empty($SmsOpen) || empty($mobile)) return false;
-
-
- if (($sms_type == 1 && !empty($SmsConfig['sms_appkey']) && !empty($SmsConfig['sms_secretkey'])) || ($sms_type == 2 && !empty($SmsConfig['sms_appkey_tx']) && !empty($SmsConfig['sms_appid_tx']))) {
- $Result = [];
- $url = ROOT_DIR . '/index.php?m=api&c=Ajax&a=SendMobileCode&_ajax=1';
- if (in_array($type, [1, 2])) {
- switch ($type) {
- case '1':
- $title = '订单支付';
- break;
- case '2':
- $title = '订单发货';
- break;
- }
- $Result = [
- 'url' => $url,
- 'data' => [
- 'mobile' => $mobile,
- 'scene' => $send_scene,
- 'title' => $title,
- 'type' => 'order_msg',
- 'data' => [
- 'type' => $type,
- 'nickname' => !empty($users['nickname']) ? $users['nickname'] : $users['username'],
- 'pay_method' => $pay_method,
- 'order_code' => !empty($sendContent['order_code']) ? $sendContent['order_code'] : '',
- ],
- ]
- ];
- } else if (in_array($type, [3])) {
- $Result = [
- 'url' => $url,
- 'data' => [
- 'mobile' => $mobile,
- 'scene' => $send_scene,
- 'title' => '投稿提醒',
- 'type' => 'usersRelease',
- 'data' => [
- 'type' => $type,
- 'nickname' => !empty($users['nickname']) ? $users['nickname'] : $users['username'],
- 'title' => !empty($sendContent['title']) ? $sendContent['title'] : '',
- 'content' => !empty($sendContent['seo_description']) ? $sendContent['seo_description'] : '',
- 'add_time' => date('Y-m-d H:i:s', $sendContent['add_time']),
- 'arcrank' => isset($sendContent['arcrank']) && -1 === intval($sendContent['arcrank']) ? '未审核' : '自动审核',
- ],
- ]
- ];
- }
- return $Result;
- }
- return false;
- }
- }
-
- if (!function_exists('download_file'))
- {
-
-
- function download_file($down_path = '', $file_mime = '', $file_name = '')
- {
-
- function_exists('set_time_limit') && set_time_limit(0);
- @ini_set('memory_limit','-1');
- @ini_set('max_execution_time', '0');
-
- $down_path = iconv("utf-8", "gb2312//IGNORE", $down_path);
-
-
- $down_path = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i', '$2', $down_path);
-
-
-
- $filename = basename($down_path);
- if (!empty($file_name)) {
- $arr = explode('.', $filename);
- $ext = end($arr);
- $arr1 = explode('.', $file_name);
- unset($arr1[count($arr1) - 1]);
- $filename = implode('.', $arr1).'.'.$ext;
- }
-
-
-
-
-
-
-
-
-
-
-
- preg_match("/^((\w)*:)?(\/\/).*$/", $down_path, $match);
- if (empty($match)) {
- $filesize = filesize('.'.$down_path);
- } else {
- $header_array = get_headers($down_path, true);
- $filesize = !empty($header_array['Content-Length']) ? $header_array['Content-Length'] : 0;
- }
-
-
-
- header('content-type:application/octet-stream');
-
- Header("Accept-Ranges: bytes");
-
- Header("Accept-Length: " . $filesize);
-
- Header("Content-Disposition: attachment; filename=" . basename($filename));
-
-
- $read_buffer = 1024 * 1024 * 2;
- if (is_http_url($down_path)) {
- $file = fopen($down_path, 'rb');
- } else {
- $file = fopen('.' . $down_path, 'rb');
- }
-
- $sum_buffer = 0;
-
- while(!feof($file) && $sum_buffer < $filesize) {
- echo fread($file,$read_buffer);
- $sum_buffer += $read_buffer;
- }
-
-
- fclose($file);
- exit;
- }
- }
-
- if (!function_exists('is_realdomain'))
- {
-
-
- function is_realdomain($domain = '')
- {
- $is_real = false;
- $domain = !empty($domain) ? $domain : request()->host();
- if (!preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i', $domain) && 'localhost' != $domain && '127.0.0.1' != serverIP()) {
- $is_real = true;
- }
-
- return $is_real;
- }
- }
-
- if (!function_exists('img_style_wh'))
- {
-
-
- function img_style_wh($content = '', $title = '')
- {
- if (!empty($content)) {
-
- static $basicConfig = null;
- null === $basicConfig && $basicConfig = tpCache('basic');
- if (empty($basicConfig['basic_img_auto_wh']) && empty($basicConfig['basic_img_alt']) && empty($basicConfig['basic_img_title'])) {
- return $content;
- }
-
- preg_match_all('/<img.*(\/)?>/iUs', $content, $imginfo);
- $imginfo = !empty($imginfo[0]) ? $imginfo[0] : [];
- if (!empty($imginfo)) {
- $num = 1;
- $appendStyle = "max-width:100%!important;height:auto!important;";
- $title = preg_replace('/("|\')/i', '', $title);
- foreach ($imginfo as $key => $imgstr) {
- $imgstrNew = $imgstr;
- if (!stristr($imgstrNew, ' src=')) {
- continue;
- }
- $imgname = preg_replace("/<img(.*?)src(\s*)=(\s*)[\'|\"](.*?)([^\/\'\"]*)[\'|\"](.*?)[\/]?(\s*)>/i", '${5}', $imgstrNew);
- $imgname = str_replace('/', '\/', $imgname);
-
-
- if (!empty($basicConfig['basic_img_auto_wh'])) {
- if (!stristr($imgstrNew, $appendStyle)) {
-
- $imgstrNew = preg_replace('/style(\s*)=(\s*)[\'|\"]([^\'\"]*)?[\'|\"]/i', 'style="'.$appendStyle.'${3}"', $imgstrNew);
- if (!preg_match('/<img(.*?)style(\s*)=(\s*)[\'|\"](.*?)[\'|\"](.*?)[\/]?(\s*)>/i', $imgstrNew)) {
-
- $imgstrNew = str_ireplace('<img', "<img style=\"".$appendStyle."\" ", $imgstrNew);
- }
- }
- } else {
- $imgstrNew = str_ireplace([$appendStyle, $appendStyle], ['', ''], $imgstrNew);
- }
-
-
-
-
-
- if (!empty($basicConfig['basic_img_alt'])) {
- $altNew = $title."(图{$num})";
- if (!empty($basicConfig['basic_img_alt_force'])) {
-
- $imgstrNew = preg_replace('/alt(\s*)=(\s*)[\'|\"]([^\'\"]*)[\'|\"]/i', '', $imgstrNew);
- $imgstrNew = str_ireplace('<img', "<img alt=\"{$altNew}\" ", $imgstrNew);
- } else {
- $imgstrNew = preg_replace('/alt(\s*)=(\s*)[\'|\"]('.$imgname.')?[\'|\"]/i', 'alt="'.$altNew.'"', $imgstrNew);
- if (!preg_match('/<img(.*?)alt(\s*)=(\s*)[\'|\"](.*?)[\'|\"](.*?)[\/]?(\s*)>/i', $imgstrNew)) {
-
- $imgstrNew = str_ireplace('<img', "<img alt=\"{$altNew}\" ", $imgstrNew);
- }
- }
- }
-
-
- if (!empty($basicConfig['basic_img_title'])) {
- $titleNew = $title."(图{$num})";
- $imgstrNew = preg_replace('/title(\s*)=(\s*)[\'|\"]('.$imgname.')?[\'|\"]/i', 'title="'.$titleNew.'"', $imgstrNew);
- if (!preg_match('/<img(.*?)title(\s*)=(\s*)[\'|\"](.*?)[\'|\"](.*?)[\/]?(\s*)>/i', $imgstrNew)) {
-
- $imgstrNew = str_ireplace('<img', "<img title=\"{$titleNew}\" ", $imgstrNew);
- }
- }
-
-
- $content = str_ireplace($imgstr, $imgstrNew, $content);
- $num++;
- }
- }
- }
-
- return $content;
- }
- }
-
- if (!function_exists('get_archives_data'))
- {
-
-
- function get_archives_data($array = [], $id = '')
- {
-
- if (empty($array) || empty($id)) {
- return false;
- }
-
- static $array_new = null;
- if (null === $array_new) {
- $aids = get_arr_column($array, $id);
- $archivesList = \think\Db::name('archives')->field('*')->where('aid','IN',$aids)->select();
- $typeids = get_arr_column($archivesList, 'typeid');
- $arctypeList = \think\Db::name('arctype')->field('*')->where('id','IN',$typeids)->getAllWithIndex('id');
-
- foreach ($archivesList as $key2 => $val2) {
- $array_new[$val2['aid']] = array_merge($arctypeList[$val2['typeid']], $val2);
- }
- }
-
- return $array_new;
- }
- }
-
- if (!function_exists('SynchronizeQiniu'))
- {
-
-
- function SynchronizeQiniu($images,$Qiniuyun=null,$is_tcp=false)
- {
- static $Qiniuyun = null;
-
- if (null == $Qiniuyun) {
-
- $data = M('weapp')->where('code','Qiniuyun')->field('data')->find();
- $Qiniuyun = json_decode($data['data'], true);
- }
-
- $images = preg_replace('#^(/[/\w\-]+)?(/uploads/)#i', '$2', $images);
-
- if (empty($Qiniuyun) || empty($Qiniuyun['domain'])) {
- return ROOT_DIR.$images;
- }
-
-
- weapp_vendor('Qiniu.src.Qiniu.Auth', 'Qiniuyun');
- weapp_vendor('Qiniu.src.Qiniu.Storage.UploadManager', 'Qiniuyun');
- require_once ROOT_PATH.'weapp/Qiniuyun/vendor/Qiniu/autoload.php';
-
-
- $accessKey = $Qiniuyun['access_key'];
- $secretKey = $Qiniuyun['secret_key'];
- $bucket = $Qiniuyun['bucket'];
- $domain = $Qiniuyun['domain'];
-
- $auth = new Qiniu\Auth($accessKey, $secretKey);
-
- $token = $auth->uploadToken($bucket);
-
- $filePath = realpath('.'.$images);
-
- $key = ltrim($images, '/');
-
- $uploadMgr = new Qiniu\Storage\UploadManager;
-
- list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
-
- if (empty($err) || $err === null) {
- $tcp = '//';
- if ($is_tcp) {
- $tcp = !empty($Qiniuyun['tcp']) ? $Qiniuyun['tcp'] : '';
- switch ($tcp) {
- case '2':
- $tcp = 'https://';
- break;
-
- case '3':
- $tcp = '//';
- break;
-
- case '1':
- default:
- $tcp = 'http://';
- break;
- }
- }
- $images = $tcp.$domain.'/'.ltrim($images, '/');
- }
-
- return [
- 'state' => 'SUCCESS',
- 'url' => $images,
- ];
- }
- }
-
- if (!function_exists('SynImageObjectBucket'))
- {
-
-
- function SynImageObjectBucket($images = '', $weappList = [], $fileziyuan = [])
- {
- $result = [];
- if (empty($images)) {
- return $result;
- }
-
-
- $images = preg_replace('#^(/[/\w\-]+)?(/uploads/|/public/static/)#i', '$2', $images);
-
- if (empty($weappList)) {
- $weappList = \think\Db::name('weapp')->where([
- 'status' => 1,
- ])->cache(true, EYOUCMS_CACHE_TIME, 'weapp')
- ->getAllWithIndex('code');
- }
-
- if (!empty($weappList['Qiniuyun']) && 1 == $weappList['Qiniuyun']['status']) {
-
- $weappConfig = json_decode($weappList['Qiniuyun']['config'], true);
- if (!empty($weappConfig['version']) && 'v1.0.6' <= $weappConfig['version']) {
- $qnyData = json_decode($weappList['Qiniuyun']['data'], true);
- $qiniuyunOssModel = new \weapp\Qiniuyun\model\QiniuyunModel;
- $ResultQny = $qiniuyunOssModel->Synchronize($qnyData, $images);
- } else {
- $ResultQny = SynchronizeQiniu($images);
- }
-
- if (!empty($ResultQny) && is_array($ResultQny)) {
- $result['local_save'] = !empty($qnyData['local_save']) ? $qnyData['local_save'] : '';
- $result['state'] = !empty($ResultQny['state']) ? $ResultQny['state'] : '';
- $result['url'] = !empty($ResultQny['url']) ? $ResultQny['url'] : '';
- }
- } else if (!empty($weappList['AliyunOss']) && 1 == $weappList['AliyunOss']['status']) {
-
- $ossData = json_decode($weappList['AliyunOss']['data'], true);
- $aliyunOssModel = new \weapp\AliyunOss\model\AliyunOssModel;
- $ResultOss = $aliyunOssModel->Synchronize($ossData, $images);
-
- if (!empty($ResultOss) && is_array($ResultOss)) {
- $result['local_save'] = !empty($ossData['local_save']) ? $ossData['local_save'] : '';
- $result['state'] = !empty($ResultOss['state']) ? $ResultOss['state'] : '';
- $result['url'] = !empty($ResultOss['url']) ? $ResultOss['url'] : '';
- }
- } else if (!empty($weappList['Cos']) && 1 == $weappList['Cos']['status']) {
-
- $CosData = json_decode($weappList['Cos']['data'], true);
- $cosModel = new \weapp\Cos\model\CosModel;
- $ResultCos = $cosModel->Synchronize($CosData, $images);
-
- if (!empty($ResultCos) && is_array($ResultCos)) {
- $result['local_save'] = !empty($CosData['local_save']) ? $CosData['local_save'] : '';
- $result['url'] = !empty($ResultCos['url']) ? $ResultCos['url'] : '';
- $result['state'] = !empty($ResultCos['state']) ? $ResultCos['state'] : '';
- }
- }
-
-
- return is_array($result) ? $result : [];
- }
- }
-
- if (!function_exists('getWeappObjectBucket'))
- {
-
-
- function getWeappObjectBucket()
- {
- $data = [];
-
- $weappList = \think\Db::name('weapp')->where([
- 'status' => 1,
- ])->cache(true, EYOUCMS_CACHE_TIME, 'weapp')
- ->getAllWithIndex('code');
-
- if (!empty($weappList['Qiniuyun']) && 1 == $weappList['Qiniuyun']['status']) {
-
- $data = json_decode($weappList['Qiniuyun']['data'], true);
- } else if (!empty($weappList['AliyunOss']) && 1 == $weappList['AliyunOss']['status']) {
-
- $data = json_decode($weappList['AliyunOss']['data'], true);
- } else if (!empty($weappList['Cos']) && 1 == $weappList['Cos']['status']) {
-
- $data = json_decode($weappList['Cos']['data'], true);
- }
-
- return is_array($data) ? $data : [];
- }
- }
-
- if (!function_exists('getAllChild'))
- {
-
-
- function getAllChild(&$arctype_child_all,$id,$type = 1){
- if($type == 1){
- $arctype_child = \think\Db::name('arctype')->where(['is_del'=>0,'status'=>1,'parent_id'=>$id])->getfield('id',true);
- }else{
- $where['is_del'] = 0;
- $where['status'] = 1;
- $where['parent_id'] = $id;
- $where['current_channel'] = array(array('neq',6),array('neq',8));
- $arctype_child = \think\Db::name('arctype')->where($where)->getfield('id',true);
- }
-
- if(!empty($arctype_child)){
- $arctype_child_all = array_merge($arctype_child_all,$arctype_child);
- for($i=0;$i<count($arctype_child);$i++){
- getAllChild($arctype_child_all,$arctype_child[$i],$type);
- }
- }
- }
- }
-
- if (!function_exists('getAllChildByList'))
- {
-
-
- function getAllChildByList(&$arctype_child_all,$id,$current_channel){
- $arctype_child = \think\Db::name('arctype')->where(['is_del'=>0,'status'=>1,'parent_id'=>$id,'current_channel'=>$current_channel])->getfield('id',true);
- if(!empty($arctype_child)){
- $arctype_child_all = array_merge($arctype_child_all,$arctype_child);
- for($i=0;$i<count($arctype_child);$i++){
- getAllChild($arctype_child_all,$arctype_child[$i]);
- }
- }
- }
- }
-
- if (!function_exists('getAllChildArctype'))
- {
-
- function getAllChildArctype(&$arctype_child_all,$id){
- $where['a.is_del'] = 0;
- $where['a.status'] = 1;
- $where['a.parent_id'] = $id;
- $arctype_child = \think\Db::name('arctype')->field('c.*, a.*, a.id as typeid')
- ->alias('a')
- ->join('__CHANNELTYPE__ c', 'c.id = a.current_channel', 'LEFT')
- ->where($where)
- ->select();
- if(!empty($arctype_child)){
- $arctype_child_all = array_merge($arctype_child,$arctype_child_all);
- for($i=0;$i<count($arctype_child);$i++){
- getAllChildArctype($arctype_child_all,$arctype_child[$i]['typeid']);
- }
- }
- }
- }
-
- if (!function_exists('getAllArctype'))
- {
-
-
- function getAllArctype($home_lang,$id,$view_suffix,$parent = true,$aid = 0){
- $map = [];
- if (!empty($id)){
- if (is_array($id)) {
- $map['a.id'] = ['IN', $id];
- } else {
- $map['a.id'] = $id;
- }
- }
-
- $map['a.lang'] = $home_lang;
- $map['a.is_del'] = 0;
- $map['a.status'] = 1;
- $info = \think\Db::name('arctype')->field('c.*, a.*, a.id as typeid')
- ->alias('a')
- ->join('__CHANNELTYPE__ c', 'c.id = a.current_channel', 'LEFT')
- ->where($map)
- ->order("a.grade desc")
- ->cache(true,EYOUCMS_CACHE_TIME,"arctype")
- ->select();
- if (!empty($id) && $parent && $aid == 0) {
- getAllChildArctype($info,$id);
- }
- $info = getAllArctypeCount($home_lang,$info,$id,$view_suffix,$aid);
- return $info;
- }
- }
-
- if (!function_exists('arctypeAllSub'))
- {
-
-
- function arctypeAllSub($typeid = 0, $self = true)
- {
- $lang = get_current_lang();
- $cacheKey = md5("common_arctypeAllSub_{$typeid}_{$self}_{$lang}");
- $data = cache($cacheKey);
- if (empty($data)) {
- $where = [];
- $where['c.lang'] = $lang;
- $where['c.is_del'] = 0;
- $where['c.status'] = 1;
-
- $fields = "c.id, c.parent_id, c.current_channel, c.grade";
- $res = $res2 = \think\Db::name('arctype')
- ->field($fields)
- ->alias('c')
- ->where($where)
- ->order('c.grade desc, c.id asc')
- ->select();
- if (empty($res)) return [];
-
- $data = [];
- foreach ($res as $key => $val) {
- if (in_array($val['current_channel'], [51]) || !empty($val['weapp_code'])) {
- continue;
- }
-
-
- if (!isset($data[$val['id']])) {
- $data[$val['id']] = [$val['id']];
- } else {
- $data[$val['id']][] = $val['id'];
- $data[$val['id']] = array_unique($data[$val['id']]);
- }
-
-
- if (!isset($data[$val['parent_id']])) {
- $data[$val['parent_id']] = [$val['parent_id']];
- } else {
- $data[$val['parent_id']][] = $val['id'];
- }
- if (!empty($data[$val['id']])) {
- $data[$val['parent_id']] = array_merge($data[$val['parent_id']], $data[$val['id']]);
- }
- $data[$val['parent_id']] = array_unique($data[$val['parent_id']]);
- }
- if (isset($data[0])) unset($data[0]);
- if (false === $self) {
- foreach ($data as $key => $val) {
- $indx = array_search($key, $val);
- if (false !== $indx) {
- unset($val[$indx]);
- }
- if (!empty($val)) {
- $val = array_merge($val);
- }
- $data[$key] = $val;
- }
- }
-
- cache($cacheKey, $data, null, "arctype");
- }
-
- return !empty($typeid) ? $data[$typeid] : $data;
- }
- }
-
- if (!function_exists('getAllArctypeCount'))
- {
-
-
- function getAllArctypeCount($home_lang,$info,$id = 0,$view_suffix = ".htm",$aid = 0)
- {
-
-
- $method_mode = 1;
- $max_aid = \think\Db::name('archives')->max('aid');
- if ($max_aid > 100000) {
- $method_mode = 2;
- }
-
- $map_arc = [];
-
- $seo_upnext = tpCache('seo.seo_upnext');
- $web_stypeid_open = tpCache('web.web_stypeid_open');
- if (1 == $method_mode && $id) {
- if (empty($web_stypeid_open)) {
- $map_arc['typeid'] = array('in',get_arr_column($info,'typeid'));
- } else {
- $typeids_tmp = get_arr_column($info,'typeid');
- $typeids_tmp = implode(',', $typeids_tmp);
- $map_arc[] = \think\Db::raw(" ( typeid IN ({$typeids_tmp}) OR CONCAT(',', stypeid, ',') LIKE '%,{$id},%' ) ");
- }
- }
-
- static $new_channel = null;
- if (null === $new_channel) {
- $allow_release_channel = config('global.allow_release_channel');
- $arctypeRow = \think\Db::name('arctype')->field('channeltype,current_channel')->select();
- foreach ($arctypeRow as $key => $val) {
- if (in_array($val['channeltype'], $allow_release_channel)) {
- $new_channel[] = $val['channeltype'];
- }
- if (in_array($val['current_channel'], $allow_release_channel)) {
- $new_channel[] = $val['current_channel'];
- }
- }
- $new_channel = array_unique($new_channel);
- }
- !empty($new_channel) && $map_arc['a.channel'] = ['IN', $new_channel];
- $map_arc['a.arcrank'] = ['egt', 0];
- $map_arc['a.status'] = 1;
- $map_arc['a.is_del'] = 0;
- $map_arc['a.lang'] = $home_lang;
-
- if (is_dir('./weapp/TimingTask/')) {
- $TimingTaskRow = model('Weapp')->getWeappList('TimingTask');
- if (!empty($TimingTaskRow['status']) && 1 == $TimingTaskRow['status']) {
- $map_arc['a.add_time'] = array('elt', getTime());
- }
- }
-
-
- if (1 == $method_mode) {
- $count_type = [];
- $archivesList = \think\Db::name('archives')->alias('a')->field("typeid,stypeid")->where($map_arc)->order('typeid asc')->select();
- foreach ($archivesList as $key => $val) {
- if (!isset($count_type[$val['typeid']])) {
- $count_type[$val['typeid']] = [
- 'typeid' => $val['typeid'],
- 'count' => 1,
- ];
- } else {
- $count_type[$val['typeid']]['count']++;
- }
-
-
- if (!empty($web_stypeid_open) && !empty($val['stypeid'])) {
- $stypeids = explode(',', $val['stypeid']);
- $arr_index = array_search($val['typeid'], $stypeids);
- if (is_numeric($arr_index) && 0 <= $arr_index) {
- unset($stypeids[$arr_index]);
- }
- foreach ($stypeids as $_k => $_v) {
- if (!isset($count_type[$_v])) {
- $count_type[$_v] = [
- 'typeid' => $_v,
- 'count' => 1,
- ];
- } else {
- $count_type[$_v]['count']++;
- }
- }
- }
- }
- }
-
- $db = new \think\Db;
- $pagetotal = 0;
- $arctypeAllSub = arctypeAllSub();
- $info2 = $tplData = [];
- $info = convert_arr_key($info,'typeid');
- foreach ($info as $k => $v) {
-
- if ($v['is_part'] == 1 || 'ask' == $v['nid']) {
- $dir = ROOT_PATH . trim($v['dirpath'], '/');
- if (!empty($v['dirpath']) && true == is_dir($dir)) {
- deldir_html($dir);
- }
- continue;
- }
-
- if (1 == $method_mode) {
- if (!isset($info[$v['typeid']]['count'])){
- $v['count'] = 0;
- }else{
- $v['count'] = intval($info[$v['typeid']]['count']);
- }
- if (isset($count_type[$v['typeid']])){
- $v['count'] += $count_type[$v['typeid']]['count'];
- }
-
-
- if ($v['parent_id'] && !in_array($v['current_channel'], [6,8]) && isset($info[$v['parent_id']]) && $v['current_channel'] == $info[$v['parent_id']]['current_channel']){
- if (isset($info[$v['parent_id']]['count'])) {
- $info[$v['parent_id']]['count'] += intval($v['count']);
- }else{
- $info[$v['parent_id']]['count'] = intval($v['count']);
- }
- }
- }
-
-
-
- if (empty($seo_upnext) && ( (!empty($id) && $v['typeid'] != $id) || (empty($id) && !empty($v['parent_id'])) ) ){
- continue;
- }
-
- $tag_attr_arr = [];
- if (!isset($tplData[$v['templist']])) {
- $tpl = !empty($v['templist']) ? str_replace('.'.$view_suffix, '',$v['templist']) : 'lists_'. $v['nid'];
- $template_html = "./template/".TPL_THEME."pc/".$tpl.".htm";
- $content = @file_get_contents($template_html);
- if ($content) {
- preg_match_all('/\{eyou:list(\s+)?(.*)\}/i', $content, $matchs);
- if (!empty($matchs[0][0])) {
- $tag_attr = !empty($matchs[2][0]) ? $matchs[2][0] : '';
- if (!empty($tag_attr)) {
- $tag_attr = preg_replace('/([a-z]+)(\s*)=(\s*)([\'|\"]?)([^ \f\n\r\t\v\'\"]+)([\'|\"]?)/i', '${1}=\'${5}\'', $tag_attr);
- preg_match_all('/([0-9a-z_-]+)=\'([^\']+)\'/i', $tag_attr, $attr_matchs);
- $attr_keys = !empty($attr_matchs[1]) ? $attr_matchs[1] : [];
- $attr_vals = !empty($attr_matchs[2]) ? $attr_matchs[2] : [];
- if (!empty($attr_keys)) {
- foreach ($attr_keys as $_ak => $_av) {
- $tag_attr_arr[$_av] = $attr_vals[$_ak];
- }
-
- if (!empty($tag_attr_arr['loop'])) $tag_attr_arr['pagesize'] = intval($tag_attr_arr['loop']);
- $tag_attr_arr['pagesize'] = !empty($tag_attr_arr['pagesize']) ? intval($tag_attr_arr['pagesize']) : 10;
-
- if (!empty($tag_attr_arr['modelid'])) $tag_attr_arr['channelid'] = intval($tag_attr_arr['modelid']);
-
- if (empty($tag_attr_arr['ordermode'])) {
- if (!empty($tag['orderWay'])) {
- $tag_attr_arr['ordermode'] = $tag_attr_arr['orderWay'];
- } else {
- $tag_attr_arr['ordermode'] = !empty($tag_attr_arr['orderway']) ? $tag_attr_arr['orderway'] : 'desc';
- }
- }
- }
- }
- $tag_attr_arr['orderby'] = !empty($tag_attr_arr['orderby']) ? $tag_attr_arr['orderby'] : "";
- $tag_attr_arr['ordermode'] = !empty($tag_attr_arr['ordermode']) ? $tag_attr_arr['ordermode'] : "desc";
- $tplData[$v['templist']] = $tag_attr_arr;
- } else {
- $tplData[$v['templist']]['count'] = -1;
- }
- }
- }
- $tplDataInfo = !empty($tplData[$v['templist']]) ? $tplData[$v['templist']] : [];
-
- if (2 == $method_mode) {
- $map_arc2 = $map_arc;
- if (empty($web_stypeid_open)) {
- $map_arc2['a.typeid'] = array('in', $arctypeAllSub[$v['typeid']]);
- } else {
- $stypeid_where = "";
- $typeid_str = implode(',', $arctypeAllSub[$v['typeid']]);
- foreach ($arctypeAllSub[$v['typeid']] as $_k => $_v) {
- $stypeid_where .= " OR CONCAT(',', a.stypeid, ',') LIKE '%,{$_v},%' ";
- }
- $map_arc2[] = $db::raw(" (a.typeid IN ({$typeid_str}) {$stypeid_where}) ");
- }
-
- $v['count'] = 0;
- if (!in_array($v['current_channel'], [6,8])) {
- $v['count'] = $db::name('archives')->alias('a')->where($map_arc2)->count('aid');
- }
- }
-
- if (in_array($v['current_channel'], [6,8])){
- $v['pagesize'] = 1;
- $v['pagetotal'] = 1;
- $pagetotal += $v['pagetotal'];
- }else{
- if (!empty($tplDataInfo)) {
- $count = !empty($tplDataInfo['count']) ? $tplDataInfo['count'] : 0;
- if (-1 == $count) {
- $v['count'] = 1;
- } else {
- $pagesize = !empty($tplDataInfo['pagesize']) ? $tplDataInfo['pagesize'] : 0;
- $channelid = !empty($tplDataInfo['channelid']) ? $tplDataInfo['channelid'] : 0;
- if (!empty($channelid)) {
- $map_arc['a.channel'] = $channelid;
- if (isset($map_arc['a.typeid'])) {
- unset($map_arc['a.typeid']);
- }
- if (isset($map_arc[0])) {
- foreach ($map_arc as $_k => $_v) {
- if (is_numeric($_k) && stristr($_v, 'stypeid')) {
- unset($map_arc[$_k]);
- }
- }
- }
- $v['count'] = $db::name('archives')->alias('a')->where($map_arc)->count();
- }
- if ($aid) {
- $orderby = !empty($tplDataInfo['orderby']) ? $tplDataInfo['orderby'] : '';
- $ordermode = !empty($tplDataInfo['ordermode']) ? $tplDataInfo['ordermode'] : 'desc';
- }
- }
- }
- $v['pagesize'] = !empty($pagesize) ? $pagesize : 10;
- $v['pagetotal'] = !empty($v['count']) ? (int)ceil($v['count'] / $v['pagesize']) : 1;
- $pagetotal += $v['pagetotal'];
- }
- $v['orderby'] = !empty($orderby) ? $orderby : "";
- $v['ordermode'] = !empty($ordermode) ? $ordermode : "desc";
-
- $info2[] = $v;
- }
- return ["info"=>$info2, "pagetotal"=>$pagetotal];
- }
- }
-
-
- if (!function_exists('deldir_html'))
- {
- function deldir_html($dir = '')
- {
-
- $fileArr = glob($dir.'/*.html');
- if (!empty($fileArr)) {
- foreach ($fileArr as $key => $val) {
- !empty($val) && @unlink($val);
- }
- }
-
- $fileArr = glob($dir.'/*');
- if(empty($fileArr)){
- rmdir($dir);
- }
- return true;
- }
- }
-
-
-
- if (!function_exists('getAllArchivesAid'))
- {
- function getAllArchivesAid($typeid = 0, $home_lang = '', $startid = 0,$endid = 0){
- empty($home_lang) && $home_lang = get_current_lang();
- $map = [];
- if (!empty($typeid)){
- $id_arr = [$typeid];
- getAllChild($id_arr,$typeid,2);
- $map['typeid'] = ['in',$id_arr];
- }
- if (!empty($startid) && !empty($endid)){
- $map['aid'] = ['between',[$startid,$endid]];
- }else if(!empty($startid)){
- $map['aid'] = ['egt',$startid];
- }else if(!empty($endid)){
- $map['aid'] = ['elt',$endid];
- }
-
- static $new_channel = null;
- if (null === $new_channel) {
- $allow_release_channel = config('global.allow_release_channel');
- $arctypeRow = \think\Db::name('arctype')->field('channeltype,current_channel')->select();
- foreach ($arctypeRow as $key => $val) {
- if (in_array($val['channeltype'], $allow_release_channel)) {
- $new_channel[] = $val['channeltype'];
- }
- if (in_array($val['current_channel'], $allow_release_channel)) {
- $new_channel[] = $val['current_channel'];
- }
- }
- $new_channel = array_unique($new_channel);
- }
- !empty($new_channel) && $map['channel'] = ['IN', $new_channel];
- $map['arcrank'] = ['egt', 0];
- $map['status'] = 1;
- $map['is_del'] = 0;
- $map['lang'] = $home_lang;
-
- if (is_dir('./weapp/TimingTask/')) {
- $TimingTaskRow = model('Weapp')->getWeappList('TimingTask');
- if (!empty($TimingTaskRow['status']) && 1 == $TimingTaskRow['status']) {
- $map['add_time'] = array('elt', getTime());
- }
- }
-
- $row = \think\Db::name('archives')
- ->field('aid,typeid,channel')
- ->where($map)
- ->order('aid asc')
- ->select();
- $aid_arr = $typeid_arr = $channel_arr = [];
- foreach ($row as $key => $val) {
- array_push($aid_arr, $val['aid']);
- if (!in_array($val['typeid'], $typeid_arr)) {
- array_push($typeid_arr, $val['typeid']);
- }
- $channel_arr[$val['channel']][] = $val['aid'];
- }
-
- return [
- 'aid_arr' => $aid_arr,
- 'typeid_arr' => $typeid_arr,
- 'channel_arr' => $channel_arr,
- ];
- }
- }
-
- if (!function_exists('getAllArchives'))
- {
-
- function getAllArchives($home_lang,$id,$aid = ''){
- $map = [];
- if(!empty($aid)){
- if (is_array($aid)) {
- $map['a.aid'] = ['in',$aid];
- } else {
- $map['a.aid'] = $aid;
- }
- }else if (!empty($id)){
- $id_arr = [$id];
- getAllChild($id_arr,$id,2);
- $map['a.typeid'] = ['in',$id_arr];
- }
-
-
- $new_channel = cache("application_common_getAllArchives_new_channel");
- if(empty($new_channel)){
- $new_channel = [];
- $allow_release_channel = config('global.allow_release_channel');
- $arctypeList = \think\Db::name('arctype')->field('channeltype,current_channel')->select();
- foreach ($arctypeList as $key => $val) {
- if (in_array($val['channeltype'], $allow_release_channel)) {
- $new_channel[] = $val['channeltype'];
- }
- if (in_array($val['current_channel'], $allow_release_channel)) {
- $new_channel[] = $val['current_channel'];
- }
- }
- $new_channel = array_unique($new_channel);
- cache("application_common_getAllArchives_new_channel", $new_channel, null, 'arctype');
- }
- !empty($new_channel) && $map['a.channel'] = ['IN', $new_channel];
-
- $map['a.is_jump'] = 0;
- $map['a.status'] = 1;
- $map['a.is_del'] = 0;
- $map['a.lang'] = $home_lang;
- $info = \think\Db::name('archives')->field('a.*')
- ->alias('a')
- ->where($map)
- ->select();
- $info = getAllContent($info);
-
-
- $arctypeRow = cache("application_common_getAllArchives_arctypeRow");
- if(empty($arctypeRow)){
- $arctypeRow = \think\Db::name('arctype')->field('c.*, a.*, a.id as typeid')
- ->alias('a')
- ->where(['a.lang'=>$home_lang])
- ->join('__CHANNELTYPE__ c', 'c.id = a.current_channel', 'LEFT')
- ->getAllWithIndex('typeid');
- cache("application_common_getAllArchives_arctypeRow", $arctypeRow, null, 'arctype');
- }
-
- return [
- 'info' => $info,
- 'arctypeRow' => $arctypeRow,
- ];
- }
- }
-
- if (!function_exists('getPreviousArchives'))
- {
-
- function getPreviousArchives($home_lang,$id,$aid = 0){
- $map = [];
- if(!empty($aid)){
- $map['a.aid'] = ['lt',$aid];
- }
- if (!empty($id)){
- $id_arr = [$id];
- getAllChild($id_arr,$id,2);
- $map['a.typeid'] = ['in',$id_arr];
- }
-
- static $new_channel = null;
- if (null === $new_channel) {
- $allow_release_channel = config('global.allow_release_channel');
- $arctypeRow = \think\Db::name('arctype')->field('channeltype,current_channel')->select();
- foreach ($arctypeRow as $key => $val) {
- if (in_array($val['channeltype'], $allow_release_channel)) {
- $new_channel[] = $val['channeltype'];
- }
- if (in_array($val['current_channel'], $allow_release_channel)) {
- $new_channel[] = $val['current_channel'];
- }
- }
- $new_channel = array_unique($new_channel);
- }
- !empty($new_channel) && $map['a.channel'] = ['IN', $new_channel];
- $map['a.lang'] = $home_lang;
- $map['a.is_jump'] = 0;
- $map['a.is_del'] = 0;
- $map['a.status'] = 1;
- $info = \think\Db::name('archives')->field('a.*')
- ->alias('a')
- ->where($map)
- ->order("a.aid desc")
- ->limit(1)
- ->select();
- $info = getAllContent($info);
-
-
- $arctypeRow = \think\Db::name('arctype')->field('c.*, a.*, a.id as typeid')
- ->alias('a')
- ->where(['a.lang'=>$home_lang])
- ->join('__CHANNELTYPE__ c', 'c.id = a.current_channel', 'LEFT')
- ->cache(true,EYOUCMS_CACHE_TIME,"arctype")
- ->getAllWithIndex('typeid');
-
- return [
- 'info' => $info,
- 'arctypeRow' => $arctypeRow,
- ];
- }
- }
-
- if (!function_exists('getNextArchives'))
- {
-
- function getNextArchives($home_lang,$id,$aid = 0){
- $map = [];
- if(!empty($aid)){
- $map['a.aid'] = ['gt',$aid];
- }
- if (!empty($id)){
- $id_arr = [$id];
- getAllChild($id_arr,$id,2);
- $map['a.typeid'] = ['in',$id_arr];
- }
-
- static $new_channel = null;
- if (null === $new_channel) {
- $allow_release_channel = config('global.allow_release_channel');
- $arctypeRow = \think\Db::name('arctype')->field('channeltype,current_channel')->select();
- foreach ($arctypeRow as $key => $val) {
- if (in_array($val['channeltype'], $allow_release_channel)) {
- $new_channel[] = $val['channeltype'];
- }
- if (in_array($val['current_channel'], $allow_release_channel)) {
- $new_channel[] = $val['current_channel'];
- }
- }
- $new_channel = array_unique($new_channel);
- }
- !empty($new_channel) && $map['a.channel'] = ['IN', $new_channel];
- $map['a.lang'] = $home_lang;
- $map['a.is_jump'] = 0;
- $map['a.is_del'] = 0;
- $map['a.status'] = 1;
- $info = \think\Db::name('archives')->field('a.*')
- ->alias('a')
- ->where($map)
- ->order("a.aid asc")
- ->limit(1)
- ->select();
- $info = getAllContent($info);
-
-
- $arctypeRow = \think\Db::name('arctype')->field('c.*, a.*, a.id as typeid')
- ->alias('a')
- ->where(['a.lang'=>$home_lang])
- ->join('__CHANNELTYPE__ c', 'c.id = a.current_channel', 'LEFT')
- ->cache(true,EYOUCMS_CACHE_TIME,"arctype")
- ->getAllWithIndex('typeid');
-
- return [
- 'info' => $info,
- 'arctypeRow' => $arctypeRow,
- ];
- }
- }
-
- if (!function_exists('getAllContent'))
- {
-
- function getAllContent($archivesList = []){
- $contentList = [];
- $db = new \think\Db;
- $channeltype_list = config('global.channeltype_list');
- $arr = group_same_key($archivesList, 'channel');
- foreach ($arr as $nid => $list) {
- $table = array_search($nid, $channeltype_list);
- if (!empty($table)) {
- $aids = get_arr_column($list, 'aid');
- $row = $db::name($table.'_content')->field('*')
- ->where(['aid'=>['IN', $aids]])
- ->select();
- $result = [];
- foreach ($row as $_k => $_v) {
- unset($_v['id']);
- unset($_v['add_time']);
- unset($_v['update_time']);
- $result[$_v['aid']] = $_v;
- }
-
- $contentList += $result;
- }
- }
-
- $firstFieldData = current($contentList);
- foreach ($archivesList as $key => $val) {
-
-
- $table = array_search($val['channel'], $channeltype_list);
- if (empty($table)) {
- unset($archivesList[$key]);
- continue;
- }
-
-
-
- if (!isset($contentList[$val['aid']])) {
- $contentList[$val['aid']] = [];
- if (!empty($firstFieldData)) {
- foreach ($firstFieldData as $k2 => $v2) {
- if (in_array($k2, ['aid'])) {
- $contentList[$val['aid']][$k2] = $val[$k2];
- } else {
- $contentList[$val['aid']][$k2] = '';
- }
- }
- }
- }
-
- $val = array_merge($val, $contentList[$val['aid']]);
- $archivesList[$key] = $val;
- }
-
- return $archivesList;
- }
- }
-
- if (!function_exists('getAllTags'))
- {
-
- function getAllTags($aid_arr = []){
- $map = [];
- $info = [];
- if (!empty($aid_arr)){
- $map['aid'] = ['in',$aid_arr];
- }
- $result = \think\Db::name('taglist')->field("aid,tag")->where($map)->select();
- if ($result) {
- foreach ($result as $key => $val) {
- if (!isset($info[$val['aid']])) $info[$val['aid']] = array();
- array_push($info[$val['aid']], $val['tag']);
- }
- }
-
- return $info;
- }
- }
-
- if (!function_exists('getAllAttrInfo'))
- {
-
-
- function getAllAttrInfo($channel_aids_arr = []){
- $info = [];
- foreach ($channel_aids_arr as $channel => $aids) {
- if (2 == $channel) {
- $ProductImg = new \app\home\model\ProductImg;
- $info['product_img'] = $ProductImg->getProImg($aids);
- $ProductAttr = new \app\home\model\ProductAttr;
- $info['product_attr'] = $ProductAttr->getProAttr($aids);
- } else if (3 == $channel) {
- $ImagesUpload = new \app\home\model\ImagesUpload;
- $info['images_upload'] = $ImagesUpload->getImgUpload($aids);
- } else if (4 == $channel) {
- $DownloadFile = new \app\home\model\DownloadFile;
- $info['download_file'] = $DownloadFile->getDownFile($aids);
- }
- }
- return $info;
- }
- }
-
- if (!function_exists('getOneAttrInfo'))
- {
-
-
- function getOneAttrInfo($info = [], $aid = 0){
- $arr = [];
-
- if (isset($info['product_img'][$aid])) {
- $arr['product_img'][$aid] = $info['product_img'][$aid];
- }
- if (isset($info['product_attr'][$aid])) {
- $arr['product_attr'][$aid] = $info['product_attr'][$aid];
- }
- if (isset($info['images_upload'][$aid])) {
- $arr['images_upload'][$aid] = $info['images_upload'][$aid];
- }
- if (isset($info['download_file'][$aid])) {
- $arr['download_file'][$aid] = $info['download_file'][$aid];
- }
-
- return $arr;
- }
- }
-
- if (!function_exists('getOrderBy'))
- {
-
-
- function getOrderBy($orderby,$ordermode,$isrand=false){
- switch ($orderby) {
- case 'hot':
- case 'click':
- $orderby = "a.click {$ordermode}, a.add_time desc";
- break;
- case 'real_sales':
- $orderby = "a.sales_num {$ordermode}, a.add_time desc";
- break;
- case 'sales_num':
- $orderby = "a.sales_all {$ordermode}, a.add_time desc";
- break;
- case 'users_price':
- $orderby = "a.users_price {$ordermode}, a.add_time desc";
- break;
- case 'id':
- case 'aid':
- $orderby = "a.aid {$ordermode}";
- break;
-
- case 'now':
- case 'new':
- case 'pubdate':
- case 'add_time':
- $orderby = "a.add_time {$ordermode}";
- break;
-
- case 'update_time':
- $orderby = "a.update_time {$ordermode}";
- break;
-
- case 'sortrank':
- case 'weight':
- case 'sort_order':
- $orderby = "a.sort_order {$ordermode}, a.add_time desc";
- break;
-
- case 'rand':
- if (true === $isrand) {
- $orderby = "rand()";
- } else {
- $orderby = "a.add_time {$ordermode}";
- }
- break;
-
- default:
- {
- if (empty($orderby)) {
- $orderby = 'a.sort_order asc, a.add_time desc';
- } elseif (trim($orderby) != 'rand()') {
- $orderbyArr = explode(',', $orderby);
- foreach ($orderbyArr as $key => $val) {
- $val = trim($val);
- if (preg_match('/^([a-z]+)\./i', $val) == 0) {
- $val = 'a.'.$val;
- $orderbyArr[$key] = $val;
- }
- }
- $orderby = implode(',', $orderbyArr);
- }
- break;
- }
- }
-
- return $orderby;
- }
- }
-
- if (!function_exists('getLocationPages'))
- {
-
-
- function getLocationPages($tid,$aid,$order){
- $map_arc = [];
- if (!empty($tid)){
- $id_arr = [$tid];
- getAllChild($id_arr,$tid,2);
- $map_arc['typeid'] = ['in',$id_arr];
- }
- $map_arc['is_del'] = 0;
- $map_arc['status'] = 1;
- $result = \think\Db::name('archives')->alias('a')->field("a.aid")->where($map_arc)->orderRaw($order)->select();
-
- foreach ($result as $key=>$val){
- if ($aid == $val['aid']){
- return $key + 1;
- }
- }
- return false;
- }
- }
-
- if (!function_exists('auto_hide_index'))
- {
-
-
- function auto_hide_index($url, $seo_inlet = null) {
- static $web_adminbasefile = null;
- if (null === $web_adminbasefile) {
- $web_adminbasefile = tpCache('web.web_adminbasefile');
- $web_adminbasefile = !empty($web_adminbasefile) ? $web_adminbasefile : ROOT_DIR.'/login.php';
- }
- $url = str_replace($web_adminbasefile, ROOT_DIR.'/index.php', $url);
- null === $seo_inlet && $seo_inlet = config('ey_config.seo_inlet');
- if (1 == $seo_inlet) {
- $url = str_replace('/index.php/', '/', $url);
- }
- return $url;
- }
- }
-
- if (!function_exists('getArchivesField'))
- {
-
-
- function getArchivesField($aid = 0, $fieldName = 'aid') {
- $value = '';
- if (0 < intval($aid)) {
- if ('arcurl' == $fieldName) {
- $row = \think\Db::name('archives')->where(['aid'=>$aid])->find();
- $value = get_arcurl($row);
- } else {
- $value = \think\Db::name('archives')->where(['aid'=>$aid])->getField($fieldName);
- if ('litpic' == $fieldName) {
- $value = handle_subdir_pic($value);
- }
- }
- }
-
- return $value;
- }
- }
-
- if (!function_exists('GetUsersLatestData'))
- {
-
-
- function GetUsersLatestData($users_id = null)
- {
- $users_id = empty($users_id) ? session('users_id') : $users_id;
- if(!empty($users_id)) {
-
- $field = 'b.*, b.discount as level_discount, a.*';
- $users = \think\Db::name('users')->field($field)
- ->alias('a')
- ->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
- ->where([
- 'a.users_id' => $users_id,
- 'a.is_activation' => 1,
- 'a.is_del' => 0,
- ])->find();
-
- if (empty($users)) return false;
-
-
- unset($users['paypwd']);
-
- $users['users_money'] = unifyPriceHandle($users['users_money']);
-
- $users['head_pic'] = get_head_pic(htmlspecialchars_decode($users['head_pic']), false, $users['sex']);
-
- $users['nickname'] = empty($users['nickname']) ? $users['username'] : $users['nickname'];
-
- $users['password'] = empty($users['password']) && !empty($users['thirdparty']) ? 1 : 1;
-
- $LevelData = [];
- if (intval($users['level_maturity_days']) >= 36600) {
- $users['maturity_code'] = 1;
- $users['maturity_date'] = '终身';
- } else if (0 === intval($users['open_level_time']) && 0 === intval($users['level_maturity_days'])) {
- $users['maturity_code'] = 0;
- $users['maturity_date'] = '未升级会员';
- } else {
-
- $days = $users['open_level_time'] + (intval($users['level_maturity_days']) * 86400);
- $days = ceil(($days - getTime()) / 86400);
- if (0 >= $days) {
-
- $LevelData = model('EyouUsers')->UpUsersLevelData($users_id);
- $users['maturity_code'] = 2;
- $users['maturity_date'] = '未升级会员';
- } else {
- $users['maturity_code'] = 3;
- $users['maturity_date'] = $days . ' 天';
- }
- }
-
-
- if (is_dir('./weapp/DealerPlugin/')) {
-
- $data = model('Weapp')->getWeappList('DealerPlugin');
- if (!empty($data['status']) && 1 == $data['status']) {
-
- $users['allowApply'] = (empty($users['is_dealer']) && !empty($users['top_users_id']) && !empty($users['top_dealer_id'])) ? 0 : 1;
-
- if (!empty($users['users_id'])) {
- $where = [
- 'users_id' => $users['users_id'],
- ];
- $dealer = \think\Db::name('weapp_dealer')->where($where)->find();
- $users['dealer'] = !empty($dealer) ? $dealer : false;
- }
-
- if (isMobile()) {
- $dealerParam = cookie('dealerParam') ? cookie('dealerParam') : session('dealerParam');
- if (!empty($dealerParam)) {
- $dealerPluginLogic = new \app\plugins\logic\DealerPluginLogic($users);
- $dealerPluginLogic->dealerAction('h5', 'bindUsers');
- }
-
- $users['dealer']['dealer_pic'] = get_default_pic($data['config']['litpic']);
- }
- }
- }
-
-
- $users['verify'] = [];
- $weappInfo = model('ShopPublicHandle')->getWeappVerifyInfo();
- if (!empty($weappInfo)) {
-
- $verifyLogic = new \app\plugins\logic\VerifyLogic($users);
- $users['verify'] = $verifyLogic->getVerifyStaff($weappInfo);
- }
-
-
- $scoreConfig = getUsersConfigData('score');
- if (!empty($scoreConfig['score_login_points_open']) && 1 == $scoreConfig['score_login_points_open'] && !empty($users_id)) {
-
- $times = getTime();
-
- $log_time = date('Ymd');
-
- $usersLoginLog = Db::name('users_login_log')->where(['users_id'=>$users_id])->find();
-
- if (empty($usersLoginLog) || intval($log_time) !== intval($usersLoginLog['log_time'])) {
-
- $insert = [
- 'type' => 10,
- 'users_id' => $users_id,
- 'score' => $scoreConfig['score_login_points_value'],
- 'info' => '登录赠送' . $scoreConfig['score_name'],
- 'remark' => '登录赠送' . $scoreConfig['score_name'],
- ];
- addConsumObtainScores($insert, 2, true);
-
- if (!empty($usersLoginLog['log_id'])) {
- $update = [
- 'users_id' => $users_id,
- 'log_time' => $log_time,
- 'log_count' => Db::Raw('log_count+1'),
- 'update_time' => $times,
- ];
- Db::name('users_login_log')->where(['log_id' => $usersLoginLog['log_id']])->update($update);
- } else {
- $insert = [
- 'users_id' => $users_id,
- 'log_time' => $log_time,
- 'log_count' => 1,
- 'add_time' => $times,
- 'update_time' => $times,
- ];
- Db::name('users_login_log')->insert($insert);
- }
-
- $users['scores'] = intval($users['scores']) + intval($scoreConfig['score_login_points_value']);
- }
- }
-
-
- $LatestData = array_merge($users, $LevelData);
-
-
- session('users', $LatestData);
- session('users_id', $LatestData['users_id']);
- cookie('users_id', $LatestData['users_id']);
-
-
- return $LatestData;
- } else {
-
- session('users_id', null);
- session('users', null);
- cookie('users_id', null);
- return false;
- }
- }
- }
-
- if (!function_exists('GetTotalArc'))
- {
-
-
- function GetTotalArc($typeid = 0)
- {
- if (empty($typeid)) {
- return 0;
- } else {
- $cache_key = md5("common-GetTotalArc-{$typeid}");
- $count = cache($cache_key);
- if (empty($count)) {
- $row = model('Arctype')->getHasChildren($typeid);
- if (empty($row)) return 0;
-
- $typeids = array_keys($row);
- $allow_release_channel = config('global.allow_release_channel');
- $condition = [
- 'typeid' => ['IN', $typeids],
- 'channel' => ['IN', $allow_release_channel],
- 'arcrank' => ['gt', -1],
- 'status' => 1,
- 'is_del' => 0,
- ];
-
- if (is_dir('./weapp/TimingTask/')) {
- $TimingTaskRow = model('Weapp')->getWeappList('TimingTask');
- if (!empty($TimingTaskRow['status']) && 1 == $TimingTaskRow['status']) {
- $condition['add_time'] = ['elt', getTime()];
- }
- }
-
- $count = \think\Db::name('archives')->where($condition)->count('aid');
- cache($cache_key, $count, null, 'archives');
- }
-
- return intval($count);
- }
- }
- }
-
- if (!function_exists('GetTagIndexRanking'))
- {
-
-
- function GetTagIndexRanking($limit = 5, $field = 'id, tag')
- {
- $order = 'weekcc desc, monthcc desc';
- $limit = '0, ' . $limit;
- $list = \think\Db::name('tagindex')->field($field)->order($order)->limit($limit)->select();
-
- return $list;
- }
- }
-
- if (!function_exists('weapptaglib'))
- {
-
-
- function weapptaglib($weapp_code = '', $act = '', $vars = [])
- {
- $list = '';
- if (empty($weapp_code) || empty($act) || !is_dir("./weapp/{$weapp_code}/")) {
- return '';
- }
-
- $is_exist = false;
- if (file_exists("./weapp/{$weapp_code}/logic/{$weapp_code}Logic.php")) {
- $class = '\weapp\\'.$weapp_code.'\logic\\'.$weapp_code.'Logic';
- if (method_exists($class, $act)) {
- $is_exist = true;
- $ctl = new $class();
- $list = $ctl->$act($vars);
- }
- }
- if (!$is_exist) {
- $class = '\weapp\\'.$weapp_code.'\controller\\'.$weapp_code;
- $ctl = new $class();
- $list = $ctl->$act($vars);
- }
-
- return $list;
- }
- }
-
- if (!function_exists('rand_username'))
- {
-
-
- function rand_username($username = '', $prefix = 'U', $includenumber = 2)
- {
- if (empty($username)) {
- $username = $prefix . get_rand_str(6, 0, $includenumber);
- }
- $count = \think\Db::name('users')->where('username', $username)->count();
- if (!empty($count)) {
- $username = $prefix . get_rand_str(6, 0, $includenumber);
- return rand_username($username, $prefix, $includenumber);
- }
-
- return $username;
- }
- }
-
- if (!function_exists('update_username')) {
-
-
- function update_username($users_id, $is_update = true)
- {
- $username = '';
- if (!empty($users_id)) {
- if (6 > strlen($users_id)) {
- $users_id = sprintf("%06d", $users_id);
- }
- $username = 'U'.$users_id;
- $username = rand_username($username);
- if ($is_update) {
- \think\Db::name('users')->where('users_id', $users_id)->update(['username'=>$username,'update_time'=>getTime()]);
- }
- }
-
- return $username;
- }
- }
-
- if (!function_exists('pay_success_logic'))
- {
-
-
- function pay_success_logic($users_id = 0, $order_code = '', $pay_details = [], $paycode = 'alipay', $notify = true, $users = [])
- {
- $pay_method_arr = config('global.pay_method_arr');
-
- $where = [
- 'order_code' => $order_code,
- ];
- !empty($users_id) && $where['users_id'] = intval($users_id);
- $orderData = \think\Db::name('shop_order')->where($where)->find();
-
- if (empty($orderData)) {
- return [
- 'code' => 0,
- 'msg' => '该订单不存在!',
- ];
- }
- else if (0 == $orderData['order_status']) {
- $saveData = [
- 'order_status' => 1,
- 'pay_details' => serialize($pay_details),
- 'pay_time' => getTime(),
- 'update_time' => getTime(),
- ];
- if ('wechat' != $paycode) {
- $saveData['pay_name'] = $paycode;
- $saveData['wechat_pay_type'] = '';
- }
- $where = [
- 'order_id' => $orderData['order_id'],
- 'users_id' => $orderData['users_id'],
- ];
- $ret = \think\Db::name('shop_order')->where($where)->update($saveData);
- if (false !== $ret) {
-
- $orderData = array_merge($orderData, $saveData);
-
- if (!empty($paycode) && isset($pay_method_arr[$paycode])){
- $orderData['pay_method'] = $pay_method_arr[$paycode];
- $actionNote = "使用{$pay_method_arr[$paycode]}完成支付";
- } else {
- $orderData['pay_method'] = '';
- $actionNote = "完成支付";
- }
-
- AddOrderAction($orderData['order_id'], $orderData['users_id'], 0, 1, 0, 1, "支付成功", $actionNote);
-
-
- SendNotifyMessage($orderData, 5, 1, 0);
-
-
- $PayModel = new \app\user\model\Pay;
- $autoSendGoods = $PayModel->afterVirtualProductPay($orderData);
-
- $data = [];
- if (false === $autoSendGoods && true === $notify) {
- $users = !empty($users) ? $users : \think\Db::name('users')->field('*')->find($orderData['users_id']);
-
- $data['email'] = GetEamilSendData(tpCache('smtp'), $users, $orderData, 1, $paycode);
-
- $data['mobile'] = GetMobileSendData(tpCache('sms'), $users, $orderData, 1, $paycode);
- }
-
-
- if ('balance' == $paycode) {
- $users = !empty($users) ? $users : \think\Db::name('users')->field('*')->find($orderData['users_id']);
- UsersMoneyRecording($order_code, $users, $orderData['order_amount'], '商品购买', 3);
- }
-
-
- $url = url('user/Shop/shop_centre');
- if (true === $autoSendGoods) {
- $msg = '支付订单完成!';
- } else {
- $msg = '支付成功,处理订单完成!';
- }
- return [
- 'code' => 1,
- 'msg' => $msg,
- 'url' => $url,
- 'data' => $data,
- ];
- }
- else {
- return [
- 'code' => 0,
- 'msg' => '支付成功,处理订单失败!',
- ];
- }
- }
- else if (1 <= $orderData['order_status'] && $orderData['order_status'] <= 3) {
- return [
- 'code' => 1,
- 'msg' => '已支付',
- ];
- }
- else if (4 == $orderData['order_status']) {
- return [
- 'code' => 0,
- 'msg' => '该订单已过期!',
- ];
- }
- else {
- return [
- 'code' => 0,
- 'msg' => '该订单不存在或已关闭!',
- ];
- }
- }
- }
-
- if (!function_exists('OrderServiceLog'))
- {
-
-
- function OrderServiceLog($ServiceId = null, $OrderId = null, $UsersId = 0, $AdminId = 0, $LogNote = '会员提交退换货申请')
- {
- if (empty($ServiceId) || empty($OrderId)) return false;
-
- $Time = getTime();
- $LogData = [
- 'service_id' => $ServiceId,
- 'order_id' => $OrderId,
- 'users_id' => $UsersId,
- 'admin_id' => $AdminId,
- 'log_note' => empty($LogNote) ? '' : $LogNote,
- 'add_time' => $Time,
- 'update_time' => $Time,
- ];
- M('shop_order_service_log')->add($LogData);
-
- }
- }
-
- if (!function_exists('UsersMoneyRecording'))
- {
-
-
- function UsersMoneyRecording($OrderCode = null, $Users = [], $UsersMoney = null, $Cause = '商品退换货', $CauseType = 2)
- {
- if (empty($OrderCode) || empty($Users) || empty($UsersMoney)) return false;
- $Time = getTime();
- $pay_method = '';
-
- if (2 == $CauseType) {
- $Status = 3;
- $Cause = $Cause . ',退还使用余额,订单号:' . $OrderCode;
- $UsersNewMoney = !empty($Users['users_money']) ? sprintf("%.2f", $Users['users_money'] += $UsersMoney) : 0;
- $pay_method = 'balance';
- } else if (3 == $CauseType) {
- $Status = 2;
- $Cause = $Cause . ',使用余额支付,订单号:' . $OrderCode;
- $UsersNewMoney = !empty($Users['users_money']) ? sprintf("%.2f", $Users['users_money'] -= $UsersMoney) : 0;
- $pay_method = 'balance';
- }
- $UsersNewMoney = !empty($Users['users_money']) ? $UsersNewMoney : Db::name('users')->where('users_id', $Users['users_id'])->value('users_money');
- $MoneyData = [
- 'users_id' => $Users['users_id'],
- 'money' => $UsersMoney,
- 'users_money' => $UsersNewMoney,
- 'cause' => $Cause,
- 'cause_type' => $CauseType,
- 'status' => $Status,
- 'pay_method' => $pay_method,
- 'pay_details' => '',
- 'order_number' => $OrderCode,
- 'add_time' => $Time,
- 'update_time' => $Time,
- ];
- Db::name('users_money')->insert($MoneyData);
- }
- }
-
- if (!function_exists('GetScoreArray')) {
-
-
- function GetScoreArray($total_score = 0)
- {
- $Result = 0;
- if (empty($total_score)) return $Result;
- if (in_array($total_score, [1])) {
- $Result = 5;
- } else if (in_array($total_score, [2])) {
- $Result = 3;
- } else if (in_array($total_score, [3])) {
- $Result = 1;
- }
- return $Result;
- }
- }
-
- if (!function_exists('getTrueTypeid')) {
-
-
- function getTrueTypeid($typeid = '')
- {
-
- if (!empty($typeid) && strval($typeid) != strval(intval($typeid))) {
- $typeid = \think\Db::name('arctype')->where([
- 'dirname' => $typeid,
- 'lang' => get_current_lang(),
- ])->cache(true,EYOUCMS_CACHE_TIME,"arctype")
- ->getField('id');
- }
-
-
- return $typeid;
- }
- }
-
- if (!function_exists('getTrueAid')) {
-
-
- function getTrueAid($aid = '')
- {
-
- if (!empty($aid) && strval($aid) != strval(intval($aid))) {
- $aid = \think\Db::name('archives')->where([
- 'htmlfilename' => $aid,
- 'lang' => get_current_lang(),
- ])->cache(true,EYOUCMS_CACHE_TIME,"archives")
- ->getField('aid');
- }
-
-
- return intval($aid);
- }
- }
-
- if (!function_exists('SendNotifyMessage'))
- {
-
-
- function SendNotifyMessage($GetContentArr = [], $SendScene = 0, $AdminID = 0, $UsersID = 0, $UsersName = null)
- {
-
- if (empty($GetContentArr) || empty($SendScene)) return false;
-
-
- $tpl_where = [
-
- 'send_scene' => $SendScene
- ];
- $Notice = M('users_notice_tpl')->where($tpl_where)->find();
-
- $times = getTime();
- $homeLang = get_home_lang();
-
- if (!empty($Notice) && !empty($Notice['tpl_title']) && 1 === intval($Notice['is_open'])) {
- if (in_array($SendScene, [1, 5, 20])) {
- $ContentArr = [];
-
- if (1 === intval($SendScene)) {
- $ContentArr = $GetContentArr;
- }
-
- else if (5 === intval($SendScene)) {
- $ContentArr = [
- '订单编号:' . $GetContentArr['order_code'],
- '订单总额:' . $GetContentArr['order_amount'],
- '支付方式:' . $GetContentArr['pay_method'],
- '手机号:' . $GetContentArr['mobile']
- ];
- }
-
- else if (20 === intval($SendScene)) {
- $arcrank = isset($GetContentArr['arcrank']) && -1 === intval($GetContentArr['arcrank']) ? '未审核' : '自动审核';
- $ContentArr = [
- '文档标题:' . $GetContentArr['title'],
- '文档内容:' . $GetContentArr['seo_description'],
- '投稿时间:' . date('Y-m-d H:i:s', $GetContentArr['add_time']),
- '文档审核:' . $arcrank,
- ];
- }
- $Content = !empty($ContentArr) ? implode('<br/>', $ContentArr) : '';
- $ContentData = [
- 'source' => $SendScene,
- 'admin_id' => $AdminID,
- 'users_id' => $UsersID,
- 'content_title' => $Notice['tpl_title'],
- 'content' => !empty($Content) ? $Content : '',
- 'is_read' => 0,
- 'lang' => $homeLang,
- 'add_time' => $times,
- 'update_time' => $times
- ];
- M('users_notice_tpl_content')->add($ContentData);
- }
-
- else if (6 === intval($SendScene)) {
- $ContentArr = [
- '快递公司:' . $GetContentArr['express_name'],
- '快递单号:' . $GetContentArr['express_order'],
- '发货时间:' . date('Y-m-d H:i:s', $GetContentArr['express_time']),
- ];
- $Content = !empty($ContentArr) ? implode('<br/>', $ContentArr) : '';
- $ContentData = [
- 'title' => $Notice['tpl_title'],
- 'users_id' => $UsersID,
- 'usernames' => $UsersName,
- 'remark' => $Content,
- 'lang' => $homeLang,
- 'add_time' => $times,
- 'update_time' => $times
- ];
- M('users_notice')->add($ContentData);
- }
- }
- }
- }
-
- if (!function_exists('usershomeurl'))
- {
-
-
- function usershomeurl($users_id)
- {
- $usershomeurl = '';
- static $is_users_weapp = null;
- static $users_seo_pseudo = 1;
- if (is_dir('./weapp/Users/') && null === $is_users_weapp) {
- $weappInfo = \think\Db::name('weapp')->field('data,status')->where(['code' => 'Users'])->find();
- if (!empty($weappInfo['status'])) {
- $is_users_weapp = true;
- $weappInfo['data'] = unserialize($weappInfo['data']);
- $users_seo_pseudo = !empty($weappInfo['data']['seo_pseudo']) ? intval($weappInfo['data']['seo_pseudo']) : 1;
- }
- }
-
- if (true === $is_users_weapp) {
- $usershomeurl = url('plugins/Users/userask', ['id'=>$users_id], true, false, $users_seo_pseudo);
- }
-
- return $usershomeurl;
- }
- }
-
- if (!function_exists('restric_type_logic')) {
-
-
- function restric_type_logic(&$post = [], $channel = 0)
- {
- if (isset($post['restric_type'])) {
- if (!isset($post['no_vip_pay'])) $post['no_vip_pay'] = 0;
-
- if (in_array($channel, [1,5])) {
- if (empty($post['restric_type'])) {
- $post['arc_level_id'] = 0;
- $post['users_price'] = 0;
- $post['no_vip_pay'] = 0;
- $post['users_free'] = 0;
- } else if (1 == $post['restric_type']) {
- $post['arc_level_id'] = 0;
- $post['no_vip_pay'] = 0;
- $post['users_free'] = 0;
- if (empty($post['users_price']) || $post['users_price'] == 0) {
- return ['code' => 0, 'msg' => '购买价格不能为空!'];
- }
- } else if (2 == $post['restric_type']) {
- if (!empty($post['no_vip_pay'])) {
- if (empty($post['users_price']) || $post['users_price'] == 0) {
- return ['code' => 0, 'msg' => '购买价格不能为空!'];
- }
- if ($post['arc_level_id'] > 0) {
- $post['users_free'] = 1;
- }
- } else {
- if ($post['arc_level_id'] > 0) {
- $post['users_price'] = 0;
- $post['users_free'] = 1;
- }
- }
- } else if (3 == $post['restric_type']) {
- $post['no_vip_pay'] = 0;
- $post['users_free'] = 0;
- if (empty($post['users_price']) || $post['users_price'] == 0) {
- return ['code' => 0, 'msg' => '购买价格不能为空!'];
- }
- }
- }
-
- else if (4 == $channel) {
- if (empty($post['restric_type'])) {
- $post['arc_level_id'] = 0;
- $post['users_price'] = 0;
- $post['no_vip_pay'] = 0;
- $post['users_free'] = 0;
- } else if (1 == $post['restric_type']) {
- $post['arc_level_id'] = 0;
- $post['no_vip_pay'] = 0;
- $post['users_free'] = 0;
- if (empty($post['users_price']) || $post['users_price'] == 0) {
- return ['code' => 0, 'msg' => '购买价格不能为空!'];
- }
- } else if (2 == $post['restric_type']) {
- if (!empty($post['no_vip_pay'])) {
- if (empty($post['users_price']) || $post['users_price'] == 0) {
- return ['code' => 0, 'msg' => '购买价格不能为空!'];
- }
- if ($post['arc_level_id'] > 0) {
- $post['users_free'] = 1;
- }
- } else {
- if ($post['arc_level_id'] > 0) {
- $post['users_price'] = 0;
- $post['users_free'] = 1;
- }
- }
- } else if (3 == $post['restric_type']) {
- $post['no_vip_pay'] = 0;
- $post['users_free'] = 0;
- if (empty($post['users_price']) || $post['users_price'] == 0) {
- return ['code' => 0, 'msg' => '购买价格不能为空!'];
- }
- }
- }
- }
-
- return true;
- }
- }
-
- if (!function_exists('clear_session_file'))
- {
-
-
- function clear_session_file()
- {
- $path = \think\Config::get('session.path');
- if (!empty($path) && file_exists($path)) {
- if ('data/session' != $path && is_dir('data/session')) {
- delFile('./data/session', true);
- }
-
- $time = getTime();
- $web_login_expiretime = tpCache('web.web_login_expiretime');
- empty($web_login_expiretime) && $web_login_expiretime = config('login_expire');
- $files = glob($path.'/sess_*');
- foreach ($files as $key => $file) {
- clearstatcache();
- $filemtime = filemtime($file);
- if (false === $filemtime) {
- $filemtime = $time;
- }
- $filesize = filesize($file);
- if (false === $filesize) {
- $filesize = 1;
- }
- if (empty($filesize) || (($time - $filemtime) > ($web_login_expiretime + 300))) {
- $referurl = '';
- if (isset($_SERVER['HTTP_REFERER'])) {
- $referurl = $_SERVER['HTTP_REFERER'];
- }
- @unlink($file);
- }
- }
- }
- }
- }
-
- if (!function_exists('func_thumb_img'))
- {
-
-
- function func_thumb_img($original_img = '', $width = '', $height = '', $quality = 75)
- {
-
- static $thumbextra = null;
- static $thumbConfig = null;
- if (null === $thumbextra) {
- @ini_set('memory_limit', '-1');
- $thumbConfig = tpCache('thumb');
- $thumbextra = config('global.thumb');
- empty($thumbConfig['thumb_width']) && $thumbConfig['thumb_width'] = $thumbextra['width'];
- empty($thumbConfig['thumb_height']) && $thumbConfig['thumb_height'] = $thumbextra['height'];
- }
-
- $c_width = !empty($width) ? intval($width) : intval($thumbConfig['thumb_width']);
- $c_height = !empty($height) ? intval($height) : intval($thumbConfig['thumb_height']);
- if ((empty($c_width) && empty($c_height)) || stristr($original_img,'.gif')) {
- return $original_img;
- }
-
- $original_img_new = handle_subdir_pic($original_img, 'img', false, true);
- $original_img_new = trim($original_img_new, '/');
-
-
- $info = @getimagesize('./'.$original_img_new);
- $img_width = !empty($info[0]) ? intval($info[0]) : 0;
- $img_height = !empty($info[1]) ? intval($info[1]) : 0;
-
-
- if (!empty($img_width) && !empty($img_height) && $img_width <= $c_width && $img_height <= $c_height) {
- return $original_img;
- }
-
-
- if (false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))) {
- return $original_img;
- } else {
- if (!empty($info['mime']) && stristr($info['mime'], 'bmp') && version_compare(PHP_VERSION,'7.2.0','<')) {
- return $original_img;
- }
- }
-
- try {
- vendor('topthink.think-image.src.Image');
- vendor('topthink.think-image.src.image.Exception');
- $image = \think\Image::open('./'.$original_img_new);
- $image->thumb($c_width, $c_height, 1)->save($original_img_new, NULL, $quality);
- } catch (think\Exception $e) {}
-
- return $original_img;
- }
- }
-
- if (!function_exists('pc_to_mobile_url'))
- {
-
-
- function pc_to_mobile_url($pageurl = '', $tid = '', $aid = '')
- {
- $url = '';
- $webData = tpCache('web');
- if (file_exists('./template/'.TPL_THEME.'mobile')) {
-
- $domain = request()->host(true);
-
-
- if (!empty($webData['web_mobile_domain_open']) && !empty($webData['web_mobile_domain'])) {
- $domain = $webData['web_mobile_domain'] . '.' . request()->rootDomain();
- }
-
-
- if (!empty($aid)) {
- $url = url('home/View/index', ['aid' => $aid], true, $domain, 1, 1, 0);
- } else if (!empty($tid)) {
- $url = url('home/Lists/index', ['tid' => $tid], true, $domain, 1, 1, 0);
- } else {
- $url = request()->scheme().'://'. $domain . ROOT_DIR . '/index.php';
- }
- } else {
-
- if (!empty($webData['web_mobile_domain_open']) && !empty($webData['web_mobile_domain'])) {
- if (empty($pageurl)) {
- $url = request()->subDomain($webData['web_mobile_domain']) . ROOT_DIR . '/index.php';
- } else {
- $url = !preg_match('/^(http(s?):)?\/\/(.*)$/i', $pageurl) ? request()->domain() . $pageurl : $pageurl;
- $url = preg_replace('/^(.*)(\/\/)([^\/]*)(\.?)(' . request()->rootDomain() . ')(.*)$/i', '${1}${2}' . $webData['web_mobile_domain'] . '.${5}${6}', $url);
- }
- }
- }
-
- return $url;
- }
- }
-
- if (!function_exists('GetSortData'))
- {
-
-
- function GetSortData($orderby = '', $Param = [])
- {
- if (empty($Param)) {
- $Param = request()->param();
- }
-
- $sort_asc = !empty($Param['sort_asc']) ? $Param['sort_asc'] : 'desc';
-
- if (!empty($Param['sort']) && 'sales' == $Param['sort']) {
- $orderby = 'a.sales_all ' . $sort_asc . ', ' . $orderby;
- } else if (!empty($Param['sort']) && 'price' == $Param['sort']) {
- $orderby = 'a.users_price ' . $sort_asc . ', ' . $orderby;
- } else if (!empty($Param['sort']) && 'appraise' == $Param['sort']) {
- $orderby = 'a.appraise ' . $sort_asc . ', ' . $orderby;
- } else if (!empty($Param['sort']) && 'new' == $Param['sort']) {
- $orderby = 'a.add_time ' . $sort_asc . ', ' . $orderby;
- } else if (!empty($Param['sort']) && 'collection' == $Param['sort']) {
- $orderby = 'a.collection ' . $sort_asc . ', ' . $orderby;
- } else if (!empty($Param['sort']) && 'click' == $Param['sort']) {
- $orderby = 'a.click ' . $sort_asc . ', ' . $orderby;
- } else if (!empty($Param['sort']) && 'download' == $Param['sort']) {
- $orderby = 'a.downcount ' . $sort_asc . ', ' . $orderby;
- }
- return $orderby;
- }
- }
-
- if (!function_exists('set_tagseotitle'))
- {
-
-
- function set_tagseotitle($tag = '', $seo_title = '', $site_info = [])
- {
- $page = I('param.page/d', 1);
- static $lang = null;
- $lang === null && $lang = get_home_lang();
- static $seoConfig = null;
- null === $seoConfig && $seoConfig = tpCache('seo');
- $seo_title_symbol = isset($seoConfig['seo_title_symbol']) ? htmlspecialchars_decode($seoConfig['seo_title_symbol']) : '_';
- if (empty($seo_title)) {
- $web_name = tpCache('web.web_name');
- if ($page > 1) {
- if (in_array($lang, ['cn'])) {
- $tag .= "{$seo_title_symbol}第{$page}页";
- } else {
- $tag .= "{$seo_title_symbol}{$page}";
- }
- }
- $seo_title = $tag.'_'.$web_name;
- } else {
- if ($page > 1) {
- if (in_array($lang, ['cn'])) {
- $seo_title .= "{$seo_title_symbol}第{$page}页";
- } else {
- $seo_title .= "{$seo_title_symbol}{$page}";
- }
- }
- }
-
-
- if (empty($site_info)) {
- $site_info = cookie('site_info');
- $site_info = json_decode($site_info, true);
- }
- $seo_title = site_seo_handle($seo_title, $site_info);
-
- return $seo_title;
- }
- }
- if (!function_exists('spellLabel'))
- {
-
-
- function spellLabel( $value = '' )
- {
- $value = '<span id="users_price_1640658971">'.$value.'</span>';
- return $value;
- }
- }
-
- if (!function_exists('get_discount_price'))
- {
-
-
- function get_discount_price( $discount = 100 , $price = 0 )
- {
- if (0 < $price){
-
-
-
-
- if (!empty($discount)) {
- $price = round($price * ($discount/100),2);
- } else {
- $price = 0;
- }
- }
- return $price;
- }
- }
-
- if (!function_exists('site_seo_handle'))
- {
-
-
- function site_seo_handle($value = '', $site_info = [])
- {
- if (!empty($value)) {
- if (!config('city_switch_on')) {
- $value = str_ireplace(['{region}','{regionAll}','{parent}','{top}'], '', $value);
- } else {
- if (empty($site_info)) {
- $site_info = [
- 'name' => '',
- 'topid' => 0,
- 'parent_id' => 0,
- 'level' => 0,
- ];
- }
-
- if (stristr($value, "{region}")) {
- $name = !empty($site_info['name']) ? $site_info['name'] : '';
- $value = str_ireplace('{region}', $name, $value);
- }
- if (stristr($value, "{regionAll}") || stristr($value, "{parent}") || stristr($value, "{top}")) {
- static $citysiteList = null;
- if (null === $citysiteList) {
- $citysiteList = get_citysite_list();
- }
-
- $topName = !empty($citysiteList[$site_info['topid']]) ? $citysiteList[$site_info['topid']]['name'] : '';
- $parentName = !empty($citysiteList[$site_info['parent_id']]) ? $citysiteList[$site_info['parent_id']]['name'] : '';
- if (1 == $site_info['level']) {
- $topName = $parentName = '';
- } else if (2 == $site_info['level']) {
- $topName = '';
- } else {
- $topName = !empty($citysiteList[$site_info['topid']]) ? $citysiteList[$site_info['topid']]['name'] : '';
- $parentName = !empty($citysiteList[$site_info['parent_id']]) ? $citysiteList[$site_info['parent_id']]['name'] : '';
- }
- $regionAll = $topName.$parentName.$site_info['name'];
- $value = str_ireplace(['{parent}','{top}','{regionAll}'], [$parentName,$topName,$regionAll], $value);
- }
- }
- }
- return $value;
- }
- }
-
- if (!function_exists('adminLoginAfter')) {
-
-
- function adminLoginAfter($admin_id = 0, $session_id = '', $third_type = '')
- {
- if (!empty($admin_id)) {
- $admin_info = \think\Db::name('admin')->where(['admin_id'=>$admin_id])->find();
- $role_id = !empty($admin_info['role_id']) ? $admin_info['role_id'] : -1;
- $auth_role_info = array();
- $is_founder = 0;
- if (!empty($admin_info['parent_id'])) {
- $role_name = '超级管理员';
- } else {
- $is_founder = 1;
- $role_name = '创始人';
- }
- $admin_info['is_founder'] = $is_founder;
-
- if (0 < intval($role_id)) {
- $auth_role_info = \think\Db::name('auth_role')
- ->field("a.*, a.name AS role_name")
- ->alias('a')
- ->where('a.id','eq', $role_id)
- ->find();
- if (!empty($auth_role_info)) {
- $auth_role_info['language'] = unserialize($auth_role_info['language']);
- $auth_role_info['cud'] = unserialize($auth_role_info['cud']);
- $auth_role_info['permission'] = unserialize($auth_role_info['permission']);
- $role_name = $auth_role_info['name'];
- }
- }
- $admin_info['auth_role_info'] = $auth_role_info;
- $admin_info['role_name'] = $role_name;
-
- $last_login_time = getTime();
- $last_login_ip = clientIP();
- $login_cnt = $admin_info['login_cnt'] + 1;
- \think\Db::name('admin')->where(['admin_id'=>$admin_info['admin_id']])->save(array('last_login'=>$last_login_time, 'last_ip'=>$last_login_ip, 'login_cnt'=>$login_cnt, 'session_id'=>$session_id));
- $admin_info['last_login'] = $last_login_time;
- $admin_info['last_ip'] = $last_login_ip;
-
-
- empty($admin_info['head_pic']) && $admin_info['head_pic'] = get_head_pic($admin_info['head_pic'], true);
-
-
- $langRow = \think\Db::name('language')->order('id asc')
- ->cache(true, EYOUCMS_CACHE_TIME, 'language')
- ->select();
-
-
- $login_errnum_key = 'adminlogin_'.md5('login_errnum_'.$admin_info['user_name'].$last_login_ip);
- $login_errtime_key = 'adminlogin_'.md5('login_errtime_'.$admin_info['user_name'].$last_login_ip);
- $login_lock_key = 'adminlogin_'.md5('login_lock_'.$admin_info['user_name'].$last_login_ip);
- foreach ($langRow as $key => $val) {
- tpSetting('adminlogin', [$login_errnum_key=>0, $login_errtime_key=>0, $login_lock_key=>0], $val['mark']);
- }
-
-
- $security = tpSetting('security');
- if (isset($security['security_ask_ip_open']) && empty($security['security_ask_ip_open'])) {
- foreach ($langRow as $key => $val) {
- tpSetting('security', ['security_answerverify_ip'=>''], $val['mark']);
- }
- }
-
-
- if (in_array($third_type, ['WechatLogin','EyouGzhLogin'])) {
- $map = ['admin_id'=>$admin_id];
- if ('EyouGzhLogin' == $third_type) {
- $map['type'] = 1;
- } else if ('WechatLogin' == $third_type) {
- $map['type'] = 2;
- }
- $admin_info['openid'] = \think\Db::name('admin_wxlogin')->where($map)->value('openid');
- }
-
- $admin_info_new = $admin_info;
-
- foreach (['user_name','true_name','password'] as $key => $val) {
- unset($admin_info_new[$val]);
- }
-
-
-
- session('admin_id', $admin_info['admin_id']);
- session('admin_info', $admin_info_new);
- session('admin_login_expire', getTime());
- return $admin_info_new;
- }
- else {
- session('admin_id', null);
- session('admin_info', null);
- session('admin_login_expire', null);
- return false;
- }
- }
- }
-
- if (!function_exists('get_form_read_value')){
-
-
- function get_form_read_value($field_value,$field_type,$domain = false){
- static $region_arr = null;
- if (null === $region_arr) {
- $region_arr = get_region_list();
- }
-
- if ('checkbox' == $field_type && !empty($field_value)) {
- $field_value = str_replace(',', '] [', '['.$field_value.']');
- }else if('region' == $field_type && !empty($field_value)){
- if (is_string($field_value)) {
- $field_value_arr = explode(',', $field_value);
- } else {
- $field_value_arr = $field_value;
- }
-
- $attr_value = [];
- foreach ($field_value_arr as $key => $val) {
- $attr_value[] = !empty($region_arr[$val]['name']) ? $region_arr[$val]['name'] : '';
- }
- $field_value = implode('',$attr_value);
- }elseif (('file' == $field_type || 'img' == $field_type) && !empty($field_value)){
- static $file_type = null;
- null === $file_type && $file_type = tpCache('basic.file_type');
- if(preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp))$/i', $field_value)){
- if (!stristr($field_value, '|')) {
- $field_value = handle_subdir_pic($field_value,'img',$domain);
- $field_value = "<a href='{$field_value}' target='_blank'><img src='{$field_value}' width='60' height='60' style='float: unset;cursor: pointer;' /></a>";
- }
- }else if(preg_match('/(\.('.$file_type.'))$/i', $field_value)){
- static $current_domain = null;
- null === $current_domain && $current_domain = request()->domain();
- if (!stristr($field_value, '|')) {
- $field_value = handle_subdir_pic($field_value,'img',$domain);
- $domain_new = "";
- if ($domain){
- $domain_new = $current_domain;
- }
- $field_value = "<a href='{$field_value}' download='".time()."'><img src=\"{$domain_new}".ROOT_DIR."/public/static/common/images/file.png\" alt=\"\" style=\"width: 16px;height: 16px;\">点击下载</a>";
- }
- }
- }
-
- return $field_value;
- }
- }
- if (!function_exists('del_all_dir')){
-
- function del_all_dir($path){
- $path = rtrim($path, '/').'/';
-
- if(is_dir($path)){
-
- $p = scandir($path);
-
- if(count($p)>2){
- foreach($p as $val){
-
- if($val !="." && $val !=".."){
-
- if(is_dir($path.$val)){
-
- del_all_dir($path.$val.'/');
- }else{
-
- unlink($path.$val);
- }
- }
- }
- }
- }
-
- return @rmdir($path);
- }
- }
- if (!function_exists('get_image_type')){
-
- function get_image_type($image)
- {
- if (function_exists('exif_imagetype')) {
- return exif_imagetype($image);
- }
- try {
- $info = getimagesize($image);
- return $info ? $info[2] : false;
- } catch (\Exception $e) {
- return false;
- }
- }
- }
-
- if (!function_exists('get_all_arctype')){
-
-
- function get_all_arctype(){
- $arctype_list = Db::name('arctype')->field("id,parent_id,dirname")->where([
- 'is_del' => 0,
- 'lang' => get_current_lang()
- ])->order("grade asc")->getAllWithIndex("id");
- return $arctype_list;
- }
- }
- if (!function_exists('get_all_parent_dirpath')){
-
-
- function get_all_parent_dirpath($id,$arctype_list,&$parent_dir = ''){
- !empty($arctype_list[$id]['dirname']) && $parent_dir = $arctype_list[$id]['dirname']."/".$parent_dir;
- if (!empty($arctype_list[$id]['parent_id'])){
- $parent_dir = get_all_parent_dirpath($arctype_list[$id]['parent_id'],$arctype_list,$parent_dir);
- }
-
- return $parent_dir;
- }
- }
-
- if (!function_exists('clearHtmlCache')) {
-
-
- function clearHtmlCache($aids = [], $typeids = [])
- {
- $filelist = [];
- $seoData = tpCache('seo');
-
- if (!empty($aids)) {
- $archivesList = \think\Db::name('archives')->field('aid,typeid,stypeid')->where(['aid'=>['IN', $aids]])->select();
- foreach ($archivesList as $_k => $_v) {
- $typeids[] = $_v['typeid'];
- $_v['stypeid'] = trim($_v['stypeid'], ',');
- $stypeid = explode(',', $_v['stypeid']);
- foreach ($stypeid as $_k2 => $_v2) {
- $typeids[] = $_v2;
- }
- }
- if (!isset($seoData['seo_uphtml_after_pernext13']) || !empty($seoData['seo_uphtml_after_pernext13'])) {
-
- foreach ($aids as $_k => $_v) {
- $arr = glob(HTML_ROOT.'view'.DS."*_{$_v}.html");
- if (is_array($arr)) {
- $filelist = array_merge($filelist, $arr);
- }
- }
-
- $tagids = \think\Db::name('taglist')->where(['aid'=>['IN', $aids]])->group('tid')->column('tid');
- foreach ($tagids as $_k => $_v) {
- $arr = glob(HTML_ROOT.'tags'.DS."*_{$_v}.html");
- if (is_array($arr)) {
- $filelist = array_merge($filelist, $arr);
- }
- }
- }
- }
-
-
- if (!empty($typeids)) {
- if (!isset($seoData['seo_uphtml_after_channel13']) || !empty($seoData['seo_uphtml_after_channel13'])) {
- $arctypeM = new \app\common\model\Arctype;
- $typeid_list = $arctypeM->getAllPidByids($typeids);
- foreach ($typeid_list as $_k => $_v) {
- $arr = glob(HTML_ROOT.'lists'.DS."*_{$_v['id']}.html");
- if (is_array($arr)) {
- $filelist = array_merge($filelist, $arr);
- }
- }
- }
- }
-
-
- if (!empty($filelist)) {
- foreach ($filelist as $_k => $_v) {
- @unlink($_v);
- }
- \think\Cache::clear();
- }
-
- if (!empty($aids)) {
- if (!isset($seoData['seo_uphtml_after_home13']) || !empty($seoData['seo_uphtml_after_home13'])) {
- delFile(HTML_ROOT.'index');
- }
- }
- }
- }
-
- if (!function_exists('getToutiaoAccessToken'))
- {
-
-
- function getToutiaoAccessToken($appid = '', $secret = '', $salt = '', $resetToken = false)
- {
-
-
-
-
- $data = [
- 'salt' => $salt,
- 'appid' => $appid,
- 'secret' => $secret,
- ];
- if (empty($data['appid'])) {
- return [
- 'code' => 0,
- 'msg' => '请先完成字节小程序配置',
- ];
- }
-
-
-
-
-
-
-
- $url = "https://developer.toutiao.com/api/apps/v2/token";
- $postData = [
- 'appid' => $data['appid'],
- 'secret' => $data['secret'],
- 'grant_type' => "client_credential",
- ];
- $headers = array("content-type: application/json");
- $response = httpRequest($url, 'POST', json_encode($postData), $headers);
- $params = json_decode($response, true);
- if (!empty($params['data']['access_token'])) {
- $data['access_token'] = $access_token = $params['data']['access_token'];
- $data['expire_time'] = getTime() + $params['data']['expires_in'] - 1000;
- tpSetting('OpenMinicode', ['conf_toutiao' => json_encode($data)]);
- return [
- 'code' => 1,
- 'access_token' => $access_token,
- 'appid' => !empty($data['appid']) ? $data['appid'] : '',
- ];
- }
-
-
-
-
-
-
- return [
- 'code' => 0,
- 'msg' => !empty($params['errmsg']) ? $params['errmsg'] : '请检查小程序appid和secret是否正确',
- ];
- }
- }
-
- if (!function_exists('sitemap_auto'))
- {
-
-
- function sitemap_auto()
- {
- $globalConfig = tpCache('global');
- if (isset($globalConfig['sitemap_auto']) && $globalConfig['sitemap_auto'] > 0) {
- sitemap_all();
- }
- }
- }
-
- if (!function_exists('sitemap_all'))
- {
-
-
- function sitemap_all($type = 'all')
- {
- sitemap_xml($type);
- }
- }
-
- if (!function_exists('sitemap_xml'))
- {
-
-
- function sitemap_xml($type = 'all'){
- $globalConfig = tpCache('global');
- if (empty($globalConfig['sitemap_xml']) && empty($globalConfig['sitemap_txt'])) {
- return '';
- }
- $response_type = config('ey_config.response_type');
- $web_mobile_domain_open = $globalConfig['web_mobile_domain_open'];
- $web_mobile_domain = $globalConfig['web_mobile_domain'];
- $lang = get_current_lang();
- $default_lang = get_default_lang();
- $langRow = \think\Db::name('language')->field('is_home_default')->where(['mark'=>$lang])->find();
- if (!empty($langRow['is_home_default'])) {
- $filename = ROOT_PATH . "sitemap.xml";
- $filename_txt = ROOT_PATH . "sitemap.txt";
- } else {
- $filename = ROOT_PATH . "sitemap_{$lang}.xml";
- $filename_txt = ROOT_PATH . "sitemap_{$lang}.txt";
- }
-
-
- $map = array(
- 'status' => 1,
- 'is_del' => 0,
- 'lang' => $lang,
- );
- if (is_array($globalConfig)) {
-
- if (isset($globalConfig['sitemap_not1']) && $globalConfig['sitemap_not1'] > 0) {
- $map['is_hidden'] = 0;
- }
-
- if (isset($globalConfig['sitemap_not2']) && $globalConfig['sitemap_not2'] > 0) {
- $map['is_part'] = 0;
- }
- }
- $result_arctype = M('arctype')->field("*, id AS loc, add_time AS lastmod, 'hourly' AS changefreq, '0.8' AS priority")
- ->where($map)
- ->order('sort_order asc, id asc')
- ->getAllWithIndex('id');
-
-
- if (!isset($globalConfig['sitemap_archives_num']) || $globalConfig['sitemap_archives_num'] === '') {
- $sitemap_archives_num = 1000;
- } else {
- $sitemap_archives_num = intval($globalConfig['sitemap_archives_num']);
- }
- $result_archives = [];
- if (0 < $sitemap_archives_num) {
- $map = array(
- 'channel' => ['IN', config('global.allow_release_channel')],
- 'arcrank' => array('gt', -1),
- 'status' => 1,
- 'is_del' => 0,
- 'lang' => $lang,
- );
- if (is_array($globalConfig)) {
-
- if (isset($globalConfig['sitemap_not2']) && $globalConfig['sitemap_not2'] > 0) {
- $map['is_jump'] = 0;
- }
- }
-
- if (is_dir('./weapp/TimingTask/')) {
- $weappModel = new \app\admin\model\Weapp;
- $TimingTaskRow = $weappModel->getWeappList('TimingTask');
- if (!empty($TimingTaskRow['status']) && 1 == $TimingTaskRow['status']) {
- $map['add_time'] = ['elt', getTime()];
- }
- }
-
- $field = "aid, channel, is_jump, jumplinks, htmlfilename,province_id,city_id,area_id, add_time, update_time, typeid, aid AS loc, add_time AS lastmod, 'daily' AS changefreq, '0.5' AS priority";
- $result_archives = M('archives')->field($field)
- ->where($map)
- ->order('aid desc')
- ->limit($sitemap_archives_num)
- ->select();
- }
-
-
- $urls_txt = [];
-
-
- $xml_wrapper = <<<XML
- <?xml version='1.0' encoding='utf-8'?>
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">
- </urlset>
- XML;
- if (function_exists('simplexml_load_string')) {
- $xml = @simplexml_load_string($xml_wrapper);
- } else if (class_exists('SimpleXMLElement')) {
- $xml = new SimpleXMLElement($xml_wrapper);
- }
- if (!$xml) {
- return true;
- }
- if($web_mobile_domain_open){
- if (function_exists('simplexml_load_string')) {
- $xml_mobile = @simplexml_load_string($xml_wrapper);
- } else if (class_exists('SimpleXMLElement')) {
- $xml_mobile = new SimpleXMLElement($xml_wrapper);
- }
- $urls_txt_mobile = [];
- $filename_mobile = str_replace('sitemap','sitemap_'.$web_mobile_domain,$filename);
- $filename_txt_mobile = str_replace('sitemap','sitemap_'.$web_mobile_domain,$filename_txt);
- }
-
- $sitemap_changefreq_index = !empty($globalConfig['sitemap_changefreq_index']) ? $globalConfig['sitemap_changefreq_index'] : 'always';
- $sitemap_changefreq_list = !empty($globalConfig['sitemap_changefreq_list']) ? $globalConfig['sitemap_changefreq_list'] : 'hourly';
- $sitemap_changefreq_view = !empty($globalConfig['sitemap_changefreq_view']) ? $globalConfig['sitemap_changefreq_view'] : 'daily';
-
-
- $sitemap_priority_index = !empty($globalConfig['sitemap_priority_index']) ? $globalConfig['sitemap_priority_index'] : '1.0';
- $sitemap_priority_list = !empty($globalConfig['sitemap_priority_list']) ? $globalConfig['sitemap_priority_list'] : '0.8';
- $sitemap_priority_view = !empty($globalConfig['sitemap_priority_view']) ? $globalConfig['sitemap_priority_view'] : '0.5';
-
- $langRow = \think\Db::name('language')
- ->where(['status'=>1])
- ->order('id asc')
- ->cache(true, EYOUCMS_CACHE_TIME, 'language')
- ->select();
-
-
- $inletStr = '/index.php';
- $seo_inlet = config('ey_config.seo_inlet');
- 1 == intval($seo_inlet) && $inletStr = '';
- $now = date('Y-m-d');
-
- if ($lang == $default_lang) {
- foreach ($langRow as $key => $val) {
- $mark = $val['mark'];
- if (empty($globalConfig['web_language_switch']) && $lang != $mark) {
- continue;
- }
-
- $url = $val['url'];
- if (empty($url)) {
- if (1 == $val['is_home_default']) {
- $url = request()->domain().ROOT_DIR.'/';
- } else {
- if ($mark != $default_lang) {
- $url = request()->domain().ROOT_DIR."/sitemap_{$mark}.xml";
- } else {
- $global_config_tmp = tpCache('global', [], $mark);
- $seo_pseudo = !empty($global_config_tmp['seo_pseudo']) ? $global_config_tmp['seo_pseudo'] : config('ey_config.seo_pseudo');
- if (1 == $seo_pseudo) {
- $url = request()->domain().ROOT_DIR.$inletStr;
- if (!empty($inletStr)) {
- $url .= '?';
- } else {
- $url .= '/?';
- }
- $url .= http_build_query(['lang'=>$mark]);
- } else {
- $url = request()->domain().ROOT_DIR.$inletStr.'/'.$mark;
- }
- }
- }
- } else {
- if (0 == $val['is_home_default']) {
- $url = $url.ROOT_DIR."/sitemap_{$mark}.xml";
- }
- }
-
- if ($web_mobile_domain_open){
- $xml = join_xml($xml,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'pc');
- array_push($urls_txt, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
- if($xml_mobile){
- $url = pc_to_mobile_url($url);
- $xml_mobile = join_xml($xml_mobile,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'mobile');
- if (!in_array($url, $urls_txt_mobile)) {
- array_push($urls_txt_mobile, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
- }
- }
- }else{
- if ($response_type){
- $xml = join_xml($xml,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'htmladapt');
- }else{
- $xml =join_xml($xml,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'pc,mobile');
- }
- array_push($urls_txt, htmlspecialchars_decode($url));
- }
- }
- }
- else {
- foreach ($langRow as $key => $val) {
- $mark = $val['mark'];
- if (empty($globalConfig['web_language_switch']) || $lang != $mark) {
- continue;
- }
-
- $url = $val['url'];
- if (empty($url)) {
- $global_config_tmp = tpCache('global', [], $mark);
- $seo_pseudo = !empty($global_config_tmp['seo_pseudo']) ? $global_config_tmp['seo_pseudo'] : config('ey_config.seo_pseudo');
- if (1 == $seo_pseudo) {
- $url = request()->domain().ROOT_DIR.$inletStr;
- if (!empty($inletStr)) {
- $url .= '?';
- } else {
- $url .= '/?';
- }
- $url .= http_build_query(['lang'=>$mark]);
- } else {
- $url = request()->domain().ROOT_DIR.$inletStr.'/'.$mark;
- }
- }
-
-
-
- if ($web_mobile_domain_open){
- $xml = join_xml($xml,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'pc');
- array_push($urls_txt, htmlspecialchars_decode($url));
- if($xml_mobile){
- $url = pc_to_mobile_url($url);
- $xml_mobile = join_xml($xml_mobile,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'mobile');
- array_push($urls_txt_mobile, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
- }
- }else{
- if ($response_type){
- $xml = join_xml($xml,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'htmladapt');
- }else{
- $xml =join_xml($xml,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'pc,mobile');
- }
- array_push($urls_txt, htmlspecialchars_decode($url));
- }
- }
- }
-
-
-
- foreach ($result_arctype as $sub) {
- if (is_array($sub)) {
- if ($sub['is_part'] == 1) {
- $url = $sub['typelink'];
- } else {
- $url = get_typeurl($sub, false);
- }
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- if ($web_mobile_domain_open){
- $xml = join_xml($xml,$url,$now,$sitemap_changefreq_list,$sitemap_priority_list,'pc');
- array_push($urls_txt, htmlspecialchars_decode($url));
- if($xml_mobile){
- $url = get_typeurl($sub, false,'mobile');
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $xml_mobile = join_xml($xml_mobile,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'mobile');
- array_push($urls_txt_mobile, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
- }
- }else{
- if ($response_type){
- $xml = join_xml($xml,$url,$now,$sitemap_changefreq_list,$sitemap_priority_list,'htmladapt');
- }else{
- $xml =join_xml($xml,$url,$now,$sitemap_changefreq_list,$sitemap_priority_list,'pc,mobile');
- }
- array_push($urls_txt, htmlspecialchars_decode($url));
- }
- }
- }
-
-
-
- foreach ($result_archives as $val) {
- if (is_array($val) && isset($result_arctype[$val['typeid']])) {
- $val = array_merge($result_arctype[$val['typeid']], $val);
- if ($val['is_jump'] == 1) {
- $url = $val['jumplinks'];
- } else {
- $url = get_arcurl($val, false);
- }
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $lastmod_time = empty($val['update_time']) ? $val['add_time'] : $val['update_time'];
- $time_row = date('Y-m-d', $lastmod_time);
- if ($web_mobile_domain_open){
- $xml = join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'pc');
- array_push($urls_txt, htmlspecialchars_decode($url));
- if($xml_mobile){
- $url = get_arcurl($val, false,'mobile');
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $xml_mobile = join_xml($xml_mobile,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'mobile');
- array_push($urls_txt_mobile, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
- }
- }else{
- if ($response_type){
- $xml = join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'htmladapt');
- }else{
- $xml =join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'pc,mobile');
- }
- array_push($urls_txt, htmlspecialchars_decode($url));
- }
- }
- }
-
-
-
-
- if (!isset($globalConfig['sitemap_tags_num']) || $globalConfig['sitemap_tags_num'] === '') {
- $sitemap_tags_num = 1000;
- } else {
- $sitemap_tags_num = intval($globalConfig['sitemap_tags_num']);
- }
- $web_tpl_theme = !empty($globalConfig['web_tpl_theme']) ? "/".$globalConfig['web_tpl_theme'] : '';
- if (is_file('./template'.$web_tpl_theme.'/pc/lists_tags.htm') && $sitemap_tags_num > 0){
- $result_tags = [];
- if (0 < $sitemap_tags_num) {
- $map = array(
- 'lang' => $lang,
- );
- $field = "id, add_time, id AS loc, add_time AS lastmod, 'daily' AS changefreq, '0.5' AS priority";
- $result_tags = M('tagindex')->field($field)
- ->where($map)
- ->order('add_time desc')
- ->limit($sitemap_tags_num)
- ->select();
- }
- foreach ($result_tags as $val) {
- if (is_array($val)) {
- $url = get_tagurl($val['id']);
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $lastmod_time = empty($val['update_time']) ? $val['add_time'] : $val['update_time'];
- $time_row = date('Y-m-d', $lastmod_time);
- if ($web_mobile_domain_open){
- $xml = join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'pc');
- array_push($urls_txt, htmlspecialchars_decode($url));
- if($xml_mobile){
- $url = get_tagurl($val['id'],'mobile');
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $xml_mobile = join_xml($xml_mobile,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'mobile');
- array_push($urls_txt_mobile, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
- }
- }else{
- if ($response_type){
- $xml = join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'htmladapt');
- }else{
- $xml =join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'pc,mobile');
- }
- array_push($urls_txt, htmlspecialchars_decode($url));
- }
- }
- }
- }
-
-
- if (is_dir('./weapp/Ask/')){
- try{
- $Askow = \think\Db::name("weapp")->where(['code'=>'Ask'])->field("status,data")->find();
- if (!empty($Askow['status']) && 1 == $Askow['status']) {
- $ask_map = [
- 'is_review' =>1,
- ];
- $mobile_domain = tpCache('global.web_mobile_domain');
- $ask_seo_pseudo = 1;
- $Askow['data'] = unserialize($Askow['data']);
- if (!empty($Askow['data']['seo_pseudo'])) {
- $ask_seo_pseudo = intval($Askow['data']['seo_pseudo']);
- }
-
- $ask_list[] = [
- 'url' => auto_hide_index(url('plugins/Ask/index', [], true, true, $ask_seo_pseudo)),
- 'title' => "问答首页",
- 'add_time' =>time(),
- 'mobile_url' => auto_hide_index(url('plugins/Ask/index', [], true, $mobile_domain, $ask_seo_pseudo)),
- ];
-
- $result_ask_type = \think\Db::name("weapp_ask_type")->field("type_id,type_name,update_time")->order('sort_order asc')->select();
- foreach ($result_ask_type as $val){
- $ask_list[] = [
- 'url' => auto_hide_index(url('plugins/Ask/index', ['type_id'=>$val['type_id']],true,true,$ask_seo_pseudo)),
- 'title' => $val['type_name'],
- 'update_time' =>$val['update_time'],
- 'mobile_url' => auto_hide_index(url('plugins/Ask/index', ['type_id'=>$val['type_id']],true,$mobile_domain,$ask_seo_pseudo)),
-
- ];
- }
-
- $result_ask = \think\Db::name('weapp_ask')->field('ask_id,type_id,ask_title,update_time')
- ->where($ask_map)
- ->order('ask_id desc')
- ->select();
- foreach ($result_ask as $val){
- $ask_list[] = [
- 'url' => auto_hide_index(url('plugins/Ask/details', ['ask_id'=>$val['ask_id']],true,true,$ask_seo_pseudo)),
- 'title' => $val['ask_title'],
- 'update_time' =>$val['update_time'],
- 'mobile_url' => auto_hide_index(url('plugins/Ask/details', ['ask_id'=>$val['ask_id']],true,$mobile_domain,$ask_seo_pseudo)),
- ];
- }
- foreach ($ask_list as $val) {
- if (is_array($val)) {
- $url = $val['url'];
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $lastmod_time = empty($val['update_time']) ? $val['add_time'] : $val['update_time'];
- $time_row = date('Y-m-d', $lastmod_time);
- if ($web_mobile_domain_open){
- $xml = join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'pc');
- array_push($urls_txt, htmlspecialchars_decode($url));
- if($xml_mobile){
- $url = $val['mobile_url'];
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $xml_mobile = join_xml($xml_mobile,$url,$now,$sitemap_changefreq_index,$sitemap_priority_index,'mobile');
- array_push($urls_txt_mobile, str_replace('.xml', '.txt', htmlspecialchars_decode($url)));
- }
- }else{
- if ($response_type){
- $xml = join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'htmladapt');
- }else{
- $xml =join_xml($xml,$url,$time_row,$sitemap_changefreq_view,$sitemap_priority_view,'pc,mobile');
- }
- array_push($urls_txt, htmlspecialchars_decode($url));
- }
- }
- }
- }
- }catch (\Exception $e){}
- }
-
-
- if ($type == 'xml' || (!empty($globalConfig['sitemap_xml']) && in_array($type, ['all','xml']))) {
- if($xml && $filename){
- $content = $xml->asXML();
- @file_put_contents($filename, $content);
- }
- if(!empty($xml_mobile) && !empty($filename_mobile)){
- $content = $xml_mobile->asXML();
- @file_put_contents($filename_mobile, $content);
- }
- }
- if ($type == 'txt' || (!empty($globalConfig['sitemap_txt']) && in_array($type, ['all','txt']))) {
- if($urls_txt && $filename_txt){
- $content = implode(PHP_EOL, $urls_txt);
- @file_put_contents($filename_txt, $content);
- }
- if(!empty($urls_txt_mobile) && !empty($filename_txt_mobile)){
- $content = implode(PHP_EOL, $urls_txt_mobile);
- @file_put_contents($filename_txt_mobile, $content);
- }
- }
- }
- }
-
- if (!function_exists('join_xml'))
- {
-
-
- function join_xml($xml,$loc,$lastmod,$changefreq,$priority,$model = 'pc')
- {
- $item = $xml->addChild('url');
- foreach (['loc','lastmod','changefreq','priority'] as $key1) {
- if ('loc' == $key1) {
- $row = $loc;
- } else if ('lastmod' == $key1) {
- $row = $lastmod;
- } else if ('changefreq' == $key1) {
- $row = $changefreq;
- } else if ('priority' == $key1) {
- $row = $priority;
- }
- try {
- $node = $item->addChild($key1, $row);
- } catch (\Exception $e) {}
- if (isset($attribute_array[$key1]) && is_array($attribute_array[$key1])) {
- foreach ($attribute_array[$key1] as $akey => $aval) {
- $node->addAttribute($akey, $aval);
- }
- }
- }
- if ($model == 'mobile'){
- $item->addChild('mobile','','http://www.google.com/schemas/sitemap-mobile/1.0')->addAttribute("type","mobile");
- }else if($model == 'pc,mobile'){
- $item->addChild('mobile','','http://www.google.com/schemas/sitemap-mobile/1.0')->addAttribute("type","pc,mobile");
- }else if($model == 'htmladapt'){
- $item->addChild('mobile','','http://www.google.com/schemas/sitemap-mobile/1.0')->addAttribute("type","htmladapt");
- }
-
- return $xml;
- }
- }
-
- if (!function_exists('to_index'))
- {
- function to_index($code="404"){
- header('HTTP/1.1 301 Moved Permanently');
-
- header('Location: https://www.zc10000.com');
-
- exit();
-
- }
- }
- if (!function_exists('get_typeurl'))
- {
-
-
- function get_typeurl($arctype_info = array(), $admin = true,$domain_type = '')
- {
-
- if ($arctype_info['current_channel'] == 51) {
- $typeurl = get_askurl("home/Ask/index");
-
- $typeurl = auto_hide_index($typeurl);
-
- return $typeurl;
- }
-
- $domain = null;
- null === $domain && $domain = request()->domain();
- if ($domain_type == 'mobile'){
- $web_mobile_domain = tpCache('global.web_mobile_domain');
- if (!empty($web_mobile_domain)){
- $subDomain = request()->subDomain();
- $domain = str_replace($subDomain,$web_mobile_domain,$domain);
- }
- }
-
- if (empty($arctype_info['current_channel'])) {
- $channelRow = \think\Db::name('channeltype')->field('id as channel')
- ->where('id',1)
- ->find();
- $arctype_info = array_merge($arctype_info, $channelRow);
- }
-
-
- static $result = null;
- null === $result && $result = model('Channeltype')->getAll('id, ctl_name', array(), 'id');
- $ctl_name = '';
- if ($result) {
- $ctl_name = $result[$arctype_info['current_channel']]['ctl_name'];
- }
-
- static $seo_pseudo = null;
- static $seo_dynamic_format = null;
- if (null === $seo_pseudo || null === $seo_dynamic_format) {
- $globalConfig = tpCache('global');
- $seo_pseudo = !empty($globalConfig['seo_pseudo']) ? $globalConfig['seo_pseudo'] : config('ey_config.seo_pseudo');
- $seo_dynamic_format = !empty($globalConfig['seo_dynamic_format']) ? $globalConfig['seo_dynamic_format'] : config('ey_config.seo_dynamic_format');
- }
-
- if (2 == $seo_pseudo && $admin) {
- static $lang = null;
- null === $lang && $lang = input('param.lang/s', 'cn');
- $typeurl = ROOT_DIR."/index.php?m=home&c=Lists&a=index&tid={$arctype_info['id']}&lang={$lang}&t=".getTime();
- } else {
- $typeurl = typeurl("home/{$ctl_name}/lists", $arctype_info, true, $domain, $seo_pseudo, $seo_dynamic_format);
-
- $typeurl = auto_hide_index($typeurl);
- }
-
- return $typeurl;
- }
- }
-
- if (!function_exists('get_askurl'))
- {
-
-
- function get_askurl($url = '', $ask_info = array(), $admin = true)
- {
- static $domain = null;
- null === $domain && $domain = request()->domain();
-
- static $seo_pseudo = null;
- static $seo_dynamic_format = null;
- if (null === $seo_pseudo || null === $seo_dynamic_format) {
- $globalConfig = tpCache('global');
- $seo_pseudo = !empty($globalConfig['seo_pseudo']) ? $globalConfig['seo_pseudo'] : config('ey_config.seo_pseudo');
- $seo_dynamic_format = !empty($globalConfig['seo_dynamic_format']) ? $globalConfig['seo_dynamic_format'] : config('ey_config.seo_dynamic_format');
- }
-
- $askurl = askurl($url, $ask_info, true, $domain, $seo_pseudo, $seo_dynamic_format);
-
- $askurl = auto_hide_index($askurl);
-
- return $askurl;
- }
- }
-
- if (!function_exists('get_arcurl'))
- {
-
-
- function get_arcurl($arcview_info = array(), $admin = true,$domain_type = '')
- {
- $domain = null;
- null === $domain && $domain = request()->domain();
- if ($domain_type == 'mobile'){
- $web_mobile_domain = tpCache('global.web_mobile_domain');
- if (!empty($web_mobile_domain)){
- $subDomain = request()->subDomain();
- $domain = str_replace($subDomain,$web_mobile_domain,$domain);
- }
- }
-
- if (!empty($arcview_info) && empty($arcview_info['channel'])) {
- $channelRow = \think\Db::name('channeltype')->field('id as channel')
- ->where('id',1)
- ->find();
- $arcview_info = array_merge($arcview_info, $channelRow);
- }
-
-
- static $result = null;
- null === $result && $result = model('Channeltype')->getAll('id, ctl_name', array(), 'id');
- $ctl_name = '';
- if ($result) {
- $ctl_name = $result[$arcview_info['channel']]['ctl_name'];
- }
-
- static $seo_pseudo = null;
- static $seo_dynamic_format = null;
- if (null === $seo_pseudo || null === $seo_dynamic_format) {
- $globalConfig = tpCache('global');
- $seo_pseudo = !empty($globalConfig['seo_pseudo']) ? $globalConfig['seo_pseudo'] : config('ey_config.seo_pseudo');
- $seo_dynamic_format = !empty($globalConfig['seo_dynamic_format']) ? $globalConfig['seo_dynamic_format'] : config('ey_config.seo_dynamic_format');
- }
-
- if ($admin) {
- if (2 == $seo_pseudo) {
- static $lang = null;
- null === $lang && $lang = input('param.lang/s', 'cn');
- $arcurl = ROOT_DIR."/index.php?m=home&c=View&a=index&aid={$arcview_info['aid']}&lang={$lang}&admin_id=".session('admin_id');
- } else {
- $arcurl = arcurl("home/{$ctl_name}/view", $arcview_info, true, $domain, $seo_pseudo, $seo_dynamic_format);
- if (config('city_switch_on')) {
- $url_path = parse_url($arcurl, PHP_URL_PATH);
- $url_path = str_replace('.html', '', $url_path);
- $url_path = '/'.trim($url_path, '/').'/';
- preg_match_all('/\/site\/([^\/]+)\//', $url_path, $matches);
- $site_domain = !empty($matches[1][0]) ? $matches[1][0] : '';
- if (!empty($site_domain)) {
- $url_path_new = str_replace("/site/{$site_domain}/", '', $url_path);
- $root_dir_str = str_replace('/', '\/', ROOT_DIR);
- $url_path_new = preg_replace("/^{$root_dir_str}\//", ROOT_DIR."/{$site_domain}/", $url_path_new);
- $arcurl = str_replace(rtrim($url_path, '/'), $url_path_new, $arcurl);
- }
- }
-
- $arcurl = auto_hide_index($arcurl);
- if (stristr($arcurl, '?')) {
- $arcurl .= '&admin_id='.session('admin_id');
- } else {
- $arcurl .= '?admin_id='.session('admin_id');
- }
- }
- } else {
- $arcurl = arcurl("home/{$ctl_name}/view", $arcview_info, true, $domain, $seo_pseudo, $seo_dynamic_format);
- if (config('city_switch_on')) {
- $url_path = parse_url($arcurl, PHP_URL_PATH);
- $url_path = str_replace('.html', '', $url_path);
- $url_path = '/'.trim($url_path, '/').'/';
- preg_match_all('/\/site\/([^\/]+)\//', $url_path, $matches);
- $site_domain = !empty($matches[1][0]) ? $matches[1][0] : '';
- if (!empty($site_domain)) {
- $url_path_new = str_replace("/site/{$site_domain}/", '', $url_path);
- $root_dir_str = str_replace('/', '\/', ROOT_DIR);
- $url_path_new = preg_replace("/^{$root_dir_str}\//", ROOT_DIR."/{$site_domain}/", $url_path_new);
- $arcurl = str_replace(rtrim($url_path, '/'), $url_path_new, $arcurl);
- }
- }
-
- $arcurl = auto_hide_index($arcurl);
- }
-
- return $arcurl;
- }
- }
-
- if (!function_exists('get_tagurl'))
- {
-
-
- function get_tagurl($tagid = '',$domain_type = '')
- {
- if ($domain_type == 'mobile'){
- $domain = tpCache('global.web_mobile_domain');
- }else{
- static $domain = null;
- null === $domain && $domain = true;
- }
- $tagurl = tagurl("home/Tags/lists", ['tagid'=>$tagid], true, $domain);
-
-
-
-
-
-
-
-
-
-
- $tagurl = auto_hide_index($tagurl);
-
- return $tagurl;
- }
- }
-
- if (!function_exists('handleEyouDataValidate'))
- {
-
-
- function handleEyouDataValidate($required = '', $token = '', $post = [], $error = '数据不存在!')
- {
- if (empty($required)) return '请传入必填项字段';
- if (empty($token)) return '请传入验证token名称';
- if (empty($post)) return '请传入提交验证的数组';
-
- $rule = [
- $required => 'require|token:'.$token.'',
- ];
- $message = [
- $required . '.require' => $error,
- ];
- $validate = new \think\Validate($rule, $message);
- if (!$validate->batch()->check($post)) {
- $getError = $validate->getError();
- $errorMsg = array_values($getError);
- $resultMsg = (empty($errorMsg[0]) || $errorMsg[0] == '令牌数据无效') ? '表单校验失败,请检查站点权限问题' : $errorMsg[0];
- }
- return !empty($resultMsg) ? $resultMsg : false;
- }
- }
-
- if (!function_exists('handleEyouFilterStr'))
- {
-
-
- function handleEyouFilterStr($resultStr = '')
- {
- if (empty($resultStr)) return '请传入字符串';
-
- $resultStr = htmlspecialchars_decode($resultStr);
- $filterStr = ['javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base', 'svg'];
- foreach ($filterStr as $value) {
- $resultStr = preg_replace('/<(\s*)\b'.$value.'\b/i', '<', $resultStr);
- }
- $resultStr = htmlspecialchars($resultStr);
-
- return !empty($resultStr) ? $resultStr : false;
- }
- }
-
- if (!function_exists('auto_bind_wechatlogin'))
- {
-
-
- function auto_bind_wechatlogin($users = [], &$referurl = '')
- {
-
- if (isMobile() && isWeixin() && 0 === intval($users['thirdparty'])) {
- $open_id = model('ShopPublicHandle')->weChatauthorizeCookie($users['users_id']);
- if (empty($open_id)) {
-
- $weChatLoginConfig = getUsersConfigData('wechat.wechat_login_config');
- $weChatLoginConfig = !empty($weChatLoginConfig) ? unserialize($weChatLoginConfig) : [];
- if (!empty($weChatLoginConfig['appid']) && !empty($weChatLoginConfig['appsecret'])) {
-
- $callBack = urlencode(url('user/Users/auto_bind_wechat_info', '', true, true));
- $referurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $weChatLoginConfig['appid'] . "&redirect_uri=" . $callBack . "&response_type=code&scope=snsapi_base&state=eyoucms&#wechat_redirect";
- }
- } else {
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
- }
-
- if (!function_exists('getConsumObtainScores'))
- {
-
-
- function getConsumObtainScores($order = [], $usersConfig = [], $isReturn = false)
- {
-
- $addScores = 0;
- if (!empty($usersConfig['score_consume_status']) && 1 === intval($usersConfig['score_consume_status'])) {
-
- $addScoresMoney = !empty($order['order_total_amount']) ? floatval($order['order_total_amount']) : 0;
-
- $scoreConsumeMoney = !empty($usersConfig['score_consume_money']) ? intval($usersConfig['score_consume_money']) : 0;
-
- $addScores = intval(floatval($addScoresMoney) * floatval($scoreConsumeMoney));
- if (empty($isReturn)) {
-
- }
- }
- if (!empty($isReturn)) return intval($addScores);
- }
- }
-
- if (!function_exists('addConsumObtainScores')) {
-
-
- function addConsumObtainScores($data = [], $rule = 2, $update = true)
- {
- $insert = [
- 'type' => $data['type'],
- 'users_id' => $data['users_id'],
- 'score' => 2 === intval($rule) ? '+' . $data['score'] : '-' . $data['score'],
- 'info' => !empty($data['info']) ? $data['info'] : '',
- 'remark' => !empty($data['remark']) ? $data['remark'] : '',
- 'admin_id' => !empty($data['admin_id']) ? $data['admin_id'] : 0,
- 'add_time' => getTime(),
- 'update_time' => getTime()
- ];
- $id = Db::name('users_score')->insertGetId($insert);
- if (!empty($id)) {
- if (!empty($update)) {
- if (2 == $rule) {
-
- $update_score = Db::Raw('scores + '.$data['score']);
- } else {
-
- $update_score = Db::Raw('scores - '.$data['score']);
- }
- Db::name('users')->where('users_id', $data['users_id'])->update(['scores'=>$update_score,'update_time'=>getTime()]);
- }
-
- $current_score = Db::name('users')->where('users_id', $data['users_id'])->value('scores');
- Db::name('users_score')->where('id', $id)->update(['current_score' => $current_score, 'update_time' => getTime()]);
- }
- }
- }
-
- if (!function_exists('get_weixin_access_token'))
- {
-
-
- function get_weixin_access_token($resetToken = false, $applets = 'openSource')
- {
- if (is_dir('./weapp/DiyminiproMall/') && 'visualization' == $applets) {
- $where = [
- 'name' => 'setting',
- ];
- $settingValue = \think\Db::name('weapp_diyminipro_mall_setting')->where($where)->getField('value');
- $settingValue = !empty($settingValue) ? json_decode($settingValue, true) : [];
- if (!empty($settingValue['appId']) && !empty($settingValue['appSecret'])) {
- $data = [
- 'appid' => $settingValue['appId'],
- 'appsecret' => $settingValue['appSecret']
- ];
- } else {
- return [
- 'code' => 0,
- 'msg' => '101: 请先完成可视化微信商城小程序配置',
- ];
- }
- } else if ('openSource' == $applets) {
- $data = tpSetting("OpenMinicode.conf_weixin");
- $data = !empty($data) ? json_decode($data, true) : [];
- if (empty($data['appid'])) {
- return [
- 'code' => 0,
- 'msg' => '102: 请先完成小程序API中的微信小程序配置',
- ];
- }
- }
-
- if (false === $resetToken && !empty($data['access_token']) && !empty($data['expire_time']) && $data['expire_time'] > getTime()) {
- return [
- 'code' => 1,
- 'access_token' => $data['access_token'],
- ];
- }
-
- $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$data['appid']."&secret=".$data['appsecret'];
- $response = httpRequest($url);
- $params = json_decode($response, true);
- if (!isset($params['access_token']) && 'openSource' == $applets) {
- get_weixin_access_token(true, 'visualization');
- } else if (isset($params['access_token'])) {
- $access_token = $params['access_token'];
- $data['access_token'] = $params['access_token'];
- $data['expire_time'] = getTime() + $params['expires_in'] - 1000;
- if (is_dir('./weapp/DiyminiproMall/') && 'visualization' == $applets) {
-
- } else if ('openSource' == $applets) {
- tpSetting('OpenMinicode', ['conf_weixin' => json_encode($data)]);
- }
- return [
- 'code' => 1,
- 'access_token' => $access_token,
- 'appid' => !empty($data['appid']) ? $data['appid'] : '',
- ];
- }
-
- return [
- 'code' => 0,
- 'msg' => !empty($params['errmsg']) ? $params['errmsg'] : '请检查小程序AppId和AppSecret是否正确',
- ];
- }
- }
-
- if (!function_exists('get_wechat_access_token'))
- {
-
-
- function get_wechat_access_token($resetToken = false)
- {
- $data = tpSetting("OpenMinicode.conf_wechat");
- $data = !empty($data) ? json_decode($data, true) : [];
- if (empty($data['appid'])) {
- return [
- 'code' => 0,
- 'msg' => '请先完成微信公众号配置',
- ];
- }
- if (false === $resetToken && !empty($data['access_token']) && !empty($data['expire_time']) && $data['expire_time'] > getTime()) {
- return [
- 'code' => 1,
- 'access_token' => $data['access_token'],
- ];
- }
- $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$data['appid']."&secret=".$data['appsecret'];
- $response = httpRequest($url);
- $params = json_decode($response, true);
- if (isset($params['access_token'])) {
- $access_token = $params['access_token'];
- $data['access_token'] = $params['access_token'];
- $data['expire_time'] = getTime() + $params['expires_in'] - 1000;
- tpSetting('OpenMinicode', ['conf_wechat' => json_encode($data)]);
- return [
- 'code' => 1,
- 'access_token' => $access_token,
- 'appid' => !empty($data['appid']) ? $data['appid'] : '',
- ];
- }
-
- return [
- 'code' => 0,
- 'errcode' => !empty($params['errcode']) ? $params['errcode'] : 0,
- 'msg' => !empty($params['errmsg']) ? $params['errmsg'] : '请检查微信公众号AppId和AppSecret是否正确',
- ];
- }
- }
-
- if (!function_exists('eyou_send_notice'))
- {
-
-
- function eyou_send_notice($send_scene, $params = [])
- {
-
- $apiModel = new \app\api\model\v1\Api;
-
- $result_id = !empty($params['result_id']) ? $params['result_id'] : 0;
-
- $users_id = !empty($params['users_id']) ? intval($params['users_id']) : 0;
-
- if ($send_scene == 9) {
-
- $admin_list = Db::name('admin')->where(['wechat_followed'=>1])->select();
- foreach ($admin_list as $key => $admin_info) {
- $apiModel->sendWechatNotice($result_id, $send_scene, $admin_info);
- }
- }
-
- else if ($send_scene == 7) {
-
- $data = [
- 'users_id' => $users_id,
- ];
- $apiModel->sendAppletsNotice($result_id, $send_scene, $data);
- }
-
- return ['code'=>1, 'msg'=>'success'];
- }
- }
-
- if (!function_exists('eyou_statistics_data')) {
-
-
- function eyou_statistics_data($type = 1,$change = 0,$now_time='',$action = 'inc')
- {
- try {
- $lang = get_current_lang();
-
- if (empty($now_time)){
- $now_time = date('Y-m-d');
- $now_time = strtotime($now_time);
- }
-
- if (!in_array($type,[3,5]) && empty($change)){
- $change = 1;
- }
- $is_have = Db::name('statistics_data')->where(['date'=>$now_time,'type'=>$type,'lang'=>$lang])->find();
- if (!empty($is_have)){
- if ('inc' == $action){
-
- if (in_array($type,[3,5])){
- Db::name('statistics_data')->where(['date'=>$now_time,'type'=>$type,'lang'=>$lang])->setInc('total',$change);
- }else{
- Db::name('statistics_data')->where(['date'=>$now_time,'type'=>$type,'lang'=>$lang])->setInc('num',$change);
- }
- }else{
- if (in_array($type,[3,5])){
- Db::name('statistics_data')->where(['date'=>$now_time,'type'=>$type,'lang'=>$lang])->setDec('total',$change);
- }else{
- Db::name('statistics_data')->where(['date'=>$now_time,'type'=>$type,'lang'=>$lang])->setDec('num',$change);
- }
- }
- }else{
- if ('inc' == $action){
-
- $insert = [
- 'date'=>$now_time,
- 'type'=>$type,
- 'lang'=>$lang,
- ];
- if (in_array($type,[3,5])){
- $insert['total'] = $change;
- }else{
- $insert['num'] = $change;
- }
- Db::name('statistics_data')->insert($insert);
- }
- }
- } catch (\Exception $e) {
-
- }
-
- return true;
- }
- }
-
- if (!function_exists('del_statistics_data'))
- {
-
-
- function del_statistics_data($type, $del_aid = '')
- {
- $del_aid = is_array($del_aid) ? $del_aid : [$del_aid];
- if (!empty($type) && !empty($del_aid)) {
- $ystd_count = $td_count = 0;
- $today = strtotime(date('Y-m-d'));
- $yesterday = $today - 86400;
- $where = [
- 'aid' => ['IN', $del_aid],
- 'add_time' => ['egt', $yesterday],
- ];
- $list = \think\Db::name('archives')->field('aid,add_time')->where($where)->select();
- foreach ($list as $key => $val) {
- if ($val['add_time'] < $today) {
- $ystd_count++;
- } else if ($val['add_time'] >= $today) {
- $td_count++;
- }
- }
-
- if ($td_count > 0){
- eyou_statistics_data($type, $td_count,'','dec');
- }
- if ($ystd_count > 0){
- $ystd = strtotime('-1 day');
- eyou_statistics_data($type, $ystd_count,$ystd,'dec');
- }
- }
- }
- }
-
- if (!function_exists('equal_pop_login'))
- {
-
-
- function equal_pop_login($type = 'default')
- {
- $str = '';
- if (is_dir('./weapp/Equal/')) {
- $equalLogic = new \weapp\Equal\logic\EqualLogic;
- $str = $equalLogic->popLogin($type);
- }
- return $str;
- }
- }
-
-
-
-
-
- function getTopHost($url)
- {
- $url = strtolower($url);
- $hosts = parse_url($url);
- $host = $hosts['host'];
-
- $data = explode('.', $host);
- $n = count($data);
-
- $preg = '/[\w].+\.(com|net|org|gov|edu)\.cn$/';
- if (($n > 2) && preg_match($preg, $host)) {
-
- $host = $data[$n - 3] . '.' . $data[$n - 2] . '.' . $data[$n - 1];
- } else {
-
- $host = $data[$n - 2] . '.' . $data[$n - 1];
- }
- return $host;
- }
-
-
- function get_tid_map_1($host = '') {
- $tid_map = [
- 'zczl' => '38',
- '38' => 'zczl',
- 'gonglve' => '117',
- '117' => 'gonglve',
- 'zclw' => '116',
- '116' => 'zclw',
- 'lwck' => '127',
- '127' => 'lwck',
-
- 'anli' => '120',
- '120' => 'anli',
- 'zcsb' => '118',
- '118' => 'zcsb',
- 'xgwt' => '122',
- '122' => 'xgwt',
-
- 'fpzn' => '131',
- '131' => 'fpzn',
- 'zcdb' => '132',
- '132' => 'zcdb',
- 'lnzt' => '133',
- '133' => 'lnzt',
- 'wthz' => '111',
- '111' => 'wthz',
- 'zlwd' => '125',
- '125' => 'zlwd',
- 'zcbt' => '306',
- '306' => 'zcbt',
-
- 'zccl' => '126',
- '126' => 'zccl',
-
-
- 'zx' => '1231',
- '1231' => 'zx',
- 'zc' => '1232',
- '1232' => 'zc',
- 'cl' => '1233',
- '1233' => 'cl',
- 'cp' => '1234',
- '1234' => 'cp',
-
-
-
-
- 'zhengce' => '115',
- '115' => 'zhengce',
- '134' => 'https://zczl.'.$host
-
-
- ];
-
- return $tid_map;
- }
-
-
- function get_tid_url_2($url = '',$catid = 0,$stypeid = '0',$level='0',$type='',$topid=0,$area_id=0,$city_id=0) {
-
-
- if($url == ''){
- return false;
- }
-
-
-
-
- $web_basehost = \think\Config::get('web_basehost');
-
-
-
- $host = getTopHost($web_basehost);
-
-
-
- $url_info = parse_url($url);
- parse_str($url_info['query'], $params);
- $module = $params['m']?$params['m']:'home';
- $controller = $params['c']?$params['c']:'Lists';
- $action = $params['a']?$params['a']:'index';
- $tid = $params['tid']?$params['tid']:0;
- $aid = $params['aid']?$params['aid']:0;
- $site = $params['site']?$params['site']:0;
- $domain = $params['domain']?$params['domain']:0;
- $sitepid = $params['sitepid']?$params['sitepid']:0;
-
-
-
-
-
-
- $tid_map = get_tid_map_1($host);
-
- $module = strtolower($module);
- $controller = strtolower($controller);
- $action = strtolower($action);
-
-
- if($site !== 0 && $domain !== 0){
- $domain = 'https://'.$domain.'.'.$host.'/'.$site;
- return $domain;
- }else if($site !== 0 && $sitepid > 0){
-
- $domain = \think\Db::table('ey_citysite')->where('id',$sitepid)->value('domain');
- $domain = 'https://'.$domain.'.'.$host.'/'.$site;
- return $domain;
- }
-
-
- if ($aid > 0) {
-
-
- $cat = \think\Db::table('ey_arctype')->field('id,parent_id,topid')->where('id',$catid)->find();
-
-
- $is_pro = 0;
- if($cat['topid'] == 38){
- $is_pro = 1;
- if($cat['parent_id'] == 38){
-
- $tid = 38;
- }else{
-
- $tid = $catid;
- }
-
- if($level == '初级'){
- return $web_basehost.'/id'.$aid.'m01';
- }else if($level == '中级'){
- return $web_basehost.'/id'.$aid.'m02';
- }else if($level == '高级'){
- return $web_basehost.'/id'.$aid.'m03';
- }else{
- return $web_basehost.'/id'.$aid.'m01';
- }
-
- }else{
-
- if($cat['parent_id'] == 119){
- $tid = $catid;
- }else if($cat['parent_id'] == 67){
-
- $tid = $catid;
- }else if($cat['parent_id'] == 1230){
-
- $tid = $catid;
- }else{
- $tid = $cat['parent_id'];
- }
-
-
-
- }
-
-
- if ($module == 'home' && $controller == 'view' && $action == 'index') {
-
- if (array_key_exists($tid, $tid_map)) {
- switch ($tid_map[$tid]) {
- case 'zczl':
- return $web_basehost."/" . $tid_map[$tid] . "/jzzc" . $aid;
- break;
- case 'gonglve':
-
-
-
-
-
-
- if(strpos($url, 'site=') !== false){
-
-
-
-
-
- $domain = \think\Db::table('ey_citysite')->where('id',(int)$area_id)->value('domain');
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',117)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
-
-
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
-
- ->value('number');
-
- return 'https://'.$domain.'.'.$host.'/'.$site.'/gonglve1-'.$number;
-
- }else if('https://'.$url_info['host'] !== $host && $url_info['host'] != ''){
-
-
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',117)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
- ->value('number');
-
- return 'https://'.$url_info['host'].'/gonglve1-'.$number;
- }else{
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',117)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
- ->value('number');
-
-
-
-
- if(!empty($stypeid)){
- $stypeid = $stypeid.',0';
- $stypeid = explode(',',$stypeid);
-
-
-
-
-
- return '/zczl/jzgv'.$stypeid[0].'/'.$number;
- }else{
-
-
- return $web_basehost.'/gonglve1-'.$number;
- }
- }
-
- break;
- case 'zlwd':
-
-
-
-
- if(strpos($url, 'site=') !== false){
-
-
- $domain_id = \think\Db::table('ey_citysite')->where('domain',$site)->value('parent_id');
- $domain = \think\Db::table('ey_citysite')->where('id',$domain_id)->value('domain');
-
- if($stypeid > 0){
- return 'https://'.$domain.'.'.$host.'/'.$site.'/zlwd/zccp'.$stypeid.'/cms'.$aid;
- }else{
- return 'https://'.$domain.'.'.$host.'/'.$site.'/zlwd/cms'.$aid;
- }
-
- }else if('https://'.$url_info['host'] !== $host && $url_info['host'] != ''){
-
-
- if($stypeid > 0){
- return 'https://'.$url_info['host'].'/zlwd/zccp'.$stypeid.'/cms'.$aid;
- }else{
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',5)
- ->where('tid','=',$catid)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',$area_id)
- ->value('number');
-
- $tyname = [126=>'zlwd',825=>'zcwj',826=>'ckwj'];
- return 'https://'.$url_info['host'].'/'.$tyname[$catid].'/cms'.$number;
- }
-
- }else{
-
-
-
-
-
-
-
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',5)
- ->where('tid','=',$catid)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',$area_id)
- ->value('number');
- $tyname = [126=>'zlwd',825=>'zcwj',826=>'ckwj'];
- return 'https://www.zc10000.com/'.$tyname[$catid].'/cms'.$number;
- }
-
- break;
- case 'lwck':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',4)
- ->where('tid','=',127)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
- return $web_basehost."/" . $tid_map[$tid].'/cankao'.$number;
- break;
- case 'zclw':
-
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',4)
- ->where('tid','=',116)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
- return $web_basehost."/" . $tid_map[$tid].'/lunwen'.$number;
- break;
- case 'wthz':
-
-
-
-
-
-
- if(strpos($url, 'site=') !== false){
-
-
-
-
-
- $domain = \think\Db::table('ey_citysite')->where('id',(int)$area_id)->value('domain');
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',111)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
-
-
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
-
- ->value('number');
-
- return 'https://'.$domain.'.'.$host.'/'.$site.'/wthz'.$number;
-
- }else if('https://'.$url_info['host'] !== $host && $url_info['host'] != ''){
-
-
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',111)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
- ->value('number');
-
- return 'https://'.$url_info['host'].'/wthz'.$number;
- }else{
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',111)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
- ->value('number');
-
-
-
-
- if(!empty($stypeid)){
- $stypeid = $stypeid.',0';
- $stypeid = explode(',',$stypeid);
-
-
-
-
-
- return '/zczl/jzgv'.$stypeid[0].'/'.$number;
- }else{
-
-
- return $web_basehost.'/wthz'.$number;
- }
- }
-
-
-
- break;
- case 'zcbt':
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',306)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
- return $web_basehost."/" . $tid_map[$tid] . $number;
- break;
- case 'xgwt':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',122)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
- return $web_basehost."/" . $tid_map[$tid] . $number;
- break;
- case 'zcsb':
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',118)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
- return $web_basehost."/" . $tid_map[$tid] . $number;
- break;
- case 'anli':
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',120)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
- return $web_basehost."/" . $tid_map[$tid] . $number;
- break;
- case 'fpzn':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',131)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
-
- return $web_basehost."/" . $tid_map[$tid] .'/cms'. $number;
- break;
- case 'zcdb':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',132)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
- return $web_basehost."/" . $tid_map[$tid] .'1-'. $number;
- break;
- case 'lnzt':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',133)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
-
- return $web_basehost."/" . $tid_map[$tid] .'/cms'. $number;
- break;
- case 'cp':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',1234)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
- return $web_basehost."/" . $tid_map[$tid].$number;
- break;
- case 'zx':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',1231)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
- return $web_basehost."/" . $tid_map[$tid].$number;
- break;
- case 'cl':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',1233)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',0)
- ->value('number');
- return $web_basehost."/" . $tid_map[$tid].'/'.$number;
- break;
- case 'zc':
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',1232)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',(int)$area_id)
- ->value('number');
-
- if((int)$area_id === 0){
- return $web_basehost."/" . $tid_map[$tid].'/'.$number;
- }else{
- $domain = \think\Db::table('ey_citysite')->where('id',(int)$area_id)->value('domain');
- return $web_basehost."/" . $tid_map[$tid].'/'.$domain.'/'.$number;
- }
- break;
- case 'zhengce':
-
-
-
-
-
-
-
-
- if(strpos($url, 'site=') !== false){
-
-
-
-
-
-
- $domain = \think\Db::table('ey_citysite')->where('id',(int)$area_id)->value('domain');
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',115)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
-
-
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
-
- ->value('number');
-
-
-
- return 'https://'.$domain.'.'.$host.'/'.$site.'/zhengce/cms'.$number;
-
- }else if('https://'.$url_info['host'] !== $host && $url_info['host'] != ''){
-
-
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',115)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
- ->value('number');
-
- return 'https://'.$url_info['host'].'/zhengce/cms'.$number;
- }else{
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',2)
- ->where('tid','=',115)
- ->where('topid',0)
- ->where('parentid',0)
- ->where('aid',$aid)
- ->where('area_id',(int)$area_id)
- ->where('city_id',(int)$city_id)
- ->value('number');
-
-
-
-
- if(!empty($stypeid)){
- $stypeid = $stypeid.',0';
- $stypeid = explode(',',$stypeid);
-
-
-
-
-
- return '/zczl/jzzc'.$stypeid[0].'/'.$number;
- }else{
-
-
- return $web_basehost.'/zhengce/cms'.$number;
- }
-
- }
-
-
- }
- }else{
-
-
- return $cat['parent_id'];
- return '/jzgczc'.$aid;
- return '666';
- }
- }
- } else {
-
- if ($module == 'home' && $controller == 'lists' && $action == 'index') {
- if (array_key_exists($tid, $tid_map)) {
- if($area_id > 0 && empty($city_id)){
-
- $domain = \think\Db::table('ey_citysite')->where('id',(int)$area_id)->value('domain');
- return 'https://'.$domain.'.'.$host.'/'.$tid_map[$tid];
- }
- if($city_id > 0 && strpos($url, 'site=') !== false){
-
- $domain = \think\Db::table('ey_citysite')->where('id',(int)$area_id)->value('domain');
- return 'https://'.$domain.'.'.$host.'/'.$site.'/'.$tid_map[$tid];
- }
- if(strpos($tid_map[$tid], 'http') !== false){
-
- return $tid_map[$tid];
- }else{
- return $web_basehost."/" . $tid_map[$tid];
- }
- }else{
-
-
-
-
-
-
-
-
-
-
- if($topid == 38){
- if($type === '产品'){
-
-
-
- if((int)$area_id === 10000){
- $domain = 'www';
- }else{
- $domain = \think\Db::table('ey_citysite')->where('id',$area_id)->value('domain');
- }
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',1)
- ->where('topid',38)
- ->where('parentid',38)
- ->where('aid',$tid)
- ->where('area_id',$area_id)
- ->value('number');
-
- return 'https://'.$domain.'.'.$host.'/id'.$number;
- }else{
-
-
-
-
-
- if((int)$area_id === 10000){
- $domain = 'www';
- }else{
- $domain = \think\Db::table('ey_citysite')->where('id',$area_id)->value('domain');
- }
-
-
- $number = \think\Db::table('ey_seo_number')
- ->where('type',1)
- ->where('topid',38)
- ->where('parentid',38)
- ->where('aid',$tid)
- ->where('area_id',$area_id)
- ->value('number');
-
- return 'https://'.$domain.'.'.$host.'/id'.$number;
- }
- }
- return '555';
- }
- }
- }
- return false;
- }
-
-
-
- if (!function_exists('function_1601946443'))
- {
-
-
- function function_1601946443()
- {
- $file_1601946443 = glob('weapp/*/function.php');
- foreach ($file_1601946443 as $key => $val) {
- include_once ROOT_PATH.$val;
- }
- }
- }
|