r1877-export.php 182 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. include "root.php";
  22. require_once "resources/config.php";
  23. require_once "resources/check_auth.php";
  24. if (ifgroup("superadmin")) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. //user defined settings
  32. $export_type = "sql"; //sql, db (for sqlite)
  33. $debug = false;
  34. $invoices = false; //default false;
  35. $db_type = "sqlite"; //pgsql, sqlite, mysql
  36. //used for debugging
  37. if ($debug) {
  38. echo "<pre>\n";
  39. }
  40. //create the destination database object
  41. if ($export_type == "db") {
  42. $dest_db = new PDO('sqlite:/tmp/fusionpbx.db');
  43. }
  44. //set the headers
  45. if ($export_type == "sql" && !$debug) {
  46. header('Content-type: application/octet-binary');
  47. header('Content-Disposition: attachment; filename=database_backup.sql');
  48. }
  49. //set the timeout to two hours
  50. set_time_limit(7200);
  51. //add an rfc compliant version 4 uuid function
  52. if (!function_exists('uuid')) {
  53. function uuid() {
  54. return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  55. // 32 bits for 'time_low'
  56. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
  57. // 16 bits 'for time_mid'
  58. mt_rand( 0, 0xffff ),
  59. // 16 bits for 'time_hi_and_version',
  60. // four most significant bits holds version number 4
  61. mt_rand( 0, 0x0fff ) | 0x4000,
  62. // 16 bits, 8 bits for 'clk_seq_hi_res',
  63. // 8 bits for 'clk_seq_low',
  64. // two most significant bits holds zero and one for variant DCE1.1
  65. mt_rand( 0, 0x3fff ) | 0x8000,
  66. // 48 bits for 'node'
  67. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
  68. );
  69. }
  70. }
  71. $schema_pgsql = <<<EOD
  72. CREATE TABLE v_call_broadcasts (
  73. call_call_broadcast_uuid uuid PRIMARY KEY,
  74. domain_uuid uuid,
  75. broadcast_name text,
  76. broadcast_description text,
  77. broadcast_timeout numeric,
  78. broadcast_concurrent_limit numeric,
  79. recording_uuid uuid,
  80. broadcast_caller_id_name text,
  81. broadcast_caller_id_number text,
  82. broadcast_destination_type text,
  83. broadcast_phone_numbers text,
  84. broadcast_destination_data text);
  85. CREATE TABLE v_call_center_agents (
  86. call_center_agent_uuid uuid PRIMARY KEY,
  87. domain_uuid uuid,
  88. agent_name text,
  89. agent_type text,
  90. agent_call_timeout numeric,
  91. agent_contact text,
  92. agent_status text,
  93. agent_logout text,
  94. agent_max_no_answer numeric,
  95. agent_wrap_up_time numeric,
  96. agent_reject_delay_time numeric,
  97. agent_busy_delay_time numeric,
  98. agent_no_answer_delay_time text);
  99. CREATE TABLE v_call_center_logs (
  100. cc_uuid uuid PRIMARY KEY,
  101. domain_uuid uuid,
  102. cc_queue text,
  103. cc_action text,
  104. cc_count numeric,
  105. cc_agent text,
  106. cc_agent_system text,
  107. cc_agent_status text,
  108. cc_agent_state text,
  109. cc_agent_uuid uuid,
  110. cc_selection text,
  111. cc_cause text,
  112. cc_wait_time text,
  113. cc_talk_time text,
  114. cc_total_time text,
  115. cc_epoch numeric,
  116. cc_date timestamp,
  117. cc_agent_type text,
  118. cc_member_uuid text,
  119. cc_member_session_uuid text,
  120. cc_member_cid_name text,
  121. cc_member_cid_number text,
  122. cc_agent_called_time numeric,
  123. cc_agent_answered_time numeric,
  124. cc_member_joined_time numeric,
  125. cc_member_leaving_time numeric,
  126. cc_bridge_terminated_time numeric,
  127. cc_hangup_cause text);
  128. CREATE TABLE v_call_center_queues (
  129. call_center_queue_uuid uuid PRIMARY KEY,
  130. domain_uuid uuid,
  131. dialplan_uuid uuid,
  132. queue_name text,
  133. queue_extension text,
  134. queue_strategy text,
  135. queue_moh_sound text,
  136. queue_record_template text,
  137. queue_time_base_score text,
  138. queue_max_wait_time numeric,
  139. queue_max_wait_time_with_no_agent numeric,
  140. queue_tier_rules_apply text,
  141. queue_tier_rule_wait_second numeric,
  142. queue_tier_rule_no_agent_no_wait text,
  143. queue_timeout_action text,
  144. queue_discard_abandoned_after numeric,
  145. queue_abandoned_resume_allowed text,
  146. queue_tier_rule_wait_multiply_level text,
  147. queue_cid_prefix text,
  148. queue_description text);
  149. CREATE TABLE v_call_center_tiers (
  150. call_center_tier_uuid uuid PRIMARY KEY,
  151. domain_uuid uuid,
  152. agent_name text,
  153. queue_name text,
  154. tier_level numeric,
  155. tier_position numeric);
  156. CREATE TABLE v_conferences (
  157. domain_uuid uuid,
  158. conference_uuid uuid PRIMARY KEY,
  159. dialplan_uuid uuid,
  160. conference_name text,
  161. conference_extension text,
  162. conference_pin_number text,
  163. conference_profile text,
  164. conference_flags text,
  165. conference_order numeric,
  166. conference_description text,
  167. conference_enabled text);
  168. CREATE TABLE v_conference_users (
  169. conference_user_uuid uuid PRIMARY KEY,
  170. domain_uuid uuid,
  171. conference_uuid uuid,
  172. user_uuid uuid);
  173. CREATE TABLE v_contacts (
  174. contact_uuid uuid PRIMARY KEY,
  175. domain_uuid uuid,
  176. contact_type text,
  177. contact_organization text,
  178. contact_name_given text,
  179. contact_name_family text,
  180. contact_nickname text,
  181. contact_title text,
  182. contact_role text,
  183. contact_email text,
  184. contact_url text,
  185. contact_time_zone text,
  186. contact_note text);
  187. CREATE TABLE v_contact_addresses (
  188. contact_address_uuid uuid PRIMARY KEY,
  189. domain_uuid uuid,
  190. contact_uuid uuid,
  191. address_type text,
  192. address_street text,
  193. address_extended text,
  194. address_locality text,
  195. address_region text,
  196. address_postal_code text,
  197. address_country text,
  198. address_latitude text,
  199. address_longitude text);
  200. CREATE TABLE v_contact_phones (
  201. contact_phone_uuid uuid PRIMARY KEY,
  202. domain_uuid uuid,
  203. contact_uuid uuid,
  204. phone_type text,
  205. phone_number text);
  206. CREATE TABLE v_contact_notes (
  207. contact_note_uuid uuid PRIMARY KEY,
  208. domain_uuid uuid,
  209. contact_uuid uuid,
  210. contact_note text,
  211. last_mod_date text,
  212. last_mod_user text);
  213. CREATE TABLE v_rss (
  214. rss_uuid uuid PRIMARY KEY,
  215. domain_uuid uuid,
  216. rss_language text,
  217. rss_category text,
  218. rss_sub_category text,
  219. rss_title text,
  220. rss_link text,
  221. rss_description text,
  222. rss_img bytea,
  223. rss_optional_1 text,
  224. rss_optional_2 text,
  225. rss_optional_3 text,
  226. rss_optional_4 text,
  227. rss_optional_5 text,
  228. rss_add_date text,
  229. rss_add_user text,
  230. rss_del_date text,
  231. rss_del_user text,
  232. rss_order numeric,
  233. rss_content text,
  234. rss_group text);
  235. CREATE TABLE v_rss_sub (
  236. rss_sub_uuid uuid PRIMARY KEY,
  237. domain_uuid uuid,
  238. rss_uuid uuid,
  239. rss_sub_language text,
  240. rss_sub_title text,
  241. rss_sub_link text,
  242. rss_sub_description text,
  243. rss_sub_optional_1 text,
  244. rss_sub_optional_2 text,
  245. rss_sub_optional_3 text,
  246. rss_sub_optional_4 text,
  247. rss_sub_optional_5 text,
  248. rss_sub_add_date text,
  249. rss_sub_add_user text,
  250. rss_sub_del_user text,
  251. rss_sub_del_date text);
  252. CREATE TABLE v_rss_sub_category (
  253. rss_sub_category_uuid uuid PRIMARY KEY,
  254. domain_uuid uuid,
  255. rss_sub_category_language text,
  256. rss_category text,
  257. rss_sub_category text,
  258. rss_sub_category_description text,
  259. rss_sub_add_user text,
  260. rss_sub_add_date text);
  261. CREATE TABLE v_destinations (
  262. domain_uuid uuid,
  263. destination_uuid uuid PRIMARY KEY,
  264. destination_name text,
  265. destination_context text,
  266. destination_extension text,
  267. destination_enabled text,
  268. destination_description text);
  269. CREATE TABLE v_dialplans (
  270. domain_uuid uuid,
  271. dialplan_uuid uuid PRIMARY KEY,
  272. app_uuid uuid,
  273. dialplan_context text,
  274. dialplan_name text,
  275. dialplan_number text,
  276. dialplan_continue text,
  277. dialplan_order numeric,
  278. dialplan_enabled text,
  279. dialplan_description text);
  280. CREATE TABLE v_dialplan_details (
  281. domain_uuid uuid,
  282. dialplan_uuid uuid,
  283. dialplan_detail_uuid uuid PRIMARY KEY,
  284. dialplan_detail_tag text,
  285. dialplan_detail_type text,
  286. dialplan_detail_data text,
  287. dialplan_detail_break text,
  288. dialplan_detail_inline text,
  289. dialplan_detail_group numeric,
  290. dialplan_detail_order numeric);
  291. CREATE TABLE v_extensions (
  292. extension_uuid uuid PRIMARY KEY,
  293. domain_uuid uuid,
  294. extension text,
  295. number_alias text,
  296. password text,
  297. provisioning_list text,
  298. mailbox text,
  299. vm_password text,
  300. accountcode text,
  301. effective_caller_id_name text,
  302. effective_caller_id_number text,
  303. outbound_caller_id_name text,
  304. outbound_caller_id_number text,
  305. emergency_caller_id_number text,
  306. directory_full_name text,
  307. directory_visible text,
  308. directory_exten_visible text,
  309. limit_max numeric,
  310. limit_destination text,
  311. vm_enabled text,
  312. vm_mailto text,
  313. vm_attach_file text,
  314. vm_keep_local_after_email text,
  315. user_context text,
  316. toll_allow text,
  317. call_group text,
  318. hold_music text,
  319. auth_acl text,
  320. cidr text,
  321. sip_force_contact text,
  322. nibble_account numeric,
  323. sip_force_expires numeric,
  324. enabled text,
  325. description text,
  326. mwi_account text,
  327. sip_bypass_media text);
  328. CREATE TABLE v_extension_users (
  329. extension_user_uuid uuid PRIMARY KEY,
  330. domain_uuid uuid,
  331. extension_uuid uuid,
  332. user_uuid uuid);
  333. CREATE TABLE v_fax (
  334. fax_uuid uuid PRIMARY KEY,
  335. domain_uuid uuid,
  336. dialplan_uuid uuid,
  337. fax_extension text,
  338. fax_name text,
  339. fax_email text,
  340. fax_pin_number text,
  341. fax_caller_id_name text,
  342. fax_caller_id_number text,
  343. fax_forward_number numeric,
  344. fax_description text);
  345. CREATE TABLE v_fax_users (
  346. fax_user_uuid uuid PRIMARY KEY,
  347. domain_uuid uuid,
  348. fax_uuid uuid,
  349. user_uuid uuid);
  350. CREATE TABLE v_gateways (
  351. gateway_uuid uuid PRIMARY KEY,
  352. domain_uuid uuid,
  353. gateway text,
  354. username text,
  355. password text,
  356. distinct_to text,
  357. auth_username text,
  358. realm text,
  359. from_user text,
  360. from_domain text,
  361. proxy text,
  362. register_proxy text,
  363. outbound_proxy text,
  364. expire_seconds numeric,
  365. register text,
  366. register_transport text,
  367. retry_seconds numeric,
  368. extension text,
  369. ping text,
  370. caller_id_in_from text,
  371. supress_cng text,
  372. sip_cid_type text,
  373. extension_in_contact text,
  374. context text,
  375. profile text,
  376. enabled text,
  377. description text);
  378. CREATE TABLE v_hardware_phones (
  379. hardware_phone_uuid uuid PRIMARY KEY,
  380. domain_uuid uuid,
  381. phone_mac_address text,
  382. phone_label text,
  383. phone_vendor text,
  384. phone_model text,
  385. phone_firmware_version text,
  386. phone_provision_enable text,
  387. phone_template text,
  388. phone_username text,
  389. phone_password text,
  390. phone_time_zone text,
  391. phone_description text);
  392. CREATE TABLE v_hunt_groups (
  393. hunt_group_uuid uuid PRIMARY KEY,
  394. domain_uuid uuid,
  395. dialplan_uuid uuid,
  396. hunt_group_extension text,
  397. hunt_group_name text,
  398. hunt_group_type text,
  399. hunt_group_context text,
  400. hunt_group_timeout text,
  401. hunt_group_timeout_destination text,
  402. hunt_group_timeout_type text,
  403. hunt_group_ringback text,
  404. hunt_group_cid_name_prefix text,
  405. hunt_group_pin text,
  406. hunt_group_caller_announce text,
  407. hunt_group_call_prompt text,
  408. hunt_group_user_list text,
  409. hunt_group_enabled text,
  410. hunt_group_description text);
  411. CREATE TABLE v_hunt_group_destinations (
  412. hunt_group_destination_uuid uuid PRIMARY KEY,
  413. domain_uuid uuid,
  414. hunt_group_uuid uuid,
  415. destination_data text,
  416. destination_type text,
  417. destination_profile text,
  418. destination_timeout text,
  419. destination_order numeric,
  420. destination_enabled text,
  421. destination_description text);
  422. CREATE TABLE v_hunt_group_users (
  423. hunt_group_user_uuid uuid PRIMARY KEY,
  424. domain_uuid uuid,
  425. hunt_group_uuid uuid,
  426. user_uuid uuid);
  427. CREATE TABLE v_invoices (
  428. invoice_uuid uuid,
  429. domain_uuid uuid,
  430. contact_uuid_from uuid,
  431. contact_uuid_to uuid,
  432. invoice_number numeric,
  433. invoice_date timestamp with time zone,
  434. invoice_notes text);
  435. CREATE TABLE v_invoice_items (
  436. invoice_item_uuid uuid,
  437. domain_uuid uuid,
  438. invoice_uuid uuid,
  439. item_qty numeric,
  440. item_desc text,
  441. item_unit_price numeric);
  442. CREATE TABLE v_ivr_menus (
  443. ivr_menu_uuid uuid PRIMARY KEY,
  444. domain_uuid uuid,
  445. dialplan_uuid uuid,
  446. ivr_menu_name text,
  447. ivr_menu_extension numeric,
  448. ivr_menu_greet_long text,
  449. ivr_menu_greet_short text,
  450. ivr_menu_invalid_sound text,
  451. ivr_menu_exit_sound text,
  452. ivr_menu_confirm_macro text,
  453. ivr_menu_confirm_key text,
  454. ivr_menu_tts_engine text,
  455. ivr_menu_tts_voice text,
  456. ivr_menu_confirm_attempts numeric,
  457. ivr_menu_timeout numeric,
  458. ivr_menu_exit_app text,
  459. ivr_menu_exit_data text,
  460. ivr_menu_inter_digit_timeout numeric,
  461. ivr_menu_max_failures numeric,
  462. ivr_menu_max_timeouts numeric,
  463. ivr_menu_digit_len numeric,
  464. ivr_menu_direct_dial text,
  465. ivr_menu_enabled text,
  466. ivr_menu_description text);
  467. CREATE TABLE v_ivr_menu_options (
  468. ivr_menu_option_uuid uuid PRIMARY KEY,
  469. ivr_menu_uuid uuid,
  470. domain_uuid uuid,
  471. ivr_menu_option_digits text,
  472. ivr_menu_option_action text,
  473. ivr_menu_option_param text,
  474. ivr_menu_option_order numeric,
  475. ivr_menu_option_description text);
  476. CREATE TABLE v_modules (
  477. module_uuid uuid PRIMARY KEY,
  478. module_label text,
  479. module_name text,
  480. module_category text,
  481. module_enabled text,
  482. module_default_enabled text,
  483. module_description text);
  484. CREATE TABLE v_clips (
  485. clip_uuid uuid PRIMARY KEY,
  486. clip_name text,
  487. clip_folder text,
  488. clip_text_start text,
  489. clip_text_end text,
  490. clip_order text,
  491. clip_desc text);
  492. CREATE TABLE v_php_services (
  493. php_service_uuid uuid PRIMARY KEY,
  494. domain_uuid uuid,
  495. service_name text,
  496. service_script text,
  497. service_enabled text,
  498. service_description text);
  499. CREATE TABLE v_recordings (
  500. recording_uuid uuid PRIMARY KEY,
  501. domain_uuid uuid,
  502. recording_filename text,
  503. recording_name text,
  504. recording_description text);
  505. CREATE TABLE v_ring_groups (
  506. domain_uuid uuid,
  507. ring_group_uuid uuid,
  508. ring_group_name text,
  509. ring_group_extension text,
  510. ring_group_context text,
  511. ring_group_strategy text,
  512. ring_group_timeout_sec numeric,
  513. ring_group_timeout_app text,
  514. ring_group_timeout_data text,
  515. ring_group_enabled text,
  516. ring_group_description text,
  517. dialplan_uuid uuid);
  518. CREATE TABLE v_ring_group_extensions (
  519. ring_group_extension_uuid uuid,
  520. domain_uuid uuid,
  521. ring_group_uuid uuid,
  522. extension_uuid uuid);
  523. CREATE TABLE v_services (
  524. service_uuid uuid PRIMARY KEY,
  525. domain_uuid uuid,
  526. service_name text,
  527. service_type text,
  528. service_data text,
  529. service_cmd_start text,
  530. service_cmd_stop text,
  531. service_cmd_restart text,
  532. service_description text);
  533. CREATE TABLE v_settings (
  534. numbering_plan text,
  535. event_socket_ip_address text,
  536. event_socket_port text,
  537. event_socket_password text,
  538. xml_rpc_http_port text,
  539. xml_rpc_auth_realm text,
  540. xml_rpc_auth_user text,
  541. xml_rpc_auth_pass text,
  542. admin_pin numeric,
  543. smtp_host text,
  544. smtp_secure text,
  545. smtp_auth text,
  546. smtp_username text,
  547. smtp_password text,
  548. smtp_from text,
  549. smtp_from_name text,
  550. mod_shout_decoder text,
  551. mod_shout_volume text);
  552. CREATE TABLE v_sip_profiles (
  553. sip_profile_uuid uuid,
  554. sip_profile_name text,
  555. sip_profile_description text);
  556. CREATE TABLE v_sip_profile_settings (
  557. sip_profile_setting_uuid uuid,
  558. sip_profile_uuid uuid,
  559. sip_profile_setting_name text,
  560. sip_profile_setting_value text,
  561. sip_profile_setting_enabled text,
  562. sip_profile_setting_description text);
  563. CREATE TABLE v_software (
  564. software_name text,
  565. software_url text,
  566. software_version text);
  567. CREATE TABLE v_vars (
  568. var_uuid uuid PRIMARY KEY,
  569. var_name text,
  570. var_value text,
  571. var_cat text,
  572. var_enabled text,
  573. var_order numeric,
  574. var_description text);
  575. CREATE TABLE v_virtual_table_data (
  576. virtual_table_data_uuid uuid PRIMARY KEY,
  577. domain_uuid uuid,
  578. virtual_table_uuid uuid,
  579. virtual_data_row_uuid text,
  580. virtual_field_name text,
  581. virtual_data_field_value text,
  582. virtual_data_add_user text,
  583. virtual_data_add_date text,
  584. virtual_data_del_user text,
  585. virtual_data_del_date text,
  586. virtual_table_parent_uuid uuid,
  587. virtual_data_parent_row_uuid text);
  588. CREATE TABLE v_virtual_table_data_types_name_value (
  589. virtual_table_data_types_name_value_uuid uuid PRIMARY KEY,
  590. domain_uuid uuid,
  591. virtual_table_uuid uuid,
  592. virtual_table_field_uuid uuid,
  593. virtual_data_types_name text,
  594. virtual_data_types_value text);
  595. CREATE TABLE v_virtual_table_fields (
  596. virtual_table_field_uuid uuid PRIMARY KEY,
  597. domain_uuid uuid,
  598. virtual_table_uuid uuid,
  599. virtual_field_label text,
  600. virtual_field_name text,
  601. virtual_field_type text,
  602. virtual_field_list_hidden text,
  603. virtual_field_column text,
  604. virtual_field_required text,
  605. virtual_field_order numeric,
  606. virtual_field_order_tab numeric,
  607. virtual_field_description text,
  608. virtual_field_value text);
  609. CREATE TABLE v_virtual_tables (
  610. virtual_table_uuid uuid PRIMARY KEY,
  611. domain_uuid uuid,
  612. virtual_table_category text,
  613. virtual_table_label text,
  614. virtual_table_name text,
  615. virtual_table_auth text,
  616. virtual_table_captcha text,
  617. virtual_table_parent_uuid uuid,
  618. virtual_table_description text);
  619. CREATE TABLE v_voicemail_greetings (
  620. greeting_uuid uuid PRIMARY KEY,
  621. domain_uuid uuid,
  622. user_id text,
  623. greeting_name text,
  624. greeting_description text);
  625. CREATE TABLE v_xml_cdr (
  626. uuid uuid PRIMARY KEY,
  627. domain_uuid uuid,
  628. domain_name text,
  629. accountcode text,
  630. direction text,
  631. default_language text,
  632. context text,
  633. xml_cdr text,
  634. caller_id_name text,
  635. caller_id_number text,
  636. destination_number text,
  637. start_epoch numeric,
  638. start_stamp timestamp,
  639. answer_stamp timestamp,
  640. answer_epoch numeric,
  641. end_epoch numeric,
  642. end_stamp text,
  643. duration numeric,
  644. mduration numeric,
  645. billsec numeric,
  646. billmsec numeric,
  647. bridge_uuid text,
  648. read_codec text,
  649. read_rate text,
  650. write_codec text,
  651. write_rate text,
  652. remote_media_ip text,
  653. network_addr text,
  654. recording_file text,
  655. leg char(1),
  656. pdd_ms numeric,
  657. last_app text,
  658. last_arg text,
  659. cc_side text,
  660. cc_member_uuid uuid,
  661. cc_queue_joined_epoch text,
  662. cc_queue text,
  663. cc_member_session_uuid uuid,
  664. cc_agent text,
  665. cc_agent_type text,
  666. waitsec numeric,
  667. conference_name text,
  668. conference_uuid uuid,
  669. conference_member_id text,
  670. digits_dialed text,
  671. hangup_cause text,
  672. hangup_cause_q850 numeric,
  673. sip_hangup_disposition text);
  674. CREATE TABLE v_xmpp (
  675. xmpp_profile_uuid uuid PRIMARY KEY,
  676. domain_uuid uuid,
  677. profile_name text,
  678. username text,
  679. password text,
  680. dialplan text,
  681. context text,
  682. rtp_ip text,
  683. ext_rtp_ip text,
  684. auto_login text,
  685. sasl_type text,
  686. xmpp_server text,
  687. tls_enable text,
  688. usr_rtp_timer text,
  689. default_exten text,
  690. vad text,
  691. avatar text,
  692. candidate_acl text,
  693. local_network_acl text,
  694. enabled text,
  695. description text);
  696. CREATE TABLE v_apps (
  697. app_uuid uuid);
  698. CREATE TABLE v_databases (
  699. database_uuid uuid PRIMARY KEY,
  700. database_type text,
  701. database_host text,
  702. database_port text,
  703. database_name text,
  704. database_username text,
  705. database_password text,
  706. database_path text,
  707. database_description text);
  708. CREATE TABLE v_default_settings (
  709. default_setting_uuid uuid PRIMARY KEY,
  710. default_setting_category text,
  711. default_setting_subcategory text,
  712. default_setting_name text,
  713. default_setting_value text,
  714. default_setting_enabled text,
  715. default_setting_description text);
  716. CREATE TABLE v_domains (
  717. domain_uuid uuid PRIMARY KEY,
  718. domain_name text,
  719. domain_description text);
  720. CREATE TABLE v_domain_settings (
  721. domain_uuid uuid,
  722. domain_setting_uuid uuid PRIMARY KEY,
  723. domain_setting_category text,
  724. domain_setting_subcategory text,
  725. domain_setting_name text,
  726. domain_setting_value text,
  727. domain_setting_enabled text,
  728. domain_setting_description text);
  729. CREATE TABLE v_menus (
  730. menu_uuid uuid PRIMARY KEY,
  731. menu_name text,
  732. menu_language text,
  733. menu_description text);
  734. CREATE TABLE v_menu_items (
  735. menu_item_uuid uuid,
  736. menu_uuid uuid,
  737. menu_item_parent_uuid uuid,
  738. menu_item_title text,
  739. menu_item_link text,
  740. menu_item_category text,
  741. menu_item_protected text,
  742. menu_item_order numeric,
  743. menu_item_description text,
  744. menu_item_add_user text,
  745. menu_item_add_date text,
  746. menu_item_mod_user text,
  747. menu_item_mod_date text);
  748. CREATE TABLE v_menu_item_groups (
  749. menu_uuid uuid,
  750. menu_item_uuid uuid,
  751. group_name text);
  752. CREATE TABLE v_users (
  753. user_uuid uuid PRIMARY KEY,
  754. domain_uuid uuid,
  755. username text,
  756. password text,
  757. salt text,
  758. contact_uuid uuid,
  759. user_status text,
  760. user_add_user text,
  761. user_add_date text);
  762. CREATE TABLE v_groups (
  763. group_uuid uuid PRIMARY KEY,
  764. domain_uuid uuid,
  765. group_name text,
  766. group_description text);
  767. CREATE TABLE v_group_users (
  768. group_user_uuid uuid PRIMARY KEY,
  769. domain_uuid uuid,
  770. group_name text,
  771. user_uuid uuid);
  772. CREATE TABLE v_group_permissions (
  773. group_permission_uuid uuid PRIMARY KEY,
  774. domain_uuid uuid,
  775. permission_name text,
  776. group_name text);
  777. CREATE TABLE v_user_settings (
  778. user_setting_uuid uuid PRIMARY KEY,
  779. user_uuid uuid,
  780. user_setting_category text,
  781. user_setting_subcategory text,
  782. user_setting_name text,
  783. user_setting_value text,
  784. user_setting_enabled text,
  785. user_setting_description text);
  786. EOD;
  787. $schema_sqlite = <<<EOD
  788. CREATE TABLE v_call_broadcasts (
  789. call_call_broadcast_uuid text PRIMARY KEY,
  790. domain_uuid text,
  791. broadcast_name text,
  792. broadcast_description text,
  793. broadcast_timeout numeric,
  794. broadcast_concurrent_limit numeric,
  795. recording_uuid text,
  796. broadcast_caller_id_name text,
  797. broadcast_caller_id_number text,
  798. broadcast_destination_type text,
  799. broadcast_phone_numbers text,
  800. broadcast_destination_data text);
  801. CREATE TABLE v_call_center_agents (
  802. call_center_agent_uuid text PRIMARY KEY,
  803. domain_uuid text,
  804. agent_name text,
  805. agent_type text,
  806. agent_call_timeout numeric,
  807. agent_contact text,
  808. agent_status text,
  809. agent_logout text,
  810. agent_max_no_answer numeric,
  811. agent_wrap_up_time numeric,
  812. agent_reject_delay_time numeric,
  813. agent_busy_delay_time numeric,
  814. agent_no_answer_delay_time text);
  815. CREATE TABLE v_call_center_logs (
  816. cc_uuid text PRIMARY KEY,
  817. domain_uuid text,
  818. cc_queue text,
  819. cc_action text,
  820. cc_count numeric,
  821. cc_agent text,
  822. cc_agent_system text,
  823. cc_agent_status text,
  824. cc_agent_state text,
  825. cc_agent_uuid text,
  826. cc_selection text,
  827. cc_cause text,
  828. cc_wait_time text,
  829. cc_talk_time text,
  830. cc_total_time text,
  831. cc_epoch numeric,
  832. cc_date date,
  833. cc_agent_type text,
  834. cc_member_uuid text,
  835. cc_member_session_uuid text,
  836. cc_member_cid_name text,
  837. cc_member_cid_number text,
  838. cc_agent_called_time numeric,
  839. cc_agent_answered_time numeric,
  840. cc_member_joined_time numeric,
  841. cc_member_leaving_time numeric,
  842. cc_bridge_terminated_time numeric,
  843. cc_hangup_cause text);
  844. CREATE TABLE v_call_center_queues (
  845. call_center_queue_uuid text PRIMARY KEY,
  846. domain_uuid text,
  847. dialplan_uuid text,
  848. queue_name text,
  849. queue_extension text,
  850. queue_strategy text,
  851. queue_moh_sound text,
  852. queue_record_template text,
  853. queue_time_base_score text,
  854. queue_max_wait_time numeric,
  855. queue_max_wait_time_with_no_agent numeric,
  856. queue_tier_rules_apply text,
  857. queue_tier_rule_wait_second numeric,
  858. queue_tier_rule_no_agent_no_wait text,
  859. queue_timeout_action text,
  860. queue_discard_abandoned_after numeric,
  861. queue_abandoned_resume_allowed text,
  862. queue_tier_rule_wait_multiply_level text,
  863. queue_cid_prefix text,
  864. queue_description text);
  865. CREATE TABLE v_call_center_tiers (
  866. call_center_tier_uuid text PRIMARY KEY,
  867. domain_uuid text,
  868. agent_name text,
  869. queue_name text,
  870. tier_level numeric,
  871. tier_position numeric);
  872. CREATE TABLE v_conferences (
  873. domain_uuid text,
  874. conference_uuid text PRIMARY KEY,
  875. dialplan_uuid text,
  876. conference_name text,
  877. conference_extension text,
  878. conference_pin_number text,
  879. conference_profile text,
  880. conference_flags text,
  881. conference_order numeric,
  882. conference_description text,
  883. conference_enabled text);
  884. CREATE TABLE v_conference_users (
  885. conference_user_uuid text PRIMARY KEY,
  886. domain_uuid text,
  887. conference_uuid text,
  888. user_uuid text);
  889. CREATE TABLE v_contacts (
  890. contact_uuid text PRIMARY KEY,
  891. domain_uuid text,
  892. contact_type text,
  893. contact_organization text,
  894. contact_name_given text,
  895. contact_name_family text,
  896. contact_nickname text,
  897. contact_title text,
  898. contact_role text,
  899. contact_email text,
  900. contact_url text,
  901. contact_time_zone text,
  902. contact_note text);
  903. CREATE TABLE v_contact_addresses (
  904. contact_address_uuid text PRIMARY KEY,
  905. domain_uuid text,
  906. contact_uuid text,
  907. address_type text,
  908. address_street text,
  909. address_extended text,
  910. address_locality text,
  911. address_region text,
  912. address_postal_code text,
  913. address_country text,
  914. address_latitude text,
  915. address_longitude text);
  916. CREATE TABLE v_contact_phones (
  917. contact_phone_uuid text PRIMARY KEY,
  918. domain_uuid text,
  919. contact_uuid text,
  920. phone_type text,
  921. phone_number text);
  922. CREATE TABLE v_contact_notes (
  923. contact_note_uuid text PRIMARY KEY,
  924. domain_uuid text,
  925. contact_uuid text,
  926. contact_note text,
  927. last_mod_date text,
  928. last_mod_user text);
  929. CREATE TABLE v_rss (
  930. rss_uuid text PRIMARY KEY,
  931. domain_uuid text,
  932. rss_language text,
  933. rss_category text,
  934. rss_sub_category text,
  935. rss_title text,
  936. rss_link text,
  937. rss_description text,
  938. rss_img blob,
  939. rss_optional_1 text,
  940. rss_optional_2 text,
  941. rss_optional_3 text,
  942. rss_optional_4 text,
  943. rss_optional_5 text,
  944. rss_add_date text,
  945. rss_add_user text,
  946. rss_del_date text,
  947. rss_del_user text,
  948. rss_order numeric,
  949. rss_content text,
  950. rss_group text);
  951. CREATE TABLE v_rss_sub (
  952. rss_sub_uuid text PRIMARY KEY,
  953. domain_uuid text,
  954. rss_uuid text,
  955. rss_sub_language text,
  956. rss_sub_title text,
  957. rss_sub_link text,
  958. rss_sub_description text,
  959. rss_sub_optional_1 text,
  960. rss_sub_optional_2 text,
  961. rss_sub_optional_3 text,
  962. rss_sub_optional_4 text,
  963. rss_sub_optional_5 text,
  964. rss_sub_add_date text,
  965. rss_sub_add_user text,
  966. rss_sub_del_user text,
  967. rss_sub_del_date text);
  968. CREATE TABLE v_rss_sub_category (
  969. rss_sub_category_uuid text PRIMARY KEY,
  970. domain_uuid text,
  971. rss_sub_category_language text,
  972. rss_category text,
  973. rss_sub_category text,
  974. rss_sub_category_description text,
  975. rss_sub_add_user text,
  976. rss_sub_add_date text);
  977. CREATE TABLE v_destinations (
  978. domain_uuid text,
  979. destination_uuid text PRIMARY KEY,
  980. destination_name text,
  981. destination_context text,
  982. destination_extension text,
  983. destination_enabled text,
  984. destination_description text);
  985. CREATE TABLE v_dialplans (
  986. domain_uuid text,
  987. dialplan_uuid text PRIMARY KEY,
  988. app_uuid text,
  989. dialplan_context text,
  990. dialplan_name text,
  991. dialplan_number text,
  992. dialplan_continue text,
  993. dialplan_order numeric,
  994. dialplan_enabled text,
  995. dialplan_description text);
  996. CREATE TABLE v_dialplan_details (
  997. domain_uuid text,
  998. dialplan_uuid text,
  999. dialplan_detail_uuid text PRIMARY KEY,
  1000. dialplan_detail_tag text,
  1001. dialplan_detail_type text,
  1002. dialplan_detail_data text,
  1003. dialplan_detail_break text,
  1004. dialplan_detail_inline text,
  1005. dialplan_detail_group numeric,
  1006. dialplan_detail_order numeric);
  1007. CREATE TABLE v_extensions (
  1008. extension_uuid text PRIMARY KEY,
  1009. domain_uuid text,
  1010. extension text,
  1011. number_alias text,
  1012. password text,
  1013. provisioning_list text,
  1014. mailbox text,
  1015. vm_password text,
  1016. accountcode text,
  1017. effective_caller_id_name text,
  1018. effective_caller_id_number text,
  1019. outbound_caller_id_name text,
  1020. outbound_caller_id_number text,
  1021. emergency_caller_id_number text,
  1022. directory_full_name text,
  1023. directory_visible text,
  1024. directory_exten_visible text,
  1025. limit_max numeric,
  1026. limit_destination text,
  1027. vm_enabled text,
  1028. vm_mailto text,
  1029. vm_attach_file text,
  1030. vm_keep_local_after_email text,
  1031. user_context text,
  1032. toll_allow text,
  1033. call_group text,
  1034. hold_music text,
  1035. auth_acl text,
  1036. cidr text,
  1037. sip_force_contact text,
  1038. nibble_account numeric,
  1039. sip_force_expires numeric,
  1040. enabled text,
  1041. description text,
  1042. mwi_account text,
  1043. sip_bypass_media text);
  1044. CREATE TABLE v_extension_users (
  1045. extension_user_uuid text PRIMARY KEY,
  1046. domain_uuid text,
  1047. extension_uuid text,
  1048. user_uuid text);
  1049. CREATE TABLE v_fax (
  1050. fax_uuid text PRIMARY KEY,
  1051. domain_uuid text,
  1052. dialplan_uuid text,
  1053. fax_extension text,
  1054. fax_name text,
  1055. fax_email text,
  1056. fax_pin_number text,
  1057. fax_caller_id_name text,
  1058. fax_caller_id_number text,
  1059. fax_forward_number numeric,
  1060. fax_description text);
  1061. CREATE TABLE v_fax_users (
  1062. fax_user_uuid text PRIMARY KEY,
  1063. domain_uuid text,
  1064. fax_uuid text,
  1065. user_uuid text);
  1066. CREATE TABLE v_gateways (
  1067. gateway_uuid text PRIMARY KEY,
  1068. domain_uuid text,
  1069. gateway text,
  1070. username text,
  1071. password text,
  1072. distinct_to text,
  1073. auth_username text,
  1074. realm text,
  1075. from_user text,
  1076. from_domain text,
  1077. proxy text,
  1078. register_proxy text,
  1079. outbound_proxy text,
  1080. expire_seconds numeric,
  1081. register text,
  1082. register_transport text,
  1083. retry_seconds numeric,
  1084. extension text,
  1085. ping text,
  1086. caller_id_in_from text,
  1087. supress_cng text,
  1088. sip_cid_type text,
  1089. extension_in_contact text,
  1090. context text,
  1091. profile text,
  1092. enabled text,
  1093. description text);
  1094. CREATE TABLE v_hardware_phones (
  1095. hardware_phone_uuid text PRIMARY KEY,
  1096. domain_uuid text,
  1097. phone_mac_address text,
  1098. phone_label text,
  1099. phone_vendor text,
  1100. phone_model text,
  1101. phone_firmware_version text,
  1102. phone_provision_enable text,
  1103. phone_template text,
  1104. phone_username text,
  1105. phone_password text,
  1106. phone_time_zone text,
  1107. phone_description text);
  1108. CREATE TABLE v_hunt_groups (
  1109. hunt_group_uuid text PRIMARY KEY,
  1110. domain_uuid text,
  1111. dialplan_uuid text,
  1112. hunt_group_extension text,
  1113. hunt_group_name text,
  1114. hunt_group_type text,
  1115. hunt_group_context text,
  1116. hunt_group_timeout text,
  1117. hunt_group_timeout_destination text,
  1118. hunt_group_timeout_type text,
  1119. hunt_group_ringback text,
  1120. hunt_group_cid_name_prefix text,
  1121. hunt_group_pin text,
  1122. hunt_group_caller_announce text,
  1123. hunt_group_call_prompt text,
  1124. hunt_group_user_list text,
  1125. hunt_group_enabled text,
  1126. hunt_group_description text);
  1127. CREATE TABLE v_hunt_group_destinations (
  1128. hunt_group_destination_uuid text PRIMARY KEY,
  1129. domain_uuid text,
  1130. hunt_group_uuid text,
  1131. destination_data text,
  1132. destination_type text,
  1133. destination_profile text,
  1134. destination_timeout text,
  1135. destination_order numeric,
  1136. destination_enabled text,
  1137. destination_description text);
  1138. CREATE TABLE v_hunt_group_users (
  1139. hunt_group_user_uuid text PRIMARY KEY,
  1140. domain_uuid text,
  1141. hunt_group_uuid text,
  1142. user_uuid text);
  1143. CREATE TABLE v_invoices (
  1144. invoice_uuid text,
  1145. domain_uuid text,
  1146. contact_uuid_from text,
  1147. contact_uuid_to text,
  1148. invoice_number numeric,
  1149. invoice_date datetime,
  1150. invoice_notes text);
  1151. CREATE TABLE v_invoice_items (
  1152. invoice_item_uuid text,
  1153. domain_uuid text,
  1154. invoice_uuid text,
  1155. item_qty numeric,
  1156. item_desc text,
  1157. item_unit_price numeric);
  1158. CREATE TABLE v_ivr_menus (
  1159. ivr_menu_uuid text PRIMARY KEY,
  1160. domain_uuid text,
  1161. dialplan_uuid text,
  1162. ivr_menu_name text,
  1163. ivr_menu_extension numeric,
  1164. ivr_menu_greet_long text,
  1165. ivr_menu_greet_short text,
  1166. ivr_menu_invalid_sound text,
  1167. ivr_menu_exit_sound text,
  1168. ivr_menu_confirm_macro text,
  1169. ivr_menu_confirm_key text,
  1170. ivr_menu_tts_engine text,
  1171. ivr_menu_tts_voice text,
  1172. ivr_menu_confirm_attempts numeric,
  1173. ivr_menu_timeout numeric,
  1174. ivr_menu_exit_app text,
  1175. ivr_menu_exit_data text,
  1176. ivr_menu_inter_digit_timeout numeric,
  1177. ivr_menu_max_failures numeric,
  1178. ivr_menu_max_timeouts numeric,
  1179. ivr_menu_digit_len numeric,
  1180. ivr_menu_direct_dial text,
  1181. ivr_menu_enabled text,
  1182. ivr_menu_description text);
  1183. CREATE TABLE v_ivr_menu_options (
  1184. ivr_menu_option_uuid text PRIMARY KEY,
  1185. ivr_menu_uuid text,
  1186. domain_uuid text,
  1187. ivr_menu_option_digits text,
  1188. ivr_menu_option_action text,
  1189. ivr_menu_option_param text,
  1190. ivr_menu_option_order numeric,
  1191. ivr_menu_option_description text);
  1192. CREATE TABLE v_modules (
  1193. module_uuid text PRIMARY KEY,
  1194. module_label text,
  1195. module_name text,
  1196. module_category text,
  1197. module_enabled text,
  1198. module_default_enabled text,
  1199. module_description text);
  1200. CREATE TABLE v_clips (
  1201. clip_uuid text PRIMARY KEY,
  1202. clip_name text,
  1203. clip_folder text,
  1204. clip_text_start text,
  1205. clip_text_end text,
  1206. clip_order text,
  1207. clip_desc text);
  1208. CREATE TABLE v_php_services (
  1209. php_service_uuid text PRIMARY KEY,
  1210. domain_uuid text,
  1211. service_name text,
  1212. service_script text,
  1213. service_enabled text,
  1214. service_description text);
  1215. CREATE TABLE v_recordings (
  1216. recording_uuid text PRIMARY KEY,
  1217. domain_uuid text,
  1218. recording_filename text,
  1219. recording_name text,
  1220. recording_description text);
  1221. CREATE TABLE v_ring_groups (
  1222. domain_uuid text,
  1223. ring_group_uuid text,
  1224. ring_group_name text,
  1225. ring_group_extension text,
  1226. ring_group_context text,
  1227. ring_group_strategy text,
  1228. ring_group_timeout_sec numeric,
  1229. ring_group_timeout_app text,
  1230. ring_group_timeout_data text,
  1231. ring_group_enabled text,
  1232. ring_group_description text,
  1233. dialplan_uuid text);
  1234. CREATE TABLE v_ring_group_extensions (
  1235. ring_group_extension_uuid text,
  1236. domain_uuid text,
  1237. ring_group_uuid text,
  1238. extension_uuid text);
  1239. CREATE TABLE v_services (
  1240. service_uuid text PRIMARY KEY,
  1241. domain_uuid text,
  1242. service_name text,
  1243. service_type text,
  1244. service_data text,
  1245. service_cmd_start text,
  1246. service_cmd_stop text,
  1247. service_cmd_restart text,
  1248. service_description text);
  1249. CREATE TABLE v_settings (
  1250. numbering_plan text,
  1251. event_socket_ip_address text,
  1252. event_socket_port text,
  1253. event_socket_password text,
  1254. xml_rpc_http_port text,
  1255. xml_rpc_auth_realm text,
  1256. xml_rpc_auth_user text,
  1257. xml_rpc_auth_pass text,
  1258. admin_pin numeric,
  1259. smtp_host text,
  1260. smtp_secure text,
  1261. smtp_auth text,
  1262. smtp_username text,
  1263. smtp_password text,
  1264. smtp_from text,
  1265. smtp_from_name text,
  1266. mod_shout_decoder text,
  1267. mod_shout_volume text);
  1268. CREATE TABLE v_sip_profiles (
  1269. sip_profile_uuid text,
  1270. sip_profile_name text,
  1271. sip_profile_description text);
  1272. CREATE TABLE v_sip_profile_settings (
  1273. sip_profile_setting_uuid text,
  1274. sip_profile_uuid text,
  1275. sip_profile_setting_name text,
  1276. sip_profile_setting_value text,
  1277. sip_profile_setting_enabled text,
  1278. sip_profile_setting_description text);
  1279. CREATE TABLE v_software (
  1280. software_name text,
  1281. software_url text,
  1282. software_version text);
  1283. CREATE TABLE v_vars (
  1284. var_uuid text PRIMARY KEY,
  1285. var_name text,
  1286. var_value text,
  1287. var_cat text,
  1288. var_enabled text,
  1289. var_order numeric,
  1290. var_description text);
  1291. CREATE TABLE v_virtual_table_data (
  1292. virtual_table_data_uuid text PRIMARY KEY,
  1293. domain_uuid text,
  1294. virtual_table_uuid text,
  1295. virtual_data_row_uuid text,
  1296. virtual_field_name text,
  1297. virtual_data_field_value text,
  1298. virtual_data_add_user text,
  1299. virtual_data_add_date text,
  1300. virtual_data_del_user text,
  1301. virtual_data_del_date text,
  1302. virtual_table_parent_uuid text,
  1303. virtual_data_parent_row_uuid text);
  1304. CREATE TABLE v_virtual_table_data_types_name_value (
  1305. virtual_table_data_types_name_value_uuid text PRIMARY KEY,
  1306. domain_uuid text,
  1307. virtual_table_uuid text,
  1308. virtual_table_field_uuid text,
  1309. virtual_data_types_name text,
  1310. virtual_data_types_value text);
  1311. CREATE TABLE v_virtual_table_fields (
  1312. virtual_table_field_uuid text PRIMARY KEY,
  1313. domain_uuid text,
  1314. virtual_table_uuid text,
  1315. virtual_field_label text,
  1316. virtual_field_name text,
  1317. virtual_field_type text,
  1318. virtual_field_list_hidden text,
  1319. virtual_field_column text,
  1320. virtual_field_required text,
  1321. virtual_field_order numeric,
  1322. virtual_field_order_tab numeric,
  1323. virtual_field_description text,
  1324. virtual_field_value text);
  1325. CREATE TABLE v_virtual_tables (
  1326. virtual_table_uuid text PRIMARY KEY,
  1327. domain_uuid text,
  1328. virtual_table_category text,
  1329. virtual_table_label text,
  1330. virtual_table_name text,
  1331. virtual_table_auth text,
  1332. virtual_table_captcha text,
  1333. virtual_table_parent_uuid text,
  1334. virtual_table_description text);
  1335. CREATE TABLE v_voicemail_greetings (
  1336. greeting_uuid text PRIMARY KEY,
  1337. domain_uuid text,
  1338. user_id text,
  1339. greeting_name text,
  1340. greeting_description text);
  1341. CREATE TABLE v_xml_cdr (
  1342. uuid text PRIMARY KEY,
  1343. domain_uuid text,
  1344. domain_name text,
  1345. accountcode text,
  1346. direction text,
  1347. default_language text,
  1348. context text,
  1349. xml_cdr text,
  1350. caller_id_name text,
  1351. caller_id_number text,
  1352. destination_number text,
  1353. start_epoch numeric,
  1354. start_stamp date,
  1355. answer_stamp date,
  1356. answer_epoch numeric,
  1357. end_epoch numeric,
  1358. end_stamp text,
  1359. duration numeric,
  1360. mduration numeric,
  1361. billsec numeric,
  1362. billmsec numeric,
  1363. bridge_uuid text,
  1364. read_codec text,
  1365. read_rate text,
  1366. write_codec text,
  1367. write_rate text,
  1368. remote_media_ip text,
  1369. network_addr text,
  1370. recording_file text,
  1371. leg text,
  1372. pdd_ms numeric,
  1373. last_app text,
  1374. last_arg text,
  1375. cc_side text,
  1376. cc_member_uuid text,
  1377. cc_queue_joined_epoch text,
  1378. cc_queue text,
  1379. cc_member_session_uuid text,
  1380. cc_agent text,
  1381. cc_agent_type text,
  1382. waitsec numeric,
  1383. conference_name text,
  1384. conference_uuid text,
  1385. conference_member_id text,
  1386. digits_dialed text,
  1387. hangup_cause text,
  1388. hangup_cause_q850 numeric,
  1389. sip_hangup_disposition text);
  1390. CREATE TABLE v_xmpp (
  1391. xmpp_profile_uuid text PRIMARY KEY,
  1392. domain_uuid text,
  1393. profile_name text,
  1394. username text,
  1395. password text,
  1396. dialplan text,
  1397. context text,
  1398. rtp_ip text,
  1399. ext_rtp_ip text,
  1400. auto_login text,
  1401. sasl_type text,
  1402. xmpp_server text,
  1403. tls_enable text,
  1404. usr_rtp_timer text,
  1405. default_exten text,
  1406. vad text,
  1407. avatar text,
  1408. candidate_acl text,
  1409. local_network_acl text,
  1410. enabled text,
  1411. description text);
  1412. CREATE TABLE v_apps (
  1413. app_uuid text);
  1414. CREATE TABLE v_databases (
  1415. database_uuid text PRIMARY KEY,
  1416. database_type text,
  1417. database_host text,
  1418. database_port text,
  1419. database_name text,
  1420. database_username text,
  1421. database_password text,
  1422. database_path text,
  1423. database_description text);
  1424. CREATE TABLE v_default_settings (
  1425. default_setting_uuid text PRIMARY KEY,
  1426. default_setting_category text,
  1427. default_setting_subcategory text,
  1428. default_setting_name text,
  1429. default_setting_value text,
  1430. default_setting_enabled text,
  1431. default_setting_description text);
  1432. CREATE TABLE v_domains (
  1433. domain_uuid text PRIMARY KEY,
  1434. domain_name text,
  1435. domain_description text);
  1436. CREATE TABLE v_domain_settings (
  1437. domain_uuid text,
  1438. domain_setting_uuid text PRIMARY KEY,
  1439. domain_setting_category text,
  1440. domain_setting_subcategory text,
  1441. domain_setting_name text,
  1442. domain_setting_value text,
  1443. domain_setting_enabled text,
  1444. domain_setting_description text);
  1445. CREATE TABLE v_menus (
  1446. menu_uuid text PRIMARY KEY,
  1447. menu_name text,
  1448. menu_language text,
  1449. menu_description text);
  1450. CREATE TABLE v_menu_items (
  1451. menu_item_uuid text,
  1452. menu_uuid text,
  1453. menu_item_parent_uuid text,
  1454. menu_item_title text,
  1455. menu_item_link text,
  1456. menu_item_category text,
  1457. menu_item_protected text,
  1458. menu_item_order numeric,
  1459. menu_item_description text,
  1460. menu_item_add_user text,
  1461. menu_item_add_date text,
  1462. menu_item_mod_user text,
  1463. menu_item_mod_date text);
  1464. CREATE TABLE v_menu_item_groups (
  1465. menu_uuid text,
  1466. menu_item_uuid text,
  1467. group_name text);
  1468. CREATE TABLE v_users (
  1469. user_uuid text PRIMARY KEY,
  1470. domain_uuid text,
  1471. username text,
  1472. password text,
  1473. salt text,
  1474. contact_uuid text,
  1475. user_status text,
  1476. user_add_user text,
  1477. user_add_date text);
  1478. CREATE TABLE v_groups (
  1479. group_uuid text PRIMARY KEY,
  1480. domain_uuid text,
  1481. group_name text,
  1482. group_description text);
  1483. CREATE TABLE v_group_users (
  1484. group_user_uuid text PRIMARY KEY,
  1485. domain_uuid text,
  1486. group_name text,
  1487. user_uuid text);
  1488. CREATE TABLE v_group_permissions (
  1489. group_permission_uuid text PRIMARY KEY,
  1490. domain_uuid text,
  1491. permission_name text,
  1492. group_name text);
  1493. CREATE TABLE v_user_settings (
  1494. user_setting_uuid text PRIMARY KEY,
  1495. user_uuid text,
  1496. user_setting_category text,
  1497. user_setting_subcategory text,
  1498. user_setting_name text,
  1499. user_setting_value text,
  1500. user_setting_enabled text,
  1501. user_setting_description text);
  1502. EOD;
  1503. $schema_mysql = <<<EOD
  1504. CREATE TABLE v_call_broadcasts (
  1505. call_call_broadcast_uuid char(36) PRIMARY KEY,
  1506. domain_uuid char(36),
  1507. broadcast_name text,
  1508. broadcast_description text,
  1509. broadcast_timeout numeric,
  1510. broadcast_concurrent_limit numeric,
  1511. recording_uuid char(36),
  1512. broadcast_caller_id_name text,
  1513. broadcast_caller_id_number text,
  1514. broadcast_destination_type text,
  1515. broadcast_phone_numbers text,
  1516. broadcast_destination_data text) ENGINE=INNODB;
  1517. CREATE TABLE v_call_center_agents (
  1518. call_center_agent_uuid char(36) PRIMARY KEY,
  1519. domain_uuid char(36),
  1520. agent_name text,
  1521. agent_type text,
  1522. agent_call_timeout numeric,
  1523. agent_contact text,
  1524. agent_status text,
  1525. agent_logout text,
  1526. agent_max_no_answer numeric,
  1527. agent_wrap_up_time numeric,
  1528. agent_reject_delay_time numeric,
  1529. agent_busy_delay_time numeric,
  1530. agent_no_answer_delay_time text) ENGINE=INNODB;
  1531. CREATE TABLE v_call_center_logs (
  1532. cc_uuid char(36) PRIMARY KEY,
  1533. domain_uuid char(36),
  1534. cc_queue text,
  1535. cc_action text,
  1536. cc_count numeric,
  1537. cc_agent text,
  1538. cc_agent_system text,
  1539. cc_agent_status text,
  1540. cc_agent_state text,
  1541. cc_agent_uuid char(36),
  1542. cc_selection text,
  1543. cc_cause text,
  1544. cc_wait_time text,
  1545. cc_talk_time text,
  1546. cc_total_time text,
  1547. cc_epoch numeric,
  1548. cc_date timestamp,
  1549. cc_agent_type text,
  1550. cc_member_uuid text,
  1551. cc_member_session_uuid text,
  1552. cc_member_cid_name text,
  1553. cc_member_cid_number text,
  1554. cc_agent_called_time numeric,
  1555. cc_agent_answered_time numeric,
  1556. cc_member_joined_time numeric,
  1557. cc_member_leaving_time numeric,
  1558. cc_bridge_terminated_time numeric,
  1559. cc_hangup_cause text) ENGINE=INNODB;
  1560. CREATE TABLE v_call_center_queues (
  1561. call_center_queue_uuid char(36) PRIMARY KEY,
  1562. domain_uuid char(36),
  1563. dialplan_uuid char(36),
  1564. queue_name text,
  1565. queue_extension text,
  1566. queue_strategy text,
  1567. queue_moh_sound text,
  1568. queue_record_template text,
  1569. queue_time_base_score text,
  1570. queue_max_wait_time numeric,
  1571. queue_max_wait_time_with_no_agent numeric,
  1572. queue_tier_rules_apply text,
  1573. queue_tier_rule_wait_second numeric,
  1574. queue_tier_rule_no_agent_no_wait text,
  1575. queue_timeout_action text,
  1576. queue_discard_abandoned_after numeric,
  1577. queue_abandoned_resume_allowed text,
  1578. queue_tier_rule_wait_multiply_level text,
  1579. queue_cid_prefix text,
  1580. queue_description text) ENGINE=INNODB;
  1581. CREATE TABLE v_call_center_tiers (
  1582. call_center_tier_uuid char(36) PRIMARY KEY,
  1583. domain_uuid char(36),
  1584. agent_name text,
  1585. queue_name text,
  1586. tier_level numeric,
  1587. tier_position numeric) ENGINE=INNODB;
  1588. CREATE TABLE v_conferences (
  1589. domain_uuid char(36),
  1590. conference_uuid char(36) PRIMARY KEY,
  1591. dialplan_uuid char(36),
  1592. conference_name text,
  1593. conference_extension text,
  1594. conference_pin_number text,
  1595. conference_profile text,
  1596. conference_flags text,
  1597. conference_order numeric,
  1598. conference_description text,
  1599. conference_enabled text) ENGINE=INNODB;
  1600. CREATE TABLE v_conference_users (
  1601. conference_user_uuid char(36) PRIMARY KEY,
  1602. domain_uuid char(36),
  1603. conference_uuid char(36),
  1604. user_uuid char(36)) ENGINE=INNODB;
  1605. CREATE TABLE v_contacts (
  1606. contact_uuid char(36) PRIMARY KEY,
  1607. domain_uuid char(36),
  1608. contact_type text,
  1609. contact_organization text,
  1610. contact_name_given text,
  1611. contact_name_family text,
  1612. contact_nickname text,
  1613. contact_title text,
  1614. contact_role text,
  1615. contact_email text,
  1616. contact_url text,
  1617. contact_time_zone text,
  1618. contact_note text) ENGINE=INNODB;
  1619. CREATE TABLE v_contact_addresses (
  1620. contact_address_uuid char(36) PRIMARY KEY,
  1621. domain_uuid char(36),
  1622. contact_uuid char(36),
  1623. address_type text,
  1624. address_street text,
  1625. address_extended text,
  1626. address_locality text,
  1627. address_region text,
  1628. address_postal_code text,
  1629. address_country text,
  1630. address_latitude text,
  1631. address_longitude text) ENGINE=INNODB;
  1632. CREATE TABLE v_contact_phones (
  1633. contact_phone_uuid char(36) PRIMARY KEY,
  1634. domain_uuid char(36),
  1635. contact_uuid char(36),
  1636. phone_type text,
  1637. phone_number text) ENGINE=INNODB;
  1638. CREATE TABLE v_contact_notes (
  1639. contact_note_uuid char(36) PRIMARY KEY,
  1640. domain_uuid char(36),
  1641. contact_uuid char(36),
  1642. contact_note text,
  1643. last_mod_date text,
  1644. last_mod_user text) ENGINE=INNODB;
  1645. CREATE TABLE v_rss (
  1646. rss_uuid char(36) PRIMARY KEY,
  1647. domain_uuid char(36),
  1648. rss_language text,
  1649. rss_category text,
  1650. rss_sub_category text,
  1651. rss_title text,
  1652. rss_link text,
  1653. rss_description text,
  1654. rss_img blob,
  1655. rss_optional_1 text,
  1656. rss_optional_2 text,
  1657. rss_optional_3 text,
  1658. rss_optional_4 text,
  1659. rss_optional_5 text,
  1660. rss_add_date text,
  1661. rss_add_user text,
  1662. rss_del_date text,
  1663. rss_del_user text,
  1664. rss_order numeric,
  1665. rss_content text,
  1666. rss_group text) ENGINE=INNODB;
  1667. CREATE TABLE v_rss_sub (
  1668. rss_sub_uuid char(36) PRIMARY KEY,
  1669. domain_uuid char(36),
  1670. rss_uuid char(36),
  1671. rss_sub_language text,
  1672. rss_sub_title text,
  1673. rss_sub_link text,
  1674. rss_sub_description text,
  1675. rss_sub_optional_1 text,
  1676. rss_sub_optional_2 text,
  1677. rss_sub_optional_3 text,
  1678. rss_sub_optional_4 text,
  1679. rss_sub_optional_5 text,
  1680. rss_sub_add_date text,
  1681. rss_sub_add_user text,
  1682. rss_sub_del_user text,
  1683. rss_sub_del_date text) ENGINE=INNODB;
  1684. CREATE TABLE v_rss_sub_category (
  1685. rss_sub_category_uuid char(36) PRIMARY KEY,
  1686. domain_uuid char(36),
  1687. rss_sub_category_language text,
  1688. rss_category text,
  1689. rss_sub_category text,
  1690. rss_sub_category_description text,
  1691. rss_sub_add_user text,
  1692. rss_sub_add_date text) ENGINE=INNODB;
  1693. CREATE TABLE v_destinations (
  1694. domain_uuid char(36),
  1695. destination_uuid char(36) PRIMARY KEY,
  1696. destination_name text,
  1697. destination_context text,
  1698. destination_extension text,
  1699. destination_enabled text,
  1700. destination_description text) ENGINE=INNODB;
  1701. CREATE TABLE v_dialplans (
  1702. domain_uuid char(36),
  1703. dialplan_uuid char(36) PRIMARY KEY,
  1704. app_uuid char(36),
  1705. dialplan_context text,
  1706. dialplan_name text,
  1707. dialplan_number text,
  1708. dialplan_continue text,
  1709. dialplan_order numeric,
  1710. dialplan_enabled text,
  1711. dialplan_description text) ENGINE=INNODB;
  1712. CREATE TABLE v_dialplan_details (
  1713. domain_uuid char(36),
  1714. dialplan_uuid char(36),
  1715. dialplan_detail_uuid char(36) PRIMARY KEY,
  1716. dialplan_detail_tag text,
  1717. dialplan_detail_type text,
  1718. dialplan_detail_data text,
  1719. dialplan_detail_break text,
  1720. dialplan_detail_inline text,
  1721. dialplan_detail_group numeric,
  1722. dialplan_detail_order numeric) ENGINE=INNODB;
  1723. CREATE TABLE v_extensions (
  1724. extension_uuid char(36) PRIMARY KEY,
  1725. domain_uuid char(36),
  1726. extension text,
  1727. number_alias text,
  1728. password text,
  1729. provisioning_list text,
  1730. mailbox text,
  1731. vm_password text,
  1732. accountcode text,
  1733. effective_caller_id_name text,
  1734. effective_caller_id_number text,
  1735. outbound_caller_id_name text,
  1736. outbound_caller_id_number text,
  1737. emergency_caller_id_number text,
  1738. directory_full_name text,
  1739. directory_visible text,
  1740. directory_exten_visible text,
  1741. limit_max numeric,
  1742. limit_destination text,
  1743. vm_enabled text,
  1744. vm_mailto text,
  1745. vm_attach_file text,
  1746. vm_keep_local_after_email text,
  1747. user_context text,
  1748. toll_allow text,
  1749. call_group text,
  1750. hold_music text,
  1751. auth_acl text,
  1752. cidr text,
  1753. sip_force_contact text,
  1754. nibble_account numeric,
  1755. sip_force_expires numeric,
  1756. enabled text,
  1757. description text,
  1758. mwi_account text,
  1759. sip_bypass_media text) ENGINE=INNODB;
  1760. CREATE TABLE v_extension_users (
  1761. extension_user_uuid char(36) PRIMARY KEY,
  1762. domain_uuid char(36),
  1763. extension_uuid char(36),
  1764. user_uuid char(36)) ENGINE=INNODB;
  1765. CREATE TABLE v_fax (
  1766. fax_uuid char(36) PRIMARY KEY,
  1767. domain_uuid char(36),
  1768. dialplan_uuid char(36),
  1769. fax_extension text,
  1770. fax_name text,
  1771. fax_email text,
  1772. fax_pin_number text,
  1773. fax_caller_id_name text,
  1774. fax_caller_id_number text,
  1775. fax_forward_number numeric,
  1776. fax_description text) ENGINE=INNODB;
  1777. CREATE TABLE v_fax_users (
  1778. fax_user_uuid char(36) PRIMARY KEY,
  1779. domain_uuid char(36),
  1780. fax_uuid char(36),
  1781. user_uuid char(36)) ENGINE=INNODB;
  1782. CREATE TABLE v_gateways (
  1783. gateway_uuid char(36) PRIMARY KEY,
  1784. domain_uuid char(36),
  1785. gateway text,
  1786. username text,
  1787. password text,
  1788. distinct_to text,
  1789. auth_username text,
  1790. realm text,
  1791. from_user text,
  1792. from_domain text,
  1793. proxy text,
  1794. register_proxy text,
  1795. outbound_proxy text,
  1796. expire_seconds numeric,
  1797. register text,
  1798. register_transport text,
  1799. retry_seconds numeric,
  1800. extension text,
  1801. ping text,
  1802. caller_id_in_from text,
  1803. supress_cng text,
  1804. sip_cid_type text,
  1805. extension_in_contact text,
  1806. context text,
  1807. profile text,
  1808. enabled text,
  1809. description text) ENGINE=INNODB;
  1810. CREATE TABLE v_hardware_phones (
  1811. hardware_phone_uuid char(36) PRIMARY KEY,
  1812. domain_uuid char(36),
  1813. phone_mac_address text,
  1814. phone_label text,
  1815. phone_vendor text,
  1816. phone_model text,
  1817. phone_firmware_version text,
  1818. phone_provision_enable text,
  1819. phone_template text,
  1820. phone_username text,
  1821. phone_password text,
  1822. phone_time_zone text,
  1823. phone_description text) ENGINE=INNODB;
  1824. CREATE TABLE v_hunt_groups (
  1825. hunt_group_uuid char(36) PRIMARY KEY,
  1826. domain_uuid char(36),
  1827. dialplan_uuid char(36),
  1828. hunt_group_extension text,
  1829. hunt_group_name text,
  1830. hunt_group_type text,
  1831. hunt_group_context text,
  1832. hunt_group_timeout text,
  1833. hunt_group_timeout_destination text,
  1834. hunt_group_timeout_type text,
  1835. hunt_group_ringback text,
  1836. hunt_group_cid_name_prefix text,
  1837. hunt_group_pin text,
  1838. hunt_group_caller_announce text,
  1839. hunt_group_call_prompt text,
  1840. hunt_group_user_list text,
  1841. hunt_group_enabled text,
  1842. hunt_group_description text) ENGINE=INNODB;
  1843. CREATE TABLE v_hunt_group_destinations (
  1844. hunt_group_destination_uuid char(36) PRIMARY KEY,
  1845. domain_uuid char(36),
  1846. hunt_group_uuid char(36),
  1847. destination_data text,
  1848. destination_type text,
  1849. destination_profile text,
  1850. destination_timeout text,
  1851. destination_order numeric,
  1852. destination_enabled text,
  1853. destination_description text) ENGINE=INNODB;
  1854. CREATE TABLE v_hunt_group_users (
  1855. hunt_group_user_uuid char(36) PRIMARY KEY,
  1856. domain_uuid char(36),
  1857. hunt_group_uuid char(36),
  1858. user_uuid char(36)) ENGINE=INNODB;
  1859. CREATE TABLE v_invoices (
  1860. invoice_uuid char(36),
  1861. domain_uuid char(36),
  1862. contact_uuid_from char(36),
  1863. contact_uuid_to char(36),
  1864. invoice_number numeric,
  1865. invoice_date timestamp,
  1866. invoice_notes text) ENGINE=INNODB;
  1867. CREATE TABLE v_invoice_items (
  1868. invoice_item_uuid char(36),
  1869. domain_uuid char(36),
  1870. invoice_uuid char(36),
  1871. item_qty numeric,
  1872. item_desc text,
  1873. item_unit_price decimal(10,2)) ENGINE=INNODB;
  1874. CREATE TABLE v_ivr_menus (
  1875. ivr_menu_uuid char(36) PRIMARY KEY,
  1876. domain_uuid char(36),
  1877. dialplan_uuid char(36),
  1878. ivr_menu_name text,
  1879. ivr_menu_extension numeric,
  1880. ivr_menu_greet_long text,
  1881. ivr_menu_greet_short text,
  1882. ivr_menu_invalid_sound text,
  1883. ivr_menu_exit_sound text,
  1884. ivr_menu_confirm_macro text,
  1885. ivr_menu_confirm_key text,
  1886. ivr_menu_tts_engine text,
  1887. ivr_menu_tts_voice text,
  1888. ivr_menu_confirm_attempts numeric,
  1889. ivr_menu_timeout numeric,
  1890. ivr_menu_exit_app text,
  1891. ivr_menu_exit_data text,
  1892. ivr_menu_inter_digit_timeout numeric,
  1893. ivr_menu_max_failures numeric,
  1894. ivr_menu_max_timeouts numeric,
  1895. ivr_menu_digit_len numeric,
  1896. ivr_menu_direct_dial text,
  1897. ivr_menu_enabled text,
  1898. ivr_menu_description text) ENGINE=INNODB;
  1899. CREATE TABLE v_ivr_menu_options (
  1900. ivr_menu_option_uuid char(36) PRIMARY KEY,
  1901. ivr_menu_uuid char(36),
  1902. domain_uuid char(36),
  1903. ivr_menu_option_digits text,
  1904. ivr_menu_option_action text,
  1905. ivr_menu_option_param text,
  1906. ivr_menu_option_order numeric,
  1907. ivr_menu_option_description text) ENGINE=INNODB;
  1908. CREATE TABLE v_modules (
  1909. module_uuid char(36) PRIMARY KEY,
  1910. module_label text,
  1911. module_name text,
  1912. module_category text,
  1913. module_enabled text,
  1914. module_default_enabled text,
  1915. module_description text) ENGINE=INNODB;
  1916. CREATE TABLE v_clips (
  1917. clip_uuid char(36) PRIMARY KEY,
  1918. clip_name text,
  1919. clip_folder text,
  1920. clip_text_start text,
  1921. clip_text_end text,
  1922. clip_order text,
  1923. clip_desc text) ENGINE=INNODB;
  1924. CREATE TABLE v_php_services (
  1925. php_service_uuid char(36) PRIMARY KEY,
  1926. domain_uuid char(36),
  1927. service_name text,
  1928. service_script text,
  1929. service_enabled text,
  1930. service_description text) ENGINE=INNODB;
  1931. CREATE TABLE v_recordings (
  1932. recording_uuid char(36) PRIMARY KEY,
  1933. domain_uuid char(36),
  1934. recording_filename text,
  1935. recording_name text,
  1936. recording_description text) ENGINE=INNODB;
  1937. CREATE TABLE v_ring_groups (
  1938. domain_uuid char(36),
  1939. ring_group_uuid char(36),
  1940. ring_group_name text,
  1941. ring_group_extension text,
  1942. ring_group_context text,
  1943. ring_group_strategy text,
  1944. ring_group_timeout_sec numeric,
  1945. ring_group_timeout_app text,
  1946. ring_group_timeout_data text,
  1947. ring_group_enabled text,
  1948. ring_group_description text,
  1949. dialplan_uuid char(36)) ENGINE=INNODB;
  1950. CREATE TABLE v_ring_group_extensions (
  1951. ring_group_extension_uuid char(36),
  1952. domain_uuid char(36),
  1953. ring_group_uuid char(36),
  1954. extension_uuid char(36)) ENGINE=INNODB;
  1955. CREATE TABLE v_services (
  1956. service_uuid char(36) PRIMARY KEY,
  1957. domain_uuid char(36),
  1958. service_name text,
  1959. service_type text,
  1960. service_data text,
  1961. service_cmd_start text,
  1962. service_cmd_stop text,
  1963. service_cmd_restart text,
  1964. service_description text) ENGINE=INNODB;
  1965. CREATE TABLE v_settings (
  1966. numbering_plan text,
  1967. event_socket_ip_address text,
  1968. event_socket_port text,
  1969. event_socket_password text,
  1970. xml_rpc_http_port text,
  1971. xml_rpc_auth_realm text,
  1972. xml_rpc_auth_user text,
  1973. xml_rpc_auth_pass text,
  1974. admin_pin numeric,
  1975. smtp_host text,
  1976. smtp_secure text,
  1977. smtp_auth text,
  1978. smtp_username text,
  1979. smtp_password text,
  1980. smtp_from text,
  1981. smtp_from_name text,
  1982. mod_shout_decoder text,
  1983. mod_shout_volume text) ENGINE=INNODB;
  1984. CREATE TABLE v_sip_profiles (
  1985. sip_profile_uuid char(36),
  1986. sip_profile_name text,
  1987. sip_profile_description text) ENGINE=INNODB;
  1988. CREATE TABLE v_sip_profile_settings (
  1989. sip_profile_setting_uuid char(36),
  1990. sip_profile_uuid char(36),
  1991. sip_profile_setting_name text,
  1992. sip_profile_setting_value text,
  1993. sip_profile_setting_enabled text,
  1994. sip_profile_setting_description text) ENGINE=INNODB;
  1995. CREATE TABLE v_software (
  1996. software_name text,
  1997. software_url text,
  1998. software_version text) ENGINE=INNODB;
  1999. CREATE TABLE v_vars (
  2000. var_uuid char(36) PRIMARY KEY,
  2001. var_name text,
  2002. var_value text,
  2003. var_cat text,
  2004. var_enabled text,
  2005. var_order numeric,
  2006. var_description text) ENGINE=INNODB;
  2007. CREATE TABLE v_virtual_table_data (
  2008. virtual_table_data_uuid char(36) PRIMARY KEY,
  2009. domain_uuid char(36),
  2010. virtual_table_uuid char(36),
  2011. virtual_data_row_uuid text,
  2012. virtual_field_name text,
  2013. virtual_data_field_value text,
  2014. virtual_data_add_user text,
  2015. virtual_data_add_date text,
  2016. virtual_data_del_user text,
  2017. virtual_data_del_date text,
  2018. virtual_table_parent_uuid char(36),
  2019. virtual_data_parent_row_uuid text) ENGINE=INNODB;
  2020. CREATE TABLE v_virtual_table_data_types_name_value (
  2021. virtual_table_data_types_name_value_uuid char(36) PRIMARY KEY,
  2022. domain_uuid char(36),
  2023. virtual_table_uuid char(36),
  2024. virtual_table_field_uuid char(36),
  2025. virtual_data_types_name text,
  2026. virtual_data_types_value text) ENGINE=INNODB;
  2027. CREATE TABLE v_virtual_table_fields (
  2028. virtual_table_field_uuid char(36) PRIMARY KEY,
  2029. domain_uuid char(36),
  2030. virtual_table_uuid char(36),
  2031. virtual_field_label text,
  2032. virtual_field_name text,
  2033. virtual_field_type text,
  2034. virtual_field_list_hidden text,
  2035. virtual_field_column text,
  2036. virtual_field_required text,
  2037. virtual_field_order numeric,
  2038. virtual_field_order_tab numeric,
  2039. virtual_field_description text,
  2040. virtual_field_value text) ENGINE=INNODB;
  2041. CREATE TABLE v_virtual_tables (
  2042. virtual_table_uuid char(36) PRIMARY KEY,
  2043. domain_uuid char(36),
  2044. virtual_table_category text,
  2045. virtual_table_label text,
  2046. virtual_table_name text,
  2047. virtual_table_auth text,
  2048. virtual_table_captcha text,
  2049. virtual_table_parent_uuid char(36),
  2050. virtual_table_description text) ENGINE=INNODB;
  2051. CREATE TABLE v_voicemail_greetings (
  2052. greeting_uuid char(36) PRIMARY KEY,
  2053. domain_uuid char(36),
  2054. user_id text,
  2055. greeting_name text,
  2056. greeting_description text) ENGINE=INNODB;
  2057. CREATE TABLE v_xml_cdr (
  2058. uuid char(36) PRIMARY KEY,
  2059. domain_uuid char(36),
  2060. domain_name text,
  2061. accountcode text,
  2062. direction text,
  2063. default_language text,
  2064. context text,
  2065. xml_cdr text,
  2066. caller_id_name text,
  2067. caller_id_number text,
  2068. destination_number text,
  2069. start_epoch bigint,
  2070. start_stamp timestamp,
  2071. answer_stamp timestamp,
  2072. answer_epoch bigint,
  2073. end_epoch bigint,
  2074. end_stamp text,
  2075. duration numeric,
  2076. mduration numeric,
  2077. billsec numeric,
  2078. billmsec numeric,
  2079. bridge_uuid text,
  2080. read_codec text,
  2081. read_rate text,
  2082. write_codec text,
  2083. write_rate text,
  2084. remote_media_ip text,
  2085. network_addr text,
  2086. recording_file text,
  2087. leg char(1),
  2088. pdd_ms smallint,
  2089. last_app text,
  2090. last_arg text,
  2091. cc_side text,
  2092. cc_member_uuid char(36),
  2093. cc_queue_joined_epoch text,
  2094. cc_queue text,
  2095. cc_member_session_uuid char(36),
  2096. cc_agent text,
  2097. cc_agent_type text,
  2098. waitsec numeric,
  2099. conference_name text,
  2100. conference_uuid char(36),
  2101. conference_member_id text,
  2102. digits_dialed text,
  2103. hangup_cause text,
  2104. hangup_cause_q850 numeric,
  2105. sip_hangup_disposition text) ENGINE=INNODB;
  2106. CREATE TABLE v_xmpp (
  2107. xmpp_profile_uuid char(36) PRIMARY KEY,
  2108. domain_uuid char(36),
  2109. profile_name text,
  2110. username text,
  2111. password text,
  2112. dialplan text,
  2113. context text,
  2114. rtp_ip text,
  2115. ext_rtp_ip text,
  2116. auto_login text,
  2117. sasl_type text,
  2118. xmpp_server text,
  2119. tls_enable text,
  2120. usr_rtp_timer text,
  2121. default_exten text,
  2122. vad text,
  2123. avatar text,
  2124. candidate_acl text,
  2125. local_network_acl text,
  2126. enabled text,
  2127. description text) ENGINE=INNODB;
  2128. CREATE TABLE v_apps (
  2129. app_uuid char(36)) ENGINE=INNODB;
  2130. CREATE TABLE v_databases (
  2131. database_uuid char(36) PRIMARY KEY,
  2132. database_type text,
  2133. database_host text,
  2134. database_port text,
  2135. database_name text,
  2136. database_username text,
  2137. database_password text,
  2138. database_path text,
  2139. database_description text) ENGINE=INNODB;
  2140. CREATE TABLE v_default_settings (
  2141. default_setting_uuid char(36) PRIMARY KEY,
  2142. default_setting_category text,
  2143. default_setting_subcategory text,
  2144. default_setting_name text,
  2145. default_setting_value text,
  2146. default_setting_enabled text,
  2147. default_setting_description text) ENGINE=INNODB;
  2148. CREATE TABLE v_domains (
  2149. domain_uuid char(36) PRIMARY KEY,
  2150. domain_name text,
  2151. domain_description text) ENGINE=INNODB;
  2152. CREATE TABLE v_domain_settings (
  2153. domain_uuid char(36),
  2154. domain_setting_uuid char(36) PRIMARY KEY,
  2155. domain_setting_category text,
  2156. domain_setting_subcategory text,
  2157. domain_setting_name text,
  2158. domain_setting_value text,
  2159. domain_setting_enabled text,
  2160. domain_setting_description text) ENGINE=INNODB;
  2161. CREATE TABLE v_menus (
  2162. menu_uuid char(36) PRIMARY KEY,
  2163. menu_name text,
  2164. menu_language text,
  2165. menu_description text) ENGINE=INNODB;
  2166. CREATE TABLE v_menu_items (
  2167. menu_item_uuid char(36),
  2168. menu_uuid char(36),
  2169. menu_item_parent_uuid char(36),
  2170. menu_item_title text,
  2171. menu_item_link text,
  2172. menu_item_category text,
  2173. menu_item_protected text,
  2174. menu_item_order numeric,
  2175. menu_item_description text,
  2176. menu_item_add_user text,
  2177. menu_item_add_date text,
  2178. menu_item_mod_user text,
  2179. menu_item_mod_date text) ENGINE=INNODB;
  2180. CREATE TABLE v_menu_item_groups (
  2181. menu_uuid char(36),
  2182. menu_item_uuid char(36),
  2183. group_name text) ENGINE=INNODB;
  2184. CREATE TABLE v_users (
  2185. user_uuid char(36) PRIMARY KEY,
  2186. domain_uuid char(36),
  2187. username text,
  2188. password text,
  2189. salt text,
  2190. contact_uuid char(36),
  2191. user_status text,
  2192. user_add_user text,
  2193. user_add_date text) ENGINE=INNODB;
  2194. CREATE TABLE v_groups (
  2195. group_uuid char(36) PRIMARY KEY,
  2196. domain_uuid char(36),
  2197. group_name text,
  2198. group_description text) ENGINE=INNODB;
  2199. CREATE TABLE v_group_users (
  2200. group_user_uuid char(36) PRIMARY KEY,
  2201. domain_uuid char(36),
  2202. group_name text,
  2203. user_uuid char(36)) ENGINE=INNODB;
  2204. CREATE TABLE v_group_permissions (
  2205. group_permission_uuid char(36) PRIMARY KEY,
  2206. domain_uuid char(36),
  2207. permission_name text,
  2208. group_name text) ENGINE=INNODB;
  2209. CREATE TABLE v_user_settings (
  2210. user_setting_uuid char(36) PRIMARY KEY,
  2211. user_uuid char(36),
  2212. user_setting_category text,
  2213. user_setting_subcategory text,
  2214. user_setting_name text,
  2215. user_setting_value text,
  2216. user_setting_enabled text,
  2217. user_setting_description text) ENGINE=INNODB;
  2218. EOD;
  2219. //add the create table statements
  2220. if ($db_type == "pgsql") {
  2221. echo $schema_pgsql."\n";
  2222. }
  2223. if ($db_type == "sqlite") {
  2224. echo $schema_sqlite."\n";
  2225. }
  2226. if ($db_type == "mysql") {
  2227. echo $schema_mysql."\n";
  2228. }
  2229. //get the domain array and make it easily accessible by the v_id
  2230. $sql = "select v_id, v_domain as domain_name, v_description as domain_description from v_system_settings ";
  2231. $prep_statement = $db->prepare($sql);
  2232. $prep_statement->execute();
  2233. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2234. foreach ($result as &$row) {
  2235. $v_id = $row['v_id'];
  2236. $domain_array[$v_id]['domain_name'] = check_str($row['domain_name']);
  2237. $domain_array[$v_id]['domain_uuid'] = uuid();
  2238. $domain_array[$v_id]['domain_description'] = check_str($row['domain_description']);
  2239. $sql = "insert into v_domains ";
  2240. $sql .= "(";
  2241. $sql .= "domain_uuid, ";
  2242. $sql .= "domain_name, ";
  2243. $sql .= "domain_description ";
  2244. $sql .= ")";
  2245. $sql .= "values ";
  2246. $sql .= "(";
  2247. $sql .= "'".$domain_array[$v_id]['domain_uuid']."', ";
  2248. $sql .= "'".$domain_array[$v_id]['domain_name']."', ";
  2249. $sql .= "'".$domain_array[$v_id]['domain_description']."' ";
  2250. $sql .= ")";
  2251. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2252. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2253. unset($sql);
  2254. }
  2255. unset ($prep_statement);
  2256. //export the default settings path
  2257. $sql = "select * from v_system_settings ";
  2258. $sql .= "limit 1 ";
  2259. $prep_statement = $db->prepare($sql);
  2260. $prep_statement->execute();
  2261. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2262. foreach ($result as &$row) {
  2263. //general
  2264. $v_id = check_str($row["v_id"]);
  2265. $domain_name = check_str($row["v_domain"]);
  2266. //switch
  2267. $switch_base_dir = check_str($row["v_dir"]);
  2268. $switch_bin_dir = check_str($row["bin_dir"]);
  2269. $switch_conf_dir = check_str($row["v_conf_dir"]);
  2270. $switch_db_dir = check_str($row["v_db_dir"]);
  2271. $switch_dialplan_dir = check_str($row["v_dialplan_default_dir"]);
  2272. if (substr($switch_dialplan_dir, -(strlen($domain_name))) == $domain_name) {
  2273. $switch_dialplan_dir = substr($switch_dialplan_dir, 0, -(strlen($domain_name)+1));
  2274. }
  2275. $switch_extensions_dir = check_str($row["v_extensions_dir"]);
  2276. if (substr($switch_extensions_dir, -(strlen($domain_name))) == $domain_name) {
  2277. $switch_extensions_dir = substr($switch_extensions_dir, 0, -(strlen($domain_name)+1));
  2278. }
  2279. $switch_gateways_dir = check_str($row["v_gateways_dir"]);
  2280. $switch_grammar_dir = check_str($row["v_grammar_dir"]);
  2281. $switch_log_dir = check_str($row["v_log_dir"]);
  2282. $switch_mod_dir = check_str($row["v_mod_dir"]);
  2283. if (strlen($row["v_provisioning_tftp_dir"]) > 0) { $switch_provision_dir = check_str($row["v_provisioning_tftp_dir"]); }
  2284. if (strlen($row["v_provisioning_ftp_dir"]) > 0) { $switch_provision_dir = check_str($row["v_provisioning_ftp_dir"]); }
  2285. if (strlen($row["v_provisioning_https_dir"]) > 0) { $switch_provision_dir = check_str($row["v_provisioning_https_dir"]); }
  2286. if (strlen($row["v_provisioning_http_dir"]) > 0) { $switch_provision_dir = check_str($row["v_provisioning_http_dir"]); }
  2287. $switch_recordings_dir = check_str($row["v_recordings_dir"]);
  2288. if (substr($switch_recordings_dir, -(strlen($domain_name))) == $domain_name) {
  2289. $switch_recordings_dir = substr($switch_extensions_dir, 0, -(strlen($domain_name)+1));
  2290. }
  2291. $switch_scripts_dir = check_str($row["v_scripts_dir"]);
  2292. $switch_sounds_dir = check_str($row["v_sounds_dir"]);
  2293. $switch_storage_dir = check_str($row["v_storage_dir"]);
  2294. $switch_voicemail_dir = check_str($row["v_voicemail_dir"]);
  2295. //server
  2296. $server_startup_script_dir = check_str($row["v_startup_script_dir"]);
  2297. $server_backup_dir = check_str($row["v_backup_dir"]);
  2298. $server_temp_dir = check_str($row["tmp_dir"]);
  2299. //domain
  2300. $domain_menu_uuid = strtolower(check_str($row["v_menu_uuid"]));
  2301. $domain_time_zone = check_str($row["v_time_zone"]);
  2302. $domain_template_name = check_str($row["v_template_name"]);
  2303. //add the default settings
  2304. $x = 0;
  2305. $tmp[$x]['name'] = 'uuid';
  2306. $tmp[$x]['value'] = $domain_menu_uuid;
  2307. $tmp[$x]['category'] = 'domain';
  2308. $tmp[$x]['subcategory'] = 'menu';
  2309. $tmp[$x]['enabled'] = 'true';
  2310. $x++;
  2311. $tmp[$x]['name'] = 'name';
  2312. $tmp[$x]['value'] = $domain_time_zone;
  2313. $tmp[$x]['category'] = 'domain';
  2314. $tmp[$x]['subcategory'] = 'time_zone';
  2315. $tmp[$x]['enabled'] = 'true';
  2316. $x++;
  2317. $tmp[$x]['name'] = 'name';
  2318. $tmp[$x]['value'] = $domain_template_name;
  2319. $tmp[$x]['category'] = 'domain';
  2320. $tmp[$x]['subcategory'] = 'template';
  2321. $tmp[$x]['enabled'] = 'true';
  2322. $x++;
  2323. $tmp[$x]['name'] = 'dir';
  2324. $tmp[$x]['value'] = $server_temp_dir;
  2325. $tmp[$x]['category'] = 'server';
  2326. $tmp[$x]['subcategory'] = 'temp';
  2327. $tmp[$x]['enabled'] = 'true';
  2328. $x++;
  2329. $tmp[$x]['name'] = 'dir';
  2330. $tmp[$x]['value'] = $server_startup_script_dir;
  2331. $tmp[$x]['category'] = 'server';
  2332. $tmp[$x]['subcategory'] = 'startup_script';
  2333. $tmp[$x]['enabled'] = 'true';
  2334. $x++;
  2335. $tmp[$x]['name'] = 'dir';
  2336. $tmp[$x]['value'] = $server_backup_dir;
  2337. $tmp[$x]['category'] = 'server';
  2338. $tmp[$x]['subcategory'] = 'backup';
  2339. $tmp[$x]['enabled'] = 'true';
  2340. $x++;
  2341. $tmp[$x]['name'] = 'dir';
  2342. $tmp[$x]['value'] = $switch_bin_dir;
  2343. $tmp[$x]['category'] = 'switch';
  2344. $tmp[$x]['subcategory'] = 'bin';
  2345. $tmp[$x]['enabled'] = 'true';
  2346. $x++;
  2347. $tmp[$x]['name'] = 'dir';
  2348. $tmp[$x]['value'] = $install_switch_base_dir;
  2349. $tmp[$x]['category'] = 'switch';
  2350. $tmp[$x]['subcategory'] = 'base';
  2351. $tmp[$x]['enabled'] = 'true';
  2352. $x++;
  2353. $tmp[$x]['name'] = 'dir';
  2354. $tmp[$x]['value'] = $switch_conf_dir;
  2355. $tmp[$x]['category'] = 'switch';
  2356. $tmp[$x]['subcategory'] = 'conf';
  2357. $tmp[$x]['enabled'] = 'true';
  2358. $x++;
  2359. $tmp[$x]['name'] = 'dir';
  2360. $tmp[$x]['value'] = $switch_db_dir;
  2361. $tmp[$x]['category'] = 'switch';
  2362. $tmp[$x]['subcategory'] = 'db';
  2363. $tmp[$x]['enabled'] = 'true';
  2364. $x++;
  2365. $tmp[$x]['name'] = 'dir';
  2366. $tmp[$x]['value'] = $switch_log_dir;
  2367. $tmp[$x]['category'] = 'switch';
  2368. $tmp[$x]['subcategory'] = 'log';
  2369. $tmp[$x]['enabled'] = 'true';
  2370. $x++;
  2371. $tmp[$x]['name'] = 'dir';
  2372. $tmp[$x]['value'] = $switch_extensions_dir;
  2373. $tmp[$x]['category'] = 'switch';
  2374. $tmp[$x]['subcategory'] = 'extensions';
  2375. $tmp[$x]['enabled'] = 'true';
  2376. $x++;
  2377. $tmp[$x]['name'] = 'dir';
  2378. $tmp[$x]['value'] = $switch_gateways_dir;
  2379. $tmp[$x]['category'] = 'switch';
  2380. $tmp[$x]['subcategory'] = 'gateways';
  2381. $tmp[$x]['enabled'] = 'true';
  2382. $x++;
  2383. $tmp[$x]['name'] = 'dir';
  2384. $tmp[$x]['value'] = $switch_dialplan_dir;
  2385. $tmp[$x]['category'] = 'switch';
  2386. $tmp[$x]['subcategory'] = 'dialplan';
  2387. $tmp[$x]['enabled'] = 'true';
  2388. $x++;
  2389. $tmp[$x]['name'] = 'dir';
  2390. $tmp[$x]['value'] = $switch_mod_dir;
  2391. $tmp[$x]['category'] = 'switch';
  2392. $tmp[$x]['subcategory'] = 'mod';
  2393. $tmp[$x]['enabled'] = 'true';
  2394. $x++;
  2395. $tmp[$x]['name'] = 'dir';
  2396. $tmp[$x]['value'] = $switch_scripts_dir;
  2397. $tmp[$x]['category'] = 'switch';
  2398. $tmp[$x]['subcategory'] = 'scripts';
  2399. $tmp[$x]['enabled'] = 'true';
  2400. $x++;
  2401. $tmp[$x]['name'] = 'dir';
  2402. $tmp[$x]['value'] = $switch_grammar_dir;
  2403. $tmp[$x]['category'] = 'switch';
  2404. $tmp[$x]['subcategory'] = 'grammar';
  2405. $tmp[$x]['enabled'] = 'true';
  2406. $x++;
  2407. $tmp[$x]['name'] = 'dir';
  2408. $tmp[$x]['value'] = $switch_storage_dir;
  2409. $tmp[$x]['category'] = 'switch';
  2410. $tmp[$x]['subcategory'] = 'storage';
  2411. $tmp[$x]['enabled'] = 'true';
  2412. $x++;
  2413. $tmp[$x]['name'] = 'dir';
  2414. $tmp[$x]['value'] = $switch_voicemail_dir;
  2415. $tmp[$x]['category'] = 'switch';
  2416. $tmp[$x]['subcategory'] = 'voicemail';
  2417. $tmp[$x]['enabled'] = 'true';
  2418. $x++;
  2419. $tmp[$x]['name'] = 'dir';
  2420. $tmp[$x]['value'] = $switch_recordings_dir;
  2421. $tmp[$x]['category'] = 'switch';
  2422. $tmp[$x]['subcategory'] = 'recordings';
  2423. $tmp[$x]['enabled'] = 'true';
  2424. $x++;
  2425. $tmp[$x]['name'] = 'dir';
  2426. $tmp[$x]['value'] = $switch_sounds_dir;
  2427. $tmp[$x]['category'] = 'switch';
  2428. $tmp[$x]['subcategory'] = 'sounds';
  2429. $tmp[$x]['enabled'] = 'true';
  2430. $x++;
  2431. $tmp[$x]['name'] = 'dir';
  2432. $tmp[$x]['value'] = $switch_provision_dir;
  2433. $tmp[$x]['category'] = 'switch';
  2434. $tmp[$x]['subcategory'] = 'provision';
  2435. $tmp[$x]['enabled'] = 'false';
  2436. $x++;
  2437. //$dest_db->beginTransaction();
  2438. foreach($tmp as $row) {
  2439. $sql = "insert into v_default_settings ";
  2440. $sql .= "(";
  2441. $sql .= "default_setting_uuid, ";
  2442. $sql .= "default_setting_name, ";
  2443. $sql .= "default_setting_value, ";
  2444. $sql .= "default_setting_category, ";
  2445. $sql .= "default_setting_subcategory, ";
  2446. $sql .= "default_setting_enabled ";
  2447. $sql .= ") ";
  2448. $sql .= "values ";
  2449. $sql .= "(";
  2450. $sql .= "'".uuid()."', ";
  2451. $sql .= "'".$row['name']."', ";
  2452. $sql .= "'".$row['value']."', ";
  2453. $sql .= "'".$row['category']."', ";
  2454. $sql .= "'".$row['subcategory']."', ";
  2455. $sql .= "'".$row['enabled']."' ";
  2456. $sql .= ")";
  2457. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2458. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2459. unset($sql);
  2460. }
  2461. //$dest_db->commit();
  2462. unset($tmp);
  2463. }
  2464. unset ($prep_statement);
  2465. //get the user array
  2466. $sql = "select username, v_id from v_users ";
  2467. $prep_statement = $db->prepare($sql);
  2468. $prep_statement->execute();
  2469. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2470. foreach ($result as &$row) {
  2471. $v_id = check_str($row["v_id"]);
  2472. $username = check_str($row["username"]);
  2473. $user_array[$v_id][$username]['user_uuid'] = uuid();
  2474. $user_array[$v_id][$username]['contact_uuid'] = uuid();
  2475. }
  2476. //print_r($user_array);
  2477. unset ($prep_statement);
  2478. //export the group members and add them into group users
  2479. $sql = "select * from v_group_members ";
  2480. $prep_statement = $db->prepare($sql);
  2481. $prep_statement->execute();
  2482. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2483. foreach ($result as &$row) {
  2484. $group_user_uuid = uuid();
  2485. $v_id = check_str($row["v_id"]);
  2486. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  2487. $username = check_str($row["username"]);
  2488. $group_name = check_str($row["group_id"]);
  2489. $user_uuid = $user_array[$v_id][$username]['user_uuid'];
  2490. if (strlen($domain_uuid) > 0 && strlen($user_uuid) > 0) {
  2491. $sql = "insert into v_group_users ";
  2492. $sql .= "(";
  2493. $sql .= "group_user_uuid, ";
  2494. $sql .= "domain_uuid, ";
  2495. $sql .= "group_name, ";
  2496. $sql .= "user_uuid ";
  2497. $sql .= ")";
  2498. $sql .= "values ";
  2499. $sql .= "(";
  2500. $sql .= "'".$group_user_uuid."', ";
  2501. $sql .= "'".$domain_uuid."', ";
  2502. $sql .= "'".$group_name."', ";
  2503. if (strlen($user_uuid) > 0) {
  2504. $sql .= "'".$user_uuid."' ";
  2505. }
  2506. else {
  2507. $sql .= "null ";
  2508. }
  2509. $sql .= ")";
  2510. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2511. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2512. }
  2513. }
  2514. unset ($prep_statement);
  2515. //export the group permissions
  2516. $sql = "select * from v_group_permissions ";
  2517. $prep_statement = $db->prepare($sql);
  2518. $prep_statement->execute();
  2519. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2520. foreach ($result as &$row) {
  2521. $group_permission_uuid = uuid();
  2522. $v_id = check_str($row["v_id"]);
  2523. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  2524. $permission_name = check_str($row["permission_id"]);
  2525. $group_name = check_str($row["group_id"]);
  2526. if (strlen($domain_uuid) > 0) {
  2527. $sql = "insert into v_group_permissions ";
  2528. $sql .= "(";
  2529. $sql .= "group_permission_uuid, ";
  2530. $sql .= "domain_uuid, ";
  2531. $sql .= "permission_name, ";
  2532. $sql .= "group_name ";
  2533. $sql .= ")";
  2534. $sql .= "values ";
  2535. $sql .= "(";
  2536. $sql .= "'".$group_permission_uuid."', ";
  2537. $sql .= "'".$domain_uuid."', ";
  2538. $sql .= "'".$permission_name."', ";
  2539. $sql .= "'".$group_name."' ";
  2540. $sql .= ")";
  2541. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2542. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2543. }
  2544. }
  2545. unset ($prep_statement);
  2546. //export the groups
  2547. $sql = "select * from v_groups ";
  2548. $prep_statement = $db->prepare($sql);
  2549. $prep_statement->execute();
  2550. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2551. foreach ($result as &$row) {
  2552. $group_uuid = uuid();
  2553. $v_id = check_str($row["v_id"]);
  2554. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  2555. $group_name = check_str($row["group_id"]);
  2556. $group_description = check_str($row["group_desc"]);
  2557. if (strlen($domain_uuid) > 0) {
  2558. $sql = "insert into v_groups ";
  2559. $sql .= "(";
  2560. $sql .= "group_uuid, ";
  2561. $sql .= "domain_uuid, ";
  2562. $sql .= "group_name, ";
  2563. $sql .= "group_description ";
  2564. $sql .= ")";
  2565. $sql .= "values ";
  2566. $sql .= "(";
  2567. $sql .= "'".$group_uuid."', ";
  2568. $sql .= "'".$domain_uuid."', ";
  2569. $sql .= "'".$group_name."', ";
  2570. $sql .= "'".$group_description."' ";
  2571. $sql .= ")";
  2572. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2573. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2574. }
  2575. }
  2576. unset ($prep_statement);
  2577. //export the menus
  2578. $sql = "select * from v_menus ";
  2579. $prep_statement = $db->prepare($sql);
  2580. $prep_statement->execute();
  2581. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2582. foreach ($result as &$row) {
  2583. $menu_uuid = check_str($row["menu_uuid"]);
  2584. $menu_name = check_str($row["menu_name"]);
  2585. $menu_language = check_str($row["menu_language"]);
  2586. $menu_description = check_str($row["menu_desc"]);
  2587. $sql = "insert into v_menus ";
  2588. $sql .= "(";
  2589. $sql .= "menu_uuid, ";
  2590. $sql .= "menu_name, ";
  2591. $sql .= "menu_language, ";
  2592. $sql .= "menu_description ";
  2593. $sql .= ")";
  2594. $sql .= "values ";
  2595. $sql .= "(";
  2596. $sql .= "'".$menu_uuid."', ";
  2597. $sql .= "'".$menu_name."', ";
  2598. $sql .= "'".$menu_language."', ";
  2599. $sql .= "'".$menu_description."' ";
  2600. $sql .= ")";
  2601. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2602. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2603. }
  2604. unset ($prep_statement);
  2605. //export the menu items
  2606. $sql = "select * from v_menu_items ";
  2607. $prep_statement = $db->prepare($sql);
  2608. $prep_statement->execute();
  2609. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2610. foreach ($result as &$row) {
  2611. $menu_item_uuid = strtolower(check_str($row["menu_item_uuid"]));
  2612. $menu_uuid = strtolower(check_str($row["menu_uuid"]));
  2613. $menu_item_parent_uuid = strtolower(check_str($row["menu_item_parent_uuid"]));
  2614. $menu_item_title = check_str($row["menu_item_title"]);
  2615. $menu_item_link = check_str($row["menu_item_str"]);
  2616. $menu_item_category = check_str($row["menu_item_category"]);
  2617. $menu_item_protected = check_str($row["menu_item_protected"]);
  2618. $menu_item_order = check_str($row["menu_item_order"]);
  2619. $menu_item_description = check_str($row["menu_item_desc"]);
  2620. $menu_item_add_user = check_str($row["menu_item_add_user"]);
  2621. $menu_item_add_date = check_str($row["menu_item_add_date"]);
  2622. $menu_item_mod_user = check_str($row["menu_item_mod_user"]);
  2623. $menu_item_mod_date = check_str($row["menu_item_mod_date"]);
  2624. $sql = "insert into v_menu_items ";
  2625. $sql .= "(";
  2626. $sql .= "menu_item_uuid, ";
  2627. $sql .= "menu_uuid, ";
  2628. $sql .= "menu_item_parent_uuid, ";
  2629. $sql .= "menu_item_title, ";
  2630. $sql .= "menu_item_link, ";
  2631. $sql .= "menu_item_category, ";
  2632. $sql .= "menu_item_protected, ";
  2633. $sql .= "menu_item_order, ";
  2634. $sql .= "menu_item_description, ";
  2635. $sql .= "menu_item_add_user, ";
  2636. $sql .= "menu_item_add_date, ";
  2637. $sql .= "menu_item_mod_user, ";
  2638. $sql .= "menu_item_mod_date ";
  2639. $sql .= ")";
  2640. $sql .= "values ";
  2641. $sql .= "(";
  2642. $sql .= "'".$menu_item_uuid."', ";
  2643. $sql .= "'".$menu_uuid."', ";
  2644. if (strlen($menu_item_parent_uuid) > 0) {
  2645. $sql .= "'".$menu_item_parent_uuid."', ";
  2646. }
  2647. else {
  2648. $sql .= "null, ";
  2649. }
  2650. $sql .= "'".$menu_item_title."', ";
  2651. $sql .= "'".$menu_item_link."', ";
  2652. $sql .= "'".$menu_item_category."', ";
  2653. $sql .= "'".$menu_item_protected."', ";
  2654. $sql .= "'".$menu_item_order."', ";
  2655. $sql .= "'".$menu_item_description."', ";
  2656. $sql .= "'".$menu_item_add_user."', ";
  2657. $sql .= "'".$menu_item_add_date."', ";
  2658. $sql .= "'".$menu_item_mod_user."', ";
  2659. $sql .= "'".$menu_item_mod_date."' ";
  2660. $sql .= ")";
  2661. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2662. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2663. }
  2664. unset ($prep_statement);
  2665. //export the groups assigned to the menu itmes
  2666. $sql = "select * from v_menu_item_groups ";
  2667. $prep_statement = $db->prepare($sql);
  2668. $prep_statement->execute();
  2669. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2670. foreach ($result as &$row) {
  2671. $menu_uuid = check_str($row["menu_uuid"]);
  2672. $menu_item_uuid = check_str($row["menu_item_uuid"]);
  2673. $group_name = check_str($row["group_id"]);
  2674. if (strlen($menu_item_uuid) > 0) {
  2675. $sql = "insert into v_menu_item_groups ";
  2676. $sql .= "(";
  2677. $sql .= "menu_uuid, ";
  2678. $sql .= "menu_item_uuid, ";
  2679. $sql .= "group_name ";
  2680. $sql .= ")";
  2681. $sql .= "values ";
  2682. $sql .= "(";
  2683. $sql .= "'".$menu_uuid."', ";
  2684. $sql .= "'".$menu_item_uuid."', ";
  2685. $sql .= "'".$group_name."' ";
  2686. $sql .= ")";
  2687. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2688. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2689. }
  2690. }
  2691. unset ($prep_statement);
  2692. //export the users
  2693. $sql = "select * from v_users ";
  2694. $prep_statement = $db->prepare($sql);
  2695. $prep_statement->execute();
  2696. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2697. foreach ($result as &$row) {
  2698. $v_id = check_str($row["v_id"]);
  2699. $username = check_str($row["username"]);
  2700. $user_uuid = $user_array[$v_id][$username]['user_uuid'];
  2701. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  2702. $password = check_str($row["password"]);
  2703. $salt = check_str($row["salt"]);
  2704. $contact_uuid = $user_array[$v_id][$username]['contact_uuid'];
  2705. $user_status = check_str($row["user_status"]);
  2706. $user_time_zone = check_str($row["user_time_zone"]);
  2707. $user_type = check_str($row["user_type"]);
  2708. $user_category = check_str($row["user_category"]);
  2709. if (strlen($user_uuid) == 0) {
  2710. $user_uuid = uuid();
  2711. }
  2712. if (strlen($domain_uuid) > 0) {
  2713. if (strlen($username) > 0) {
  2714. $sql = "insert into v_users ";
  2715. $sql .= "(";
  2716. $sql .= "user_uuid, ";
  2717. $sql .= "domain_uuid, ";
  2718. $sql .= "username, ";
  2719. $sql .= "password, ";
  2720. $sql .= "salt, ";
  2721. $sql .= "contact_uuid, ";
  2722. $sql .= "user_status, ";
  2723. $sql .= "user_add_user, ";
  2724. $sql .= "user_add_date ";
  2725. $sql .= ")";
  2726. $sql .= "values ";
  2727. $sql .= "(";
  2728. $sql .= "'".$user_uuid."', ";
  2729. $sql .= "'".$domain_uuid."', ";
  2730. $sql .= "'".$username."', ";
  2731. $sql .= "'".$password."', ";
  2732. $sql .= "'".$salt."', ";
  2733. $sql .= "'".$contact_uuid."', ";
  2734. $sql .= "'".$user_status."', ";
  2735. $sql .= "'".$user_add_user."', ";
  2736. $sql .= "'".$user_add_date."' ";
  2737. $sql .= ")";
  2738. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2739. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2740. }
  2741. //export contacts
  2742. $contact_name_given = check_str($row["user_first_name"]);
  2743. $contact_name_family = check_str($row["user_last_name"]);
  2744. $contact_organization = check_str($row["user_company_name"]);
  2745. $contact_email = check_str($row["user_email"]);
  2746. $contact_note = check_str($row["user_notes"]);
  2747. $contact_url = check_str($row["user_url"]);
  2748. $sql = "insert into v_contacts ";
  2749. $sql .= "(";
  2750. $sql .= "contact_uuid, ";
  2751. $sql .= "domain_uuid, ";
  2752. $sql .= "contact_type, ";
  2753. $sql .= "contact_organization, ";
  2754. $sql .= "contact_name_given, ";
  2755. $sql .= "contact_name_family, ";
  2756. $sql .= "contact_email, ";
  2757. $sql .= "contact_url, ";
  2758. $sql .= "contact_time_zone, ";
  2759. $sql .= "contact_note ";
  2760. $sql .= ")";
  2761. $sql .= "values ";
  2762. $sql .= "(";
  2763. $sql .= "'".$contact_uuid."', ";
  2764. $sql .= "'".$domain_uuid."', ";
  2765. if ($user_type == 'user') {
  2766. $sql .= "'user', ";
  2767. }
  2768. else {
  2769. $sql .= "'".$user_category."', ";
  2770. }
  2771. $sql .= "'".$contact_organization."', ";
  2772. $sql .= "'".$contact_name_given."', ";
  2773. $sql .= "'".$contact_name_family."', ";
  2774. $sql .= "'".$contact_email."', ";
  2775. $sql .= "'".$contact_url."', ";
  2776. $sql .= "'".$user_time_zone."', ";
  2777. $sql .= "'".$contact_note."' ";
  2778. $sql .= ")";
  2779. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2780. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2781. //export the contact addresses
  2782. $x = 0;
  2783. if (strlen($row["user_physical_city"]) > 0) {
  2784. $addresses[$x]['address_1'] = check_str($row["user_physical_address_1"]);
  2785. $addresses[$x]['address_2'] = check_str($row["user_physical_address_2"]);
  2786. $addresses[$x]['city'] = check_str($row["user_physical_city"]);
  2787. $addresses[$x]['state_province'] = check_str($row["user_physical_state_province"]);
  2788. $addresses[$x]['country'] = check_str($row["user_physical_country"]);
  2789. $addresses[$x]['postal_code'] = check_str($row["user_physical_postal_code"]);
  2790. $addresses[$x]['address_type'] = 'work';
  2791. $x++;
  2792. }
  2793. if (strlen($row["user_mailing_city"]) > 0) {
  2794. $addresses[$x]['address_1'] = check_str($row["user_mailing_address_1"]);
  2795. $addresses[$x]['address_2'] = check_str($row["user_mailing_address_2"]);
  2796. $addresses[$x]['city'] = check_str($row["user_mailing_city"]);
  2797. $addresses[$x]['state_province'] = check_str($row["user_mailing_state_province"]);
  2798. $addresses[$x]['country'] = check_str($row["user_mailing_country"]);
  2799. $addresses[$x]['postal_code'] = check_str($row["user_mailing_postal_code"]);
  2800. $addresses[$x]['address_type'] = 'work';
  2801. $x++;
  2802. }
  2803. if (strlen($row["user_billing_city"]) > 0) {
  2804. $addresses[$x]['address_1'] = check_str($row["user_billing_address_1"]);
  2805. $addresses[$x]['address_2'] = check_str($row["user_billing_address_2"]);
  2806. $addresses[$x]['city'] = check_str($row["user_billing_city"]);
  2807. $addresses[$x]['state_province'] = check_str($row["user_billing_state_province"]);
  2808. $addresses[$x]['country'] = check_str($row["user_billing_country"]);
  2809. $addresses[$x]['postal_code'] = check_str($row["user_billing_postal_code"]);
  2810. $addresses[$x]['address_type'] = 'work';
  2811. $x++;
  2812. }
  2813. if (strlen($row["user_shipping_city"]) > 0) {
  2814. $addresses[$x]['address_1'] = check_str($row["user_shipping_address_1"]);
  2815. $addresses[$x]['address_2'] = check_str($row["user_shipping_address_2"]);
  2816. $addresses[$x]['city'] = check_str($row["user_shipping_city"]);
  2817. $addresses[$x]['state_province'] = check_str($row["user_shipping_state_province"]);
  2818. $addresses[$x]['country'] = check_str($row["user_shipping_country"]);
  2819. $addresses[$x]['postal_code'] = check_str($row["user_shipping_postal_code"]);
  2820. $addresses[$x]['address_type'] = 'work';
  2821. }
  2822. foreach($addresses as $address) {
  2823. $sql = "insert into v_contact_addresses ";
  2824. $sql .= "(";
  2825. $sql .= "contact_address_uuid, ";
  2826. $sql .= "contact_uuid, ";
  2827. $sql .= "domain_uuid, ";
  2828. $sql .= "address_type, ";
  2829. $sql .= "address_street, ";
  2830. $sql .= "address_extended, ";
  2831. $sql .= "address_locality, ";
  2832. $sql .= "address_region, ";
  2833. $sql .= "address_postal_code, ";
  2834. $sql .= "address_country ";
  2835. $sql .= ")";
  2836. $sql .= "values ";
  2837. $sql .= "(";
  2838. $sql .= "'".uuid()."', ";
  2839. $sql .= "'".$contact_uuid."', ";
  2840. $sql .= "'".$domain_uuid."', ";
  2841. $sql .= "'".$address["address_type"]."', ";
  2842. $sql .= "'".$address["address_1"]."', ";
  2843. $sql .= "'".$address["address_2"]."', ";
  2844. $sql .= "'".$address["city"]."', ";
  2845. $sql .= "'".$address["state_province"]."', ";
  2846. $sql .= "'".$address["postal_code"]."', ";
  2847. $sql .= "'".$address["country"]."' ";
  2848. $sql .= ")";
  2849. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2850. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2851. }
  2852. unset($addresses);
  2853. //export the contact phone numbers
  2854. $x = 0;
  2855. if (strlen($row["user_phone_1"]) > 0) {
  2856. $phones[$x]['number'] = check_str($row["user_phone_1"]);
  2857. $phones[$x]['type'] = 'work';
  2858. $x++;
  2859. }
  2860. if (strlen($row["user_phone_2"]) > 0) {
  2861. $phones[$x]['number'] = check_str($row["user_phone_2"]);
  2862. $phones[$x]['type'] = 'work';
  2863. $x++;
  2864. }
  2865. if (strlen($row["user_phone_mobile"]) > 0) {
  2866. $phones[$x]['number'] = check_str($row["user_phone_mobile"]);
  2867. $phones[$x]['type'] = 'cell';
  2868. $x++;
  2869. }
  2870. if (strlen($row["user_phone_emergency_mobile"]) > 0) {
  2871. $phones[$x]['number'] = check_str($row["user_phone_emergency_mobile"]);
  2872. $phones[$x]['type'] = 'x-emergency';
  2873. $x++;
  2874. }
  2875. if (strlen($row["user_phone_fax"]) > 0) {
  2876. $phones[$x]['number'] = check_str($row["user_phone_fax"]);
  2877. $phones[$x]['type'] = 'fax';
  2878. $x++;
  2879. }
  2880. foreach($phones as $phone) {
  2881. $sql = "insert into v_contact_phones ";
  2882. $sql .= "(";
  2883. $sql .= "contact_phone_uuid, ";
  2884. $sql .= "domain_uuid, ";
  2885. $sql .= "contact_uuid, ";
  2886. $sql .= "phone_type, ";
  2887. $sql .= "phone_number ";
  2888. $sql .= ")";
  2889. $sql .= "values ";
  2890. $sql .= "(";
  2891. $sql .= "'".uuid()."', ";
  2892. $sql .= "'".$domain_uuid."', ";
  2893. $sql .= "'".$contact_uuid."', ";
  2894. $sql .= "'".$phone["type"]."', ";
  2895. $sql .= "'".$phone["number"]."' ";
  2896. $sql .= ")";
  2897. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2898. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2899. }
  2900. unset($phones);
  2901. //add to user settings
  2902. //$user_template_name = $row["user_template_name"];
  2903. if (strlen($row["user_time_zone"]) > 0) {
  2904. $user_settings[$x]['category'] = 'domain';
  2905. $user_settings[$x]['sub_category'] = 'time_zone';
  2906. $user_settings[$x]['name'] = "name";
  2907. $user_settings[$x]['value'] = check_str($row["user_time_zone"]);
  2908. $x++;
  2909. }
  2910. foreach($user_settings as $setting) {
  2911. $sql = "insert into v_user_settings ";
  2912. $sql .= "(";
  2913. $sql .= "user_setting_uuid, ";
  2914. $sql .= "user_setting_category, ";
  2915. $sql .= "user_setting_subcategory, ";
  2916. $sql .= "user_setting_name, ";
  2917. $sql .= "user_setting_value, ";
  2918. $sql .= "user_setting_enabled, ";
  2919. $sql .= "user_uuid ";
  2920. $sql .= ") ";
  2921. $sql .= "values ";
  2922. $sql .= "(";
  2923. $sql .= "'".uuid()."', ";
  2924. $sql .= "'".$setting["category"]."', ";
  2925. $sql .= "'".$setting["sub_category"]."', ";
  2926. $sql .= "'".$setting["name"]."', ";
  2927. $sql .= "'".$setting["value"]."', ";
  2928. $sql .= "'true', ";
  2929. $sql .= "'".$user_uuid."' ";
  2930. $sql .= ")";
  2931. $db->exec(check_sql($sql));
  2932. }
  2933. unset($user_settings);
  2934. }
  2935. }
  2936. unset ($prep_statement);
  2937. //export the call broadcasts
  2938. $sql = "select * from v_call_broadcast ";
  2939. $prep_statement = $db->prepare($sql);
  2940. $prep_statement->execute();
  2941. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2942. foreach ($result as &$row) {
  2943. $v_id = check_str($row["v_id"]);
  2944. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  2945. $call_call_broadcast_uuid = uuid();
  2946. $broadcast_name = check_str($row["broadcast_name"]);
  2947. $broadcast_description = check_str($row["broadcast_desc"]);
  2948. $broadcast_timeout = check_str($row["broadcast_timeout"]);
  2949. $broadcast_concurrent_limit = check_str($row["broadcast_concurrent_limit"]);
  2950. $recording_uuid = check_str($row["recording_uuid"]);
  2951. $broadcast_caller_id_name = check_str($row["broadcast_caller_id_name"]);
  2952. $broadcast_caller_id_number = check_str($row["broadcast_caller_id_number"]);
  2953. $broadcast_destination_type = check_str($row["broadcast_destination_type"]);
  2954. $broadcast_phone_numbers = check_str($row["broadcast_phone_numbers"]);
  2955. $broadcast_destination_data = check_str($row["broadcast_destination_data"]);
  2956. $sql = "insert into v_call_broadcasts ";
  2957. $sql .= "(";
  2958. $sql .= "call_call_broadcast_uuid, ";
  2959. $sql .= "domain_uuid, ";
  2960. $sql .= "broadcast_name, ";
  2961. $sql .= "broadcast_description, ";
  2962. $sql .= "broadcast_timeout, ";
  2963. $sql .= "broadcast_concurrent_limit, ";
  2964. $sql .= "recording_uuid, ";
  2965. $sql .= "broadcast_caller_id_name, ";
  2966. $sql .= "broadcast_caller_id_number, ";
  2967. $sql .= "broadcast_destination_type, ";
  2968. $sql .= "broadcast_phone_numbers, ";
  2969. $sql .= "broadcast_destination_data ";
  2970. $sql .= ")";
  2971. $sql .= "values ";
  2972. $sql .= "(";
  2973. $sql .= "'".$call_call_broadcast_uuid."', ";
  2974. $sql .= "'".$domain_uuid."', ";
  2975. $sql .= "'".$broadcast_name."', ";
  2976. $sql .= "'".$broadcast_description."', ";
  2977. $sql .= "'".$broadcast_timeout."', ";
  2978. $sql .= "'".$broadcast_concurrent_limit."', ";
  2979. $sql .= "null, ";
  2980. $sql .= "'".$broadcast_caller_id_name."', ";
  2981. $sql .= "'".$broadcast_caller_id_number."', ";
  2982. $sql .= "'".$broadcast_destination_type."', ";
  2983. $sql .= "'".$broadcast_phone_numbers."', ";
  2984. $sql .= "'".$broadcast_destination_data."' ";
  2985. $sql .= ")";
  2986. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  2987. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  2988. }
  2989. unset ($prep_statement);
  2990. //export call center agents
  2991. $sql = "select * from v_call_center_agent ";
  2992. $prep_statement = $db->prepare($sql);
  2993. $prep_statement->execute();
  2994. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  2995. foreach ($result as &$row) {
  2996. $v_id = check_str($row["v_id"]);
  2997. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  2998. $call_center_agent_uuid = uuid();
  2999. $agent_name = check_str($row["agent_name"]);
  3000. $agent_type = check_str($row["agent_type"]);
  3001. $agent_call_timeout = check_str($row["agent_call_timeout"]);
  3002. $agent_contact = check_str($row["agent_contact"]);
  3003. $agent_status = check_str($row["agent_status"]);
  3004. $agent_logout = check_str($row["agent_logout"]);
  3005. $agent_max_no_answer = check_str($row["agent_max_no_answer"]);
  3006. $agent_wrap_up_time = check_str($row["agent_wrap_up_time"]);
  3007. $agent_reject_delay_time = check_str($row["agent_reject_delay_time"]);
  3008. $agent_busy_delay_time = check_str($row["agent_busy_delay_time"]);
  3009. $agent_no_answer_delay_time = check_str($row["agent_no_answer_delay_time"]);
  3010. $sql = "insert into v_call_center_agents ";
  3011. $sql .= "(";
  3012. $sql .= "call_center_agent_uuid, ";
  3013. $sql .= "domain_uuid, ";
  3014. $sql .= "agent_name, ";
  3015. $sql .= "agent_type, ";
  3016. $sql .= "agent_call_timeout, ";
  3017. $sql .= "agent_contact, ";
  3018. $sql .= "agent_status, ";
  3019. $sql .= "agent_logout, ";
  3020. $sql .= "agent_max_no_answer, ";
  3021. $sql .= "agent_wrap_up_time, ";
  3022. $sql .= "agent_reject_delay_time, ";
  3023. $sql .= "agent_busy_delay_time, ";
  3024. $sql .= "agent_no_answer_delay_time ";
  3025. $sql .= ")";
  3026. $sql .= "values ";
  3027. $sql .= "(";
  3028. $sql .= "'".$call_center_agent_uuid."', ";
  3029. $sql .= "'".$domain_uuid."', ";
  3030. $sql .= "'".$agent_name."', ";
  3031. $sql .= "'".$agent_type."', ";
  3032. $sql .= "'".$agent_call_timeout."', ";
  3033. $sql .= "'".$agent_contact."', ";
  3034. $sql .= "'".$agent_status."', ";
  3035. $sql .= "'".$agent_logout."', ";
  3036. $sql .= "'".$agent_max_no_answer."', ";
  3037. $sql .= "'".$agent_wrap_up_time."', ";
  3038. $sql .= "'".$agent_reject_delay_time."', ";
  3039. $sql .= "'".$agent_busy_delay_time."', ";
  3040. $sql .= "'".$agent_no_answer_delay_time."' ";
  3041. $sql .= ")";
  3042. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3043. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3044. }
  3045. unset ($prep_statement);
  3046. //export call center logs
  3047. $sql = "select * from v_call_center_logs ";
  3048. $prep_statement = $db->prepare($sql);
  3049. $prep_statement->execute();
  3050. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3051. foreach ($result as &$row) {
  3052. $cc_uuid = uuid();
  3053. $v_id = check_str($row["v_id"]);
  3054. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3055. $cc_queue = check_str($row["cc_queue"]);
  3056. $cc_action = check_str($row["cc_action"]);
  3057. $cc_count = check_str($row["cc_count"]);
  3058. $cc_agent = check_str($row["cc_agent"]);
  3059. $cc_agent_system = check_str($row["cc_agent_system"]);
  3060. $cc_agent_status = check_str($row["cc_agent_status"]);
  3061. $cc_agent_state = check_str($row["cc_agent_state"]);
  3062. $cc_agent_uuid = check_str($row["cc_agent_uuid"]);
  3063. $cc_selection = check_str($row["cc_selection"]);
  3064. $cc_cause = check_str($row["cc_cause"]);
  3065. $cc_wait_time = check_str($row["cc_wait_time"]);
  3066. $cc_talk_time = check_str($row["cc_talk_time"]);
  3067. $cc_total_time = check_str($row["cc_total_time"]);
  3068. $cc_epoch = check_str($row["cc_epoch"]);
  3069. $cc_date = check_str($row["cc_date"]);
  3070. $cc_agent_type = check_str($row["cc_agent_type"]);
  3071. $cc_member_uuid = check_str($row["cc_member_uuid"]);
  3072. $cc_member_session_uuid = check_str($row["cc_member_session_uuid"]);
  3073. $cc_member_cid_name = check_str($row["cc_member_cid_name"]);
  3074. $cc_member_cid_number = check_str($row["cc_member_cid_number"]);
  3075. $cc_agent_called_time = check_str($row["cc_agent_called_time"]);
  3076. $cc_agent_answered_time = check_str($row["cc_agent_answered_time"]);
  3077. $cc_member_joined_time = check_str($row["cc_member_joined_time"]);
  3078. $cc_member_leaving_time = check_str($row["cc_member_leaving_time"]);
  3079. $cc_bridge_terminated_time = check_str($row["cc_bridge_terminated_time"]);
  3080. $cc_hangup_cause = check_str($row["cc_hangup_cause"]);
  3081. $sql = "insert into v_call_center_logs ";
  3082. $sql .= "(";
  3083. $sql .= "cc_uuid, ";
  3084. $sql .= "cc_queue, ";
  3085. $sql .= "cc_action, ";
  3086. $sql .= "cc_count, ";
  3087. $sql .= "cc_agent, ";
  3088. $sql .= "cc_agent_system, ";
  3089. $sql .= "cc_agent_status, ";
  3090. $sql .= "cc_agent_state, ";
  3091. $sql .= "cc_agent_uuid, ";
  3092. $sql .= "cc_selection, ";
  3093. $sql .= "cc_cause, ";
  3094. $sql .= "cc_wait_time, ";
  3095. $sql .= "cc_talk_time, ";
  3096. $sql .= "cc_total_time, ";
  3097. $sql .= "cc_epoch, ";
  3098. $sql .= "cc_date, ";
  3099. $sql .= "cc_agent_type, ";
  3100. $sql .= "cc_member_uuid, ";
  3101. $sql .= "cc_member_session_uuid, ";
  3102. $sql .= "cc_member_cid_name, ";
  3103. $sql .= "cc_member_cid_number, ";
  3104. $sql .= "cc_agent_called_time, ";
  3105. $sql .= "cc_agent_answered_time, ";
  3106. $sql .= "cc_member_joined_time, ";
  3107. $sql .= "cc_member_leaving_time, ";
  3108. $sql .= "cc_bridge_terminated_time, ";
  3109. $sql .= "cc_hangup_cause ";
  3110. $sql .= ")";
  3111. $sql .= "values ";
  3112. $sql .= "(";
  3113. $sql .= "'".$cc_uuid."', ";
  3114. $sql .= "'".$cc_queue."', ";
  3115. $sql .= "'".$cc_action."', ";
  3116. if (strlen($cc_count) > 0) {
  3117. $sql .= "'".$cc_count."', ";
  3118. }
  3119. else {
  3120. $sql .= "null, ";
  3121. }
  3122. $sql .= "'".$cc_agent."', ";
  3123. $sql .= "'".$cc_agent_system."', ";
  3124. $sql .= "'".$cc_agent_status."', ";
  3125. $sql .= "'".$cc_agent_state."', ";
  3126. $sql .= "'".$cc_agent_uuid."', ";
  3127. $sql .= "'".$cc_selection."', ";
  3128. $sql .= "'".$cc_cause."', ";
  3129. $sql .= "'".$cc_wait_time."', ";
  3130. $sql .= "'".$cc_talk_time."', ";
  3131. $sql .= "'".$cc_total_time."', ";
  3132. if (strlen($cc_epoch) > 0) {
  3133. $sql .= "'".$cc_epoch."', ";
  3134. }
  3135. else {
  3136. $sql .= "null, ";
  3137. }
  3138. $sql .= "'".$cc_date."', ";
  3139. $sql .= "'".$cc_agent_type."', ";
  3140. $sql .= "'".$cc_member_uuid."', ";
  3141. $sql .= "'".$cc_member_session_uuid."', ";
  3142. $sql .= "'".$cc_member_cid_name."', ";
  3143. $sql .= "'".$cc_member_cid_number."', ";
  3144. if (strlen($cc_agent_called_time) > 0) {
  3145. $sql .= "'".$cc_agent_called_time."', ";
  3146. }
  3147. else {
  3148. $sql .= "null, ";
  3149. }
  3150. if (strlen($cc_agent_answered_time) > 0) {
  3151. $sql .= "'".$cc_agent_answered_time."', ";
  3152. }
  3153. else {
  3154. $sql .= "null, ";
  3155. }
  3156. if (strlen($cc_member_joined_time) > 0) {
  3157. $sql .= "'".$cc_member_joined_time."', ";
  3158. }
  3159. else {
  3160. $sql .= "null, ";
  3161. }
  3162. if (strlen($cc_member_leaving_time) > 0) {
  3163. $sql .= "'".$cc_member_leaving_time."', ";
  3164. }
  3165. else {
  3166. $sql .= "null, ";
  3167. }
  3168. if (strlen($cc_bridge_terminated_time) > 0) {
  3169. $sql .= "'".$cc_bridge_terminated_time."', ";
  3170. }
  3171. else {
  3172. $sql .= "null, ";
  3173. }
  3174. $sql .= "'".$cc_hangup_cause."' ";
  3175. $sql .= ")";
  3176. //if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3177. //if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3178. }
  3179. unset ($prep_statement);
  3180. //export the call center queues
  3181. $sql = "select * from v_call_center_queue ";
  3182. $prep_statement = $db->prepare($sql);
  3183. $prep_statement->execute();
  3184. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3185. foreach ($result as &$row) {
  3186. $call_center_queue_uuid = uuid();
  3187. $v_id = check_str($row["v_id"]);
  3188. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3189. $queue_name = check_str($row["queue_name"]);
  3190. $queue_extension = check_str($row["queue_extension"]);
  3191. $queue_strategy = check_str($row["queue_strategy"]);
  3192. $queue_moh_sound = check_str($row["queue_moh_sound"]);
  3193. $queue_record_template = check_str($row["queue_record_template"]);
  3194. $queue_time_base_score = check_str($row["queue_time_base_score"]);
  3195. $queue_max_wait_time = check_str($row["queue_max_wait_time"]);
  3196. $queue_max_wait_time_with_no_agent = check_str($row["queue_max_wait_time_with_no_agent"]);
  3197. $queue_tier_rules_apply = check_str($row["queue_tier_rules_apply"]);
  3198. $queue_tier_rule_wait_second = check_str($row["queue_tier_rule_wait_second"]);
  3199. $queue_tier_rule_no_agent_no_wait = check_str($row["queue_tier_rule_no_agent_no_wait"]);
  3200. $queue_timeout_action = check_str($row["queue_timeout_action"]);
  3201. $queue_discard_abandoned_after = check_str($row["queue_discard_abandoned_after"]);
  3202. $queue_abandoned_resume_allowed = check_str($row["queue_abandoned_resume_allowed"]);
  3203. $queue_tier_rule_wait_multiply_level = check_str($row["queue_tier_rule_wait_multiply_level"]);
  3204. $queue_cid_prefix = check_str($row["queue_cid_prefix"]);
  3205. $queue_description = check_str($row["queue_description"]);
  3206. $sql = "insert into v_call_center_queues ";
  3207. $sql .= "(";
  3208. $sql .= "call_center_queue_uuid, ";
  3209. $sql .= "domain_uuid, ";
  3210. $sql .= "queue_name, ";
  3211. $sql .= "queue_extension, ";
  3212. $sql .= "queue_strategy, ";
  3213. $sql .= "queue_moh_sound, ";
  3214. $sql .= "queue_record_template, ";
  3215. $sql .= "queue_time_base_score, ";
  3216. $sql .= "queue_max_wait_time, ";
  3217. $sql .= "queue_max_wait_time_with_no_agent, ";
  3218. $sql .= "queue_tier_rules_apply, ";
  3219. $sql .= "queue_tier_rule_wait_second, ";
  3220. $sql .= "queue_tier_rule_no_agent_no_wait, ";
  3221. $sql .= "queue_timeout_action, ";
  3222. $sql .= "queue_discard_abandoned_after, ";
  3223. $sql .= "queue_abandoned_resume_allowed, ";
  3224. $sql .= "queue_tier_rule_wait_multiply_level, ";
  3225. $sql .= "queue_cid_prefix, ";
  3226. $sql .= "queue_description ";
  3227. $sql .= ")";
  3228. $sql .= "values ";
  3229. $sql .= "(";
  3230. $sql .= "'".$call_center_queue_uuid."', ";
  3231. $sql .= "'".$domain_uuid."', ";
  3232. $sql .= "'".$queue_name."', ";
  3233. $sql .= "'".$queue_extension."', ";
  3234. $sql .= "'".$queue_strategy."', ";
  3235. $sql .= "'".$queue_moh_sound."', ";
  3236. $sql .= "'".$queue_record_template."', ";
  3237. $sql .= "'".$queue_time_base_score."', ";
  3238. $sql .= "'".$queue_max_wait_time."', ";
  3239. $sql .= "'".$queue_max_wait_time_with_no_agent."', ";
  3240. $sql .= "'".$queue_tier_rules_apply."', ";
  3241. $sql .= "'".$queue_tier_rule_wait_second."', ";
  3242. $sql .= "'".$queue_tier_rule_no_agent_no_wait."', ";
  3243. $sql .= "'".$queue_timeout_action."', ";
  3244. $sql .= "'".$queue_discard_abandoned_after."', ";
  3245. $sql .= "'".$queue_abandoned_resume_allowed."', ";
  3246. $sql .= "'".$queue_tier_rule_wait_multiply_level."', ";
  3247. $sql .= "'".$queue_cid_prefix."', ";
  3248. $sql .= "'".$queue_description."' ";
  3249. $sql .= ")";
  3250. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3251. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3252. }
  3253. unset ($prep_statement);
  3254. //export the call center tiers
  3255. $sql = "select * from v_call_center_tier ";
  3256. $prep_statement = $db->prepare($sql);
  3257. $prep_statement->execute();
  3258. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3259. foreach ($result as &$row) {
  3260. $call_center_tier_uuid = uuid();
  3261. $v_id = check_str($row["v_id"]);
  3262. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3263. $agent_name = check_str($row["agent_name"]);
  3264. $queue_name = check_str($row["queue_name"]);
  3265. $tier_level = check_str($row["tier_level"]);
  3266. $tier_position = check_str($row["tier_position"]);
  3267. $sql = "insert into v_call_center_tiers ";
  3268. $sql .= "(";
  3269. $sql .= "call_center_tier_uuid, ";
  3270. $sql .= "domain_uuid, ";
  3271. $sql .= "agent_name, ";
  3272. $sql .= "queue_name, ";
  3273. $sql .= "tier_level, ";
  3274. $sql .= "tier_position ";
  3275. $sql .= ")";
  3276. $sql .= "values ";
  3277. $sql .= "(";
  3278. $sql .= "'".$call_center_tier_uuid."', ";
  3279. $sql .= "'".$domain_uuid."', ";
  3280. $sql .= "'".$agent_name."', ";
  3281. $sql .= "'".$queue_name."', ";
  3282. $sql .= "'".$tier_level."', ";
  3283. $sql .= "'".$tier_position."' ";
  3284. $sql .= ")";
  3285. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3286. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3287. }
  3288. unset ($prep_statement);
  3289. //export contacts
  3290. $sql = "select * from v_contacts ";
  3291. $prep_statement = $db->prepare($sql);
  3292. $prep_statement->execute();
  3293. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3294. foreach ($result as &$row) {
  3295. $contact_id = check_str($row["contact_id"]);
  3296. $v_id = check_str($row["v_id"]);
  3297. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3298. $contact_uuid = uuid();
  3299. $contact_type = check_str($row["type"]);
  3300. $contact_organization = check_str($row["org"]);
  3301. $contact_name_given = check_str($row["n_given"]);
  3302. $contact_name_family = check_str($row["n_family"]);
  3303. $contact_nickname = check_str($row["nickname"]);
  3304. $contact_title = check_str($row["title"]);
  3305. $contact_role = check_str($row["role"]);
  3306. $contact_email = check_str($row["email"]);
  3307. $contact_url = check_str($row["url"]);
  3308. $contact_time_zone = check_str($row["tz"]);
  3309. $contact_note = check_str($row["note"]);
  3310. //set the contact_uuid
  3311. $contact_array[$contact_id]['contact_uuid'] = $contact_uuid;
  3312. $sql = "insert into v_contacts ";
  3313. $sql .= "(";
  3314. $sql .= "contact_uuid, ";
  3315. $sql .= "domain_uuid, ";
  3316. $sql .= "contact_type, ";
  3317. $sql .= "contact_organization, ";
  3318. $sql .= "contact_name_given, ";
  3319. $sql .= "contact_name_family, ";
  3320. $sql .= "contact_nickname, ";
  3321. $sql .= "contact_title, ";
  3322. $sql .= "contact_role, ";
  3323. $sql .= "contact_email, ";
  3324. $sql .= "contact_url, ";
  3325. $sql .= "contact_time_zone, ";
  3326. $sql .= "contact_note ";
  3327. $sql .= ")";
  3328. $sql .= "values ";
  3329. $sql .= "(";
  3330. $sql .= "'".$contact_uuid."', ";
  3331. $sql .= "'".$domain_uuid."', ";
  3332. $sql .= "'".$contact_type."', ";
  3333. $sql .= "'".$contact_organization."', ";
  3334. $sql .= "'".$contact_name_given."', ";
  3335. $sql .= "'".$contact_name_family."', ";
  3336. $sql .= "'".$contact_nickname."', ";
  3337. $sql .= "'".$contact_title."', ";
  3338. $sql .= "'".$contact_role."', ";
  3339. $sql .= "'".$contact_email."', ";
  3340. $sql .= "'".$contact_url."', ";
  3341. $sql .= "'".$contact_time_zone."', ";
  3342. $sql .= "'".$contact_note."' ";
  3343. $sql .= ")";
  3344. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3345. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3346. }
  3347. unset ($prep_statement);
  3348. //export the contact addresses
  3349. $sql = "select * from v_contacts_adr ";
  3350. $prep_statement = $db->prepare($sql);
  3351. $prep_statement->execute();
  3352. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3353. foreach ($result as &$row) {
  3354. $v_id = check_str($row["v_id"]);
  3355. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3356. $contact_address_uuid = uuid();
  3357. $contact_id = check_str($row["contact_id"]);
  3358. $address_type = check_str($row["adr_type"]);
  3359. $address_street = check_str($row["adr_street"]);
  3360. $address_extended = check_str($row["adr_extended"]);
  3361. $address_locality = check_str($row["adr_locality"]);
  3362. $address_region = check_str($row["adr_region"]);
  3363. $address_postal_code = check_str($row["adr_postal_code"]);
  3364. $address_country = check_str($row["adr_country"]);
  3365. $address_latitude = check_str($row["adr_latitude"]);
  3366. $address_longitude = check_str($row["adr_longitude"]);
  3367. //get the contact_uuid
  3368. $contact_uuid = $contact_array[$contact_id]['contact_uuid'];
  3369. $sql = "insert into v_contact_addresses ";
  3370. $sql .= "(";
  3371. $sql .= "contact_address_uuid, ";
  3372. $sql .= "contact_uuid, ";
  3373. $sql .= "domain_uuid, ";
  3374. $sql .= "address_type, ";
  3375. $sql .= "address_street, ";
  3376. $sql .= "address_extended, ";
  3377. $sql .= "address_locality, ";
  3378. $sql .= "address_region, ";
  3379. $sql .= "address_postal_code, ";
  3380. $sql .= "address_country, ";
  3381. $sql .= "address_latitude, ";
  3382. $sql .= "address_longitude ";
  3383. $sql .= ")";
  3384. $sql .= "values ";
  3385. $sql .= "(";
  3386. $sql .= "'".$contact_address_uuid."', ";
  3387. $sql .= "'".$contact_uuid."', ";
  3388. $sql .= "'".$domain_uuid."', ";
  3389. $sql .= "'".$address_type."', ";
  3390. $sql .= "'".$address_street."', ";
  3391. $sql .= "'".$address_extended."', ";
  3392. $sql .= "'".$address_locality."', ";
  3393. $sql .= "'".$address_region."', ";
  3394. $sql .= "'".$address_postal_code."', ";
  3395. $sql .= "'".$address_country."', ";
  3396. $sql .= "'".$address_latitude."', ";
  3397. $sql .= "'".$address_longitude."' ";
  3398. $sql .= ")";
  3399. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3400. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3401. }
  3402. unset ($prep_statement);
  3403. //export the contact phone numbers
  3404. $sql = "select * from v_contacts_tel ";
  3405. $prep_statement = $db->prepare($sql);
  3406. $prep_statement->execute();
  3407. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3408. foreach ($result as &$row) {
  3409. $contact_phone_uuid = uuid();
  3410. $v_id = check_str($row["v_id"]);
  3411. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3412. $contact_id = check_str($row["contact_id"]);
  3413. $phone_type = check_str($row["tel_type"]);
  3414. $phone_number = check_str($row["tel_number"]);
  3415. //get the contact_uuid
  3416. $contact_uuid = $contact_array[$contact_id]['contact_uuid'];
  3417. if (strlen($contact_uuid) > 0) {
  3418. $sql = "insert into v_contact_phones ";
  3419. $sql .= "(";
  3420. $sql .= "contact_phone_uuid, ";
  3421. $sql .= "domain_uuid, ";
  3422. $sql .= "contact_uuid, ";
  3423. $sql .= "phone_type, ";
  3424. $sql .= "phone_number ";
  3425. $sql .= ")";
  3426. $sql .= "values ";
  3427. $sql .= "(";
  3428. $sql .= "'".$contact_phone_uuid."', ";
  3429. $sql .= "'".$domain_uuid."', ";
  3430. $sql .= "'".$contact_uuid."', ";
  3431. $sql .= "'".$phone_type."', ";
  3432. $sql .= "'".$phone_number."' ";
  3433. $sql .= ")";
  3434. }
  3435. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3436. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3437. }
  3438. unset ($prep_statement);
  3439. //export the contact notes
  3440. $sql = "select * from v_contact_notes ";
  3441. $prep_statement = $db->prepare($sql);
  3442. $prep_statement->execute();
  3443. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3444. foreach ($result as &$row) {
  3445. $contact_note_uuid = uuid();
  3446. $v_id = check_str($row["v_id"]);
  3447. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3448. $contact_id = check_str($row["contact_id"]);
  3449. $contact_note = check_str($row["notes"]);
  3450. $last_mod_date = check_str($row["last_mod_date"]);
  3451. $last_mod_user = check_str($row["last_mod_user"]);
  3452. //get the contact_uuid
  3453. $contact_uuid = $contact_array[$contact_id]['contact_uuid'];
  3454. $sql = "insert into v_contact_notes ";
  3455. $sql .= "(";
  3456. $sql .= "contact_note_uuid, ";
  3457. $sql .= "domain_uuid, ";
  3458. $sql .= "contact_uuid, ";
  3459. $sql .= "contact_note, ";
  3460. $sql .= "last_mod_date, ";
  3461. $sql .= "last_mod_user ";
  3462. $sql .= ")";
  3463. $sql .= "values ";
  3464. $sql .= "(";
  3465. $sql .= "'".$contact_note_uuid."', ";
  3466. $sql .= "'".$domain_uuid."', ";
  3467. $sql .= "'".$contact_uuid."', ";
  3468. $sql .= "'".$contact_note."', ";
  3469. $sql .= "'".$last_mod_date."', ";
  3470. $sql .= "'".$last_mod_user."' ";
  3471. $sql .= ")";
  3472. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3473. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3474. }
  3475. unset ($prep_statement);
  3476. //export the rss data
  3477. $sql = "select * from v_rss ";
  3478. $prep_statement = $db->prepare($sql);
  3479. $prep_statement->execute();
  3480. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3481. foreach ($result as &$row) {
  3482. $rss_id = check_str($row["rss_id"]);
  3483. $rss_uuid = uuid();
  3484. $v_id = check_str($row["v_id"]);
  3485. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3486. $rss_language = check_str($row["rss_language"]);
  3487. $rss_category = check_str($row["rss_category"]);
  3488. $rss_sub_category = check_str($row["rss_sub_category"]);
  3489. $rss_title = check_str($row["rss_title"]);
  3490. $rss_link = check_str($row["rss_link"]);
  3491. $rss_description = check_str($row["rss_desc"]);
  3492. $rss_img = check_str($row["rss_img"]);
  3493. $rss_optional_1 = check_str($row["rss_optional_1"]);
  3494. $rss_optional_2 = check_str($row["rss_optional_2"]);
  3495. $rss_optional_3 = check_str($row["rss_optional_3"]);
  3496. $rss_optional_4 = check_str($row["rss_optional_4"]);
  3497. $rss_optional_5 = check_str($row["rss_optional_5"]);
  3498. $rss_add_date = check_str($row["rss_add_date"]);
  3499. $rss_add_user = check_str($row["rss_add_user"]);
  3500. $rss_del_date = check_str($row["rss_del_date"]);
  3501. $rss_del_user = check_str($row["rss_del_user"]);
  3502. $rss_order = check_str($row["rss_order"]);
  3503. $rss_content = check_str($row["rss_content"]);
  3504. $rss_group = check_str($row["rss_group"]);
  3505. //set the rss_uuid
  3506. $rss_array[$rss_id]['rss_uuid'] = $rss_uuid;
  3507. $sql = "insert into v_rss ";
  3508. $sql .= "(";
  3509. $sql .= "rss_uuid, ";
  3510. $sql .= "domain_uuid, ";
  3511. $sql .= "rss_language, ";
  3512. $sql .= "rss_category, ";
  3513. $sql .= "rss_sub_category, ";
  3514. $sql .= "rss_title, ";
  3515. $sql .= "rss_link, ";
  3516. $sql .= "rss_description, ";
  3517. $sql .= "rss_img, ";
  3518. $sql .= "rss_optional_1, ";
  3519. $sql .= "rss_optional_2, ";
  3520. $sql .= "rss_optional_3, ";
  3521. $sql .= "rss_optional_4, ";
  3522. $sql .= "rss_optional_5, ";
  3523. $sql .= "rss_add_date, ";
  3524. $sql .= "rss_add_user, ";
  3525. $sql .= "rss_del_date, ";
  3526. $sql .= "rss_del_user, ";
  3527. $sql .= "rss_order, ";
  3528. $sql .= "rss_content, ";
  3529. $sql .= "rss_group ";
  3530. $sql .= ")";
  3531. $sql .= "values ";
  3532. $sql .= "(";
  3533. $sql .= "'".$rss_uuid."', ";
  3534. $sql .= "'".$domain_uuid."', ";
  3535. $sql .= "'".$rss_language."', ";
  3536. $sql .= "'".$rss_category."', ";
  3537. $sql .= "'".$rss_sub_category."', ";
  3538. $sql .= "'".$rss_title."', ";
  3539. $sql .= "'".$rss_link."', ";
  3540. $sql .= "'".$rss_description."', ";
  3541. $sql .= "'".$rss_img."', ";
  3542. $sql .= "'".$rss_optional_1."', ";
  3543. $sql .= "'".$rss_optional_2."', ";
  3544. $sql .= "'".$rss_optional_3."', ";
  3545. $sql .= "'".$rss_optional_4."', ";
  3546. $sql .= "'".$rss_optional_5."', ";
  3547. $sql .= "'".$rss_add_date."', ";
  3548. $sql .= "'".$rss_add_user."', ";
  3549. $sql .= "'".$rss_del_date."', ";
  3550. $sql .= "'".$rss_del_user."', ";
  3551. $sql .= "'".$rss_order."', ";
  3552. $sql .= "'".$rss_content."', ";
  3553. $sql .= "'".$rss_group."' ";
  3554. $sql .= ")";
  3555. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3556. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3557. }
  3558. unset ($prep_statement);
  3559. //export the rss sub data
  3560. $sql = "select * from v_rss_sub ";
  3561. $prep_statement = $db->prepare($sql);
  3562. $prep_statement->execute();
  3563. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3564. foreach ($result as &$row) {
  3565. $rss_sub_uuid = uuid();
  3566. $v_id = check_str($row["v_id"]);
  3567. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3568. $rss_id = check_str($row["rss_id"]);
  3569. $rss_sub_language = check_str($row["rss_sub_language"]);
  3570. $rss_sub_title = check_str($row["rss_sub_title"]);
  3571. $rss_sub_link = check_str($row["rss_sub_link"]);
  3572. $rss_sub_description = check_str($row["rss_sub_desc"]);
  3573. $rss_sub_optional_1 = check_str($row["rss_sub_optional_1"]);
  3574. $rss_sub_optional_2 = check_str($row["rss_sub_optional_2"]);
  3575. $rss_sub_optional_3 = check_str($row["rss_sub_optional_3"]);
  3576. $rss_sub_optional_4 = check_str($row["rss_sub_optional_4"]);
  3577. $rss_sub_optional_5 = check_str($row["rss_sub_optional_5"]);
  3578. $rss_sub_add_date = check_str($row["rss_sub_add_date"]);
  3579. $rss_sub_add_user = check_str($row["rss_sub_add_user"]);
  3580. $rss_sub_del_user = check_str($row["rss_sub_del_user"]);
  3581. $rss_sub_del_date = check_str($row["rss_sub_del_date"]);
  3582. //get the rss_uuid
  3583. $rss_uuid = $rss_array[$rss_id]['rss_uuid'];
  3584. $sql = "insert into v_rss_sub ";
  3585. $sql .= "(";
  3586. $sql .= "rss_sub_uuid, ";
  3587. $sql .= "rss_uuid, ";
  3588. $sql .= "domain_uuid, ";
  3589. $sql .= "rss_sub_language, ";
  3590. $sql .= "rss_sub_title, ";
  3591. $sql .= "rss_sub_link, ";
  3592. $sql .= "rss_sub_description, ";
  3593. $sql .= "rss_sub_optional_1, ";
  3594. $sql .= "rss_sub_optional_2, ";
  3595. $sql .= "rss_sub_optional_3, ";
  3596. $sql .= "rss_sub_optional_4, ";
  3597. $sql .= "rss_sub_optional_5, ";
  3598. $sql .= "rss_sub_add_date, ";
  3599. $sql .= "rss_sub_add_user, ";
  3600. $sql .= "rss_sub_del_user, ";
  3601. $sql .= "rss_sub_del_date ";
  3602. $sql .= ")";
  3603. $sql .= "values ";
  3604. $sql .= "(";
  3605. $sql .= "'".$rss_sub_uuid."', ";
  3606. $sql .= "'".$rss_uuid."', ";
  3607. $sql .= "'".$domain_uuid."', ";
  3608. $sql .= "'".$rss_sub_language."', ";
  3609. $sql .= "'".$rss_sub_title."', ";
  3610. $sql .= "'".$rss_sub_link."', ";
  3611. $sql .= "'".$rss_sub_description."', ";
  3612. $sql .= "'".$rss_sub_optional_1."', ";
  3613. $sql .= "'".$rss_sub_optional_2."', ";
  3614. $sql .= "'".$rss_sub_optional_3."', ";
  3615. $sql .= "'".$rss_sub_optional_4."', ";
  3616. $sql .= "'".$rss_sub_optional_5."', ";
  3617. $sql .= "'".$rss_sub_add_date."', ";
  3618. $sql .= "'".$rss_sub_add_user."', ";
  3619. $sql .= "'".$rss_sub_del_user."', ";
  3620. $sql .= "'".$rss_sub_del_date."' ";
  3621. $sql .= ")";
  3622. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3623. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3624. }
  3625. unset ($prep_statement);
  3626. //export the rss sub category data
  3627. $sql = "select * from v_rss_sub_category ";
  3628. $prep_statement = $db->prepare($sql);
  3629. $prep_statement->execute();
  3630. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3631. foreach ($result as &$row) {
  3632. $rss_sub_category_uuid = uuid();
  3633. $v_id = check_str($row["v_id"]);
  3634. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3635. $rss_sub_category_language = check_str($row["rss_sub_category_language"]);
  3636. $rss_category = check_str($row["rss_category"]);
  3637. $rss_sub_category = check_str($row["rss_sub_category"]);
  3638. $rss_sub_category_description = check_str($row["rss_sub_category_desc"]);
  3639. $rss_sub_add_user = check_str($row["rss_sub_add_user"]);
  3640. $rss_sub_add_date = check_str($row["rss_sub_add_date"]);
  3641. $sql = "insert into v_rss_sub_category ";
  3642. $sql .= "(";
  3643. $sql .= "rss_sub_category_uuid, ";
  3644. $sql .= "domain_uuid, ";
  3645. $sql .= "rss_sub_category_language, ";
  3646. $sql .= "rss_category, ";
  3647. $sql .= "rss_sub_category, ";
  3648. $sql .= "rss_sub_category_description, ";
  3649. $sql .= "rss_sub_add_user, ";
  3650. $sql .= "rss_sub_add_date ";
  3651. $sql .= ")";
  3652. $sql .= "values ";
  3653. $sql .= "(";
  3654. $sql .= "'".$rss_sub_category_uuid."', ";
  3655. $sql .= "'".$domain_uuid."', ";
  3656. $sql .= "'".$rss_sub_category_language."', ";
  3657. $sql .= "'".$rss_category."', ";
  3658. $sql .= "'".$rss_sub_category."', ";
  3659. $sql .= "'".$rss_sub_category_description."', ";
  3660. $sql .= "'".$rss_sub_add_user."', ";
  3661. $sql .= "'".$rss_sub_add_date."' ";
  3662. $sql .= ")";
  3663. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3664. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3665. }
  3666. unset ($prep_statement);
  3667. //get the database connection information
  3668. $sql = "select * from v_database_connections ";
  3669. $prep_statement = $db->prepare($sql);
  3670. $prep_statement->execute();
  3671. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3672. foreach ($result as &$row) {
  3673. $database_uuid = uuid();
  3674. $v_id = check_str($row["v_id"]);
  3675. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3676. $database_type = check_str($row["db_type"]);
  3677. $database_host = check_str($row["db_host"]);
  3678. $database_port = check_str($row["db_port"]);
  3679. $database_name = check_str($row["db_name"]);
  3680. $database_username = check_str($row["db_username"]);
  3681. $database_password = check_str($row["db_password"]);
  3682. $database_path = check_str($row["db_path"]);
  3683. $database_description = check_str($row["db_description"]);
  3684. $sql = "insert into v_databases ";
  3685. $sql .= "(";
  3686. $sql .= "database_uuid, ";
  3687. $sql .= "database_type, ";
  3688. $sql .= "database_host, ";
  3689. $sql .= "database_port, ";
  3690. $sql .= "database_name, ";
  3691. $sql .= "database_username, ";
  3692. $sql .= "database_password, ";
  3693. $sql .= "database_path, ";
  3694. $sql .= "database_description ";
  3695. $sql .= ")";
  3696. $sql .= "values ";
  3697. $sql .= "(";
  3698. $sql .= "'".$database_uuid."', ";
  3699. $sql .= "'".$database_type."', ";
  3700. $sql .= "'".$database_host."', ";
  3701. $sql .= "'".$database_port."', ";
  3702. $sql .= "'".$database_name."', ";
  3703. $sql .= "'".$database_username."', ";
  3704. $sql .= "'".$database_password."', ";
  3705. $sql .= "'".$database_path."', ";
  3706. $sql .= "'".$database_description."' ";
  3707. $sql .= ")";
  3708. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3709. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3710. }
  3711. unset ($prep_statement);
  3712. //export the dialplan
  3713. $sql = "select * from v_dialplan_includes ";
  3714. $prep_statement = $db->prepare($sql);
  3715. $prep_statement->execute();
  3716. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3717. foreach ($result as &$row) {
  3718. $dialplan_uuid = uuid();
  3719. $v_id = check_str($row["v_id"]);
  3720. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3721. $dialplan_include_id = check_str($row["dialplan_include_id"]);
  3722. $app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db'; //dialplan app_uuid
  3723. $dialplan_name = check_str($row["extension_name"]);
  3724. $dialplan_number = check_str($row["extension_number"]);
  3725. //$dialplan_context = check_str($row["context"]);
  3726. $dialplan_continue = check_str($row["extension_continue"]);
  3727. $dialplan_order = check_str($row["dialplan_order"]);
  3728. $dialplan_enabled = check_str($row["enabled"]);
  3729. $dialplan_description = check_str($row["descr"]);
  3730. //$opt_1_name = check_str($row["opt_1_name"]);
  3731. //$opt_1_value = check_str($row["opt_1_value"]);
  3732. //set the dialplan order
  3733. if ($dialplan_order < 320) { $dialplan_order = 320; }
  3734. //set the dialplan_uuid
  3735. $dialplan_array[$dialplan_include_id]['dialplan_uuid'] = $dialplan_uuid;
  3736. //set the dialplan context
  3737. if (count($domain_array) > 1) {
  3738. $dialplan_context = $domain_array[$v_id]['domain_name'];
  3739. }
  3740. else {
  3741. $dialplan_context = "default";
  3742. }
  3743. if (strlen($domain_uuid) > 0) {
  3744. $sql = "insert into v_dialplans ";
  3745. $sql .= "(";
  3746. $sql .= "dialplan_uuid, ";
  3747. $sql .= "domain_uuid, ";
  3748. $sql .= "app_uuid, ";
  3749. $sql .= "dialplan_name, ";
  3750. $sql .= "dialplan_number, ";
  3751. $sql .= "dialplan_context, ";
  3752. $sql .= "dialplan_continue, ";
  3753. $sql .= "dialplan_order, ";
  3754. $sql .= "dialplan_enabled, ";
  3755. $sql .= "dialplan_description ";
  3756. $sql .= ")";
  3757. $sql .= "values ";
  3758. $sql .= "(";
  3759. $sql .= "'".$dialplan_uuid."', ";
  3760. $sql .= "'".$domain_uuid."', ";
  3761. $sql .= "'".$app_uuid."', ";
  3762. $sql .= "'".$dialplan_name."', ";
  3763. $sql .= "'".$dialplan_number."', ";
  3764. $sql .= "'".$dialplan_context."', ";
  3765. $sql .= "'".$dialplan_continue."', ";
  3766. $sql .= "'".$dialplan_order."', ";
  3767. $sql .= "'".$dialplan_enabled."', ";
  3768. $sql .= "'".$dialplan_description."' ";
  3769. $sql .= ")";
  3770. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3771. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3772. }
  3773. }
  3774. unset ($prep_statement);
  3775. //export the dialplan details
  3776. $sql = "select * from v_dialplan_includes_details ";
  3777. $prep_statement = $db->prepare($sql);
  3778. $prep_statement->execute();
  3779. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3780. foreach ($result as &$row) {
  3781. $dialplan_detail_uuid = uuid();
  3782. $v_id = check_str($row["v_id"]);
  3783. $dialplan_include_id = check_str($row["dialplan_include_id"]);
  3784. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3785. $dialplan_detail_tag = check_str($row["tag"]);
  3786. $dialplan_detail_type = check_str($row["field_type"]);
  3787. $dialplan_detail_data = check_str($row["field_data"]);
  3788. $dialplan_detail_break = check_str($row["field_break"]);
  3789. $dialplan_detail_inline = check_str($row["field_inline"]);
  3790. $dialplan_detail_group = check_str($row["field_group"]);
  3791. $dialplan_detail_order = check_str($row["field_order"]);
  3792. // $dialplan_detail_data = str_replace("\\\\", "\\", $dialplan_detail_data);
  3793. //get the dialplan_uuid
  3794. $dialplan_uuid = $dialplan_array[$dialplan_include_id]['dialplan_uuid'];
  3795. if (strlen($domain_uuid) > 0 && strlen($dialplan_uuid) > 0 ) {
  3796. $sql = "insert into v_dialplan_details ";
  3797. $sql .= "(";
  3798. $sql .= "dialplan_detail_uuid, ";
  3799. $sql .= "domain_uuid, ";
  3800. $sql .= "dialplan_uuid, ";
  3801. $sql .= "dialplan_detail_tag, ";
  3802. $sql .= "dialplan_detail_type, ";
  3803. $sql .= "dialplan_detail_data, ";
  3804. $sql .= "dialplan_detail_break, ";
  3805. $sql .= "dialplan_detail_inline, ";
  3806. $sql .= "dialplan_detail_group, ";
  3807. $sql .= "dialplan_detail_order ";
  3808. $sql .= ")";
  3809. $sql .= "values ";
  3810. $sql .= "(";
  3811. $sql .= "'".$dialplan_detail_uuid."', ";
  3812. $sql .= "'".$domain_uuid."', ";
  3813. $sql .= "'".$dialplan_uuid."', ";
  3814. $sql .= "'".$dialplan_detail_tag."', ";
  3815. $sql .= "'".$dialplan_detail_type."', ";
  3816. $sql .= "'".$dialplan_detail_data."', ";
  3817. $sql .= "'".$dialplan_detail_break."', ";
  3818. $sql .= "'".$dialplan_detail_inline."', ";
  3819. if (strlen($dialplan_detail_group) > 0) {
  3820. $sql .= "'".$dialplan_detail_group."', ";
  3821. }
  3822. else {
  3823. $sql .= "null, ";
  3824. }
  3825. if (strlen($dialplan_detail_order) > 0) {
  3826. $sql .= "'".$dialplan_detail_order."' ";
  3827. }
  3828. else {
  3829. $sql .= "'330' ";
  3830. }
  3831. $sql .= ")";
  3832. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3833. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3834. }
  3835. }
  3836. unset ($prep_statement);
  3837. //export the inbound routes
  3838. $sql = "select * from v_public_includes ";
  3839. $prep_statement = $db->prepare($sql);
  3840. $prep_statement->execute();
  3841. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3842. foreach ($result as &$row) {
  3843. $public_include_id = $row["public_include_id"];
  3844. $dialplan_uuid = uuid();
  3845. $v_id = check_str($row["v_id"]);
  3846. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3847. $app_uuid = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4';
  3848. $dialplan_name = check_str($row["extension_name"]);
  3849. $dialplan_context = 'public';
  3850. $dialplan_continue = check_str($row["extension_continue"]);
  3851. $dialplan_order = check_str($row["public_order"]);
  3852. $dialplan_enabled = check_str($row["enabled"]);
  3853. $dialplan_description = check_str($row["descr"]);
  3854. //set the dialplan_uuid
  3855. $public_dialplan_array[$public_include_id]['dialplan_uuid'] = $dialplan_uuid;
  3856. $sql = "insert into v_dialplans ";
  3857. $sql .= "(";
  3858. $sql .= "dialplan_uuid, ";
  3859. $sql .= "domain_uuid, ";
  3860. $sql .= "app_uuid, ";
  3861. $sql .= "dialplan_name, ";
  3862. $sql .= "dialplan_context, ";
  3863. $sql .= "dialplan_continue, ";
  3864. $sql .= "dialplan_order, ";
  3865. $sql .= "dialplan_enabled, ";
  3866. $sql .= "dialplan_description ";
  3867. $sql .= ")";
  3868. $sql .= "values ";
  3869. $sql .= "(";
  3870. $sql .= "'".$dialplan_uuid."', ";
  3871. $sql .= "'".$domain_uuid."', ";
  3872. $sql .= "'".$app_uuid."', ";
  3873. $sql .= "'".$dialplan_name."', ";
  3874. $sql .= "'".$dialplan_context."', ";
  3875. $sql .= "'".$dialplan_continue."', ";
  3876. $sql .= "'".$dialplan_order."', ";
  3877. $sql .= "'".$dialplan_enabled."', ";
  3878. $sql .= "'".$dialplan_description."' ";
  3879. $sql .= ")";
  3880. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3881. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3882. }
  3883. unset ($prep_statement);
  3884. //export inbound route details
  3885. $sql = "select * from v_public_includes_details ";
  3886. $prep_statement = $db->prepare($sql);
  3887. $prep_statement->execute();
  3888. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3889. foreach ($result as &$row) {
  3890. $dialplan_detail_uuid = uuid();
  3891. $v_id = check_str($row["v_id"]);
  3892. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3893. $public_include_id = check_str($row["public_include_id"]);
  3894. $dialplan_detail_tag = check_str($row["tag"]);
  3895. $dialplan_detail_type = check_str($row["field_type"]);
  3896. $dialplan_detail_data = check_str($row["field_data"]);
  3897. $dialplan_detail_break = check_str($row["field_break"]);
  3898. $dialplan_detail_inline = check_str($row["field_inline"]);
  3899. $dialplan_detail_group = check_str($row["field_group"]);
  3900. $dialplan_detail_order = check_str($row["field_order"]);
  3901. //get the dialplan_uuid
  3902. $dialplan_uuid = $public_dialplan_array[$public_include_id]['dialplan_uuid'];
  3903. $sql = "insert into v_dialplan_details ";
  3904. $sql .= "(";
  3905. $sql .= "dialplan_detail_uuid, ";
  3906. $sql .= "domain_uuid, ";
  3907. $sql .= "dialplan_uuid, ";
  3908. $sql .= "dialplan_detail_tag, ";
  3909. $sql .= "dialplan_detail_type, ";
  3910. $sql .= "dialplan_detail_data, ";
  3911. $sql .= "dialplan_detail_break, ";
  3912. $sql .= "dialplan_detail_inline, ";
  3913. $sql .= "dialplan_detail_group, ";
  3914. $sql .= "dialplan_detail_order ";
  3915. $sql .= ")";
  3916. $sql .= "values ";
  3917. $sql .= "(";
  3918. $sql .= "'".$dialplan_detail_uuid."', ";
  3919. $sql .= "'".$domain_uuid."', ";
  3920. $sql .= "'".$dialplan_uuid."', ";
  3921. $sql .= "'".$dialplan_detail_tag."', ";
  3922. $sql .= "'".$dialplan_detail_type."', ";
  3923. $sql .= "'".$dialplan_detail_data."', ";
  3924. $sql .= "'".$dialplan_detail_break."', ";
  3925. $sql .= "'".$dialplan_detail_inline."', ";
  3926. if (strlen($dialplan_detail_group) > 0) {
  3927. $sql .= "'".$dialplan_detail_group."', ";
  3928. }
  3929. else {
  3930. $sql .= "null, ";
  3931. }
  3932. if (strlen($dialplan_detail_order) > 0) {
  3933. $sql .= "'".$dialplan_detail_order."' ";
  3934. }
  3935. else {
  3936. $sql .= "null ";
  3937. }
  3938. $sql .= ")";
  3939. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3940. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3941. }
  3942. unset ($prep_statement);
  3943. //set the app_uuid for the dialplan outbound route
  3944. $sql = "select * from v_dialplan_includes_details ";
  3945. $sql .= "where (";
  3946. $sql .= "field_data like '%sofia/gateway/%' ";
  3947. $sql .= "or field_data like '%freetdm%' ";
  3948. $sql .= "or field_data like '%openzap%' ";
  3949. $sql .= "or field_data like '%dingaling%' ";
  3950. $sql .= "or field_data like '%enum_auto_route%' ";
  3951. $sql .= ") ";
  3952. $prepstatement = $db->prepare(check_sql($sql));
  3953. $prepstatement->execute();
  3954. $result = $prepstatement->fetchAll();
  3955. foreach ($result as &$row) {
  3956. $dialplan_include_id = check_str($row["dialplan_include_id"]);
  3957. //get the dialplan_uuid
  3958. $dialplan_uuid = $dialplan_array[$dialplan_include_id]['dialplan_uuid'];
  3959. $sql = "update v_dialplans set ";
  3960. $sql .= "app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
  3961. $sql .= "where dialplan_uuid = '$dialplan_uuid'";
  3962. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  3963. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  3964. unset($sql);
  3965. }
  3966. unset ($prepstatement);
  3967. //export the extensions
  3968. $sql = "select * from v_extensions ";
  3969. $prep_statement = $db->prepare($sql);
  3970. $prep_statement->execute();
  3971. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  3972. foreach ($result as &$row) {
  3973. $extension_uuid = uuid();
  3974. $v_id = check_str($row["v_id"]);
  3975. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  3976. $extension = check_str($row["extension"]);
  3977. $number_alias = check_str($row["number_alias"]);
  3978. $password = check_str($row["password"]);
  3979. $user_list = check_str($row["user_list"]);
  3980. $provisioning_list = check_str($row["provisioning_list"]);
  3981. $mailbox = check_str($row["mailbox"]);
  3982. $vm_password = check_str($row["vm_password"]);
  3983. $accountcode = check_str($row["accountcode"]);
  3984. $effective_caller_id_name = check_str($row["effective_caller_id_name"]);
  3985. $effective_caller_id_number = check_str($row["effective_caller_id_number"]);
  3986. $outbound_caller_id_name = check_str($row["outbound_caller_id_name"]);
  3987. $outbound_caller_id_number = check_str($row["outbound_caller_id_number"]);
  3988. $limit_max = check_str($row["limit_max"]);
  3989. $limit_destination = check_str($row["limit_destination"]);
  3990. $vm_enabled = check_str($row["vm_enabled"]);
  3991. $vm_mailto = check_str($row["vm_mailto"]);
  3992. $vm_attach_file = check_str($row["vm_attach_file"]);
  3993. $vm_keep_local_after_email = check_str($row["vm_keep_local_after_email"]);
  3994. $user_context = check_str($row["user_context"]);
  3995. $toll_allow = check_str($row["toll_allow"]);
  3996. $call_group = check_str($row["callgroup"]);
  3997. $hold_music = check_str($row["hold_music"]);
  3998. $auth_acl = check_str($row["auth_acl"]);
  3999. $cidr = check_str($row["cidr"]);
  4000. $sip_force_contact = check_str($row["sip_force_contact"]);
  4001. $nibble_account = check_str($row["nibble_account"]);
  4002. $sip_force_expires = check_str($row["sip_force_expires"]);
  4003. $enabled = check_str($row["enabled"]);
  4004. $description = check_str($row["description"]);
  4005. $mwi_account = check_str($row["mwi_account"]);
  4006. $sip_bypass_media = check_str($row["sip_bypass_media"]);
  4007. $sql = "insert into v_extensions ";
  4008. $sql .= "(";
  4009. $sql .= "extension_uuid, ";
  4010. $sql .= "domain_uuid, ";
  4011. $sql .= "extension, ";
  4012. $sql .= "number_alias, ";
  4013. $sql .= "password, ";
  4014. $sql .= "provisioning_list, ";
  4015. $sql .= "mailbox, ";
  4016. $sql .= "vm_password, ";
  4017. $sql .= "accountcode, ";
  4018. $sql .= "effective_caller_id_name, ";
  4019. $sql .= "effective_caller_id_number, ";
  4020. $sql .= "outbound_caller_id_name, ";
  4021. $sql .= "outbound_caller_id_number, ";
  4022. $sql .= "limit_max, ";
  4023. $sql .= "limit_destination, ";
  4024. $sql .= "vm_enabled, ";
  4025. $sql .= "vm_mailto, ";
  4026. $sql .= "vm_attach_file, ";
  4027. $sql .= "vm_keep_local_after_email, ";
  4028. $sql .= "user_context, ";
  4029. $sql .= "toll_allow, ";
  4030. $sql .= "call_group, ";
  4031. $sql .= "hold_music, ";
  4032. $sql .= "auth_acl, ";
  4033. $sql .= "cidr, ";
  4034. $sql .= "sip_force_contact, ";
  4035. $sql .= "nibble_account, ";
  4036. $sql .= "sip_force_expires, ";
  4037. $sql .= "enabled, ";
  4038. $sql .= "description, ";
  4039. $sql .= "mwi_account, ";
  4040. $sql .= "sip_bypass_media ";
  4041. $sql .= ")";
  4042. $sql .= "values ";
  4043. $sql .= "(";
  4044. $sql .= "'".$extension_uuid."', ";
  4045. $sql .= "'".$domain_uuid."', ";
  4046. $sql .= "'".$extension."', ";
  4047. $sql .= "'".$number_alias."', ";
  4048. $sql .= "'".$password."', ";
  4049. $sql .= "'".$provisioning_list."', ";
  4050. $sql .= "'".$mailbox."', ";
  4051. $sql .= "'".$vm_password."', ";
  4052. $sql .= "'".$accountcode."', ";
  4053. $sql .= "'".$effective_caller_id_name."', ";
  4054. $sql .= "'".$effective_caller_id_number."', ";
  4055. $sql .= "'".$outbound_caller_id_name."', ";
  4056. $sql .= "'".$outbound_caller_id_number."', ";
  4057. if (strlen($limit_max) > 0) {
  4058. $sql .= "'".$limit_max."', ";
  4059. }
  4060. else {
  4061. $sql .= "null, ";
  4062. }
  4063. $sql .= "'".$limit_destination."', ";
  4064. $sql .= "'".$vm_enabled."', ";
  4065. $sql .= "'".$vm_mailto."', ";
  4066. $sql .= "'".$vm_attach_file."', ";
  4067. $sql .= "'".$vm_keep_local_after_email."', ";
  4068. $sql .= "'".$user_context."', ";
  4069. $sql .= "'".$toll_allow."', ";
  4070. $sql .= "'".$call_group."', ";
  4071. $sql .= "'".$hold_music."', ";
  4072. $sql .= "'".$auth_acl."', ";
  4073. $sql .= "'".$cidr."', ";
  4074. $sql .= "'".$sip_force_contact."', ";
  4075. if (strlen($nibble_account) > 0) {
  4076. $sql .= "'".$nibble_account."', ";
  4077. }
  4078. else {
  4079. $sql .= "null, ";
  4080. }
  4081. if (strlen($sip_force_expires) > 0) {
  4082. $sql .= "'".$sip_force_expires."', ";
  4083. }
  4084. else {
  4085. $sql .= "null, ";
  4086. }
  4087. $sql .= "'".$enabled."', ";
  4088. $sql .= "'".$description."', ";
  4089. $sql .= "'".$mwi_account."', ";
  4090. $sql .= "'".$sip_bypass_media."' ";
  4091. $sql .= ")";
  4092. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4093. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4094. $user_list_array = explode("|", $user_list);
  4095. foreach($user_list_array as $username){
  4096. if (strlen($username) > 0) {
  4097. $user_uuid = $user_array[$v_id][$username]['user_uuid'];
  4098. if (strlen($user_uuid) > 0) {
  4099. $sql = "insert into v_extension_users ";
  4100. $sql .= "(";
  4101. $sql .= "extension_user_uuid, ";
  4102. $sql .= "domain_uuid, ";
  4103. $sql .= "extension_uuid, ";
  4104. $sql .= "user_uuid ";
  4105. $sql .= ")";
  4106. $sql .= "values ";
  4107. $sql .= "(";
  4108. $sql .= "'".uuid()."', ";
  4109. $sql .= "'".$domain_uuid."', ";
  4110. $sql .= "'".$extension_uuid."', ";
  4111. $sql .= "'".$user_uuid."' ";
  4112. $sql .= ")";
  4113. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4114. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4115. }
  4116. }
  4117. }
  4118. unset($user_list_array, $username, $extension_uuid);
  4119. }
  4120. unset ($prep_statement);
  4121. //get the conference identifiers
  4122. $sql = "select * from v_dialplan_includes_details ";
  4123. $sql .= "where field_data like 'conference_user_list%' ";
  4124. $prepstatement = $db->prepare(check_sql($sql));
  4125. $prepstatement->execute();
  4126. $x = 0;
  4127. $result = $prepstatement->fetchAll();
  4128. foreach ($result as &$row) {
  4129. $dialplan_include_id = $row["dialplan_include_id"];
  4130. $field_type = $row["field_type"];
  4131. $conference_array[$x]['dialplan_include_id'] = $dialplan_include_id;
  4132. $x++;
  4133. }
  4134. unset ($prepstatement);
  4135. //get the conferences
  4136. $sql = "select * from v_dialplan_includes ";
  4137. $x = 0;
  4138. foreach ($conference_array as &$row) {
  4139. if ($x == 0) {
  4140. $sql .= " where dialplan_include_id = '".$row['dialplan_include_id']."' \n";
  4141. }
  4142. else {
  4143. $sql .= " or dialplan_include_id = '".$row['dialplan_include_id']."' \n";
  4144. }
  4145. $x++;
  4146. }
  4147. $sql .= "order by dialplan_order, extension_name asc ";
  4148. $prep_statement = $db->prepare(check_sql($sql));
  4149. $prep_statement->execute();
  4150. $result = $prep_statement->fetchAll();
  4151. foreach ($result as &$tmp) {
  4152. //get the values from the database
  4153. $v_id = check_str($tmp["v_id"]);
  4154. $dialplan_include_id = check_str($tmp["dialplan_include_id"]);
  4155. //get the dialplan
  4156. $sql = "select * from v_dialplan_includes ";
  4157. $sql .= "where v_id = '$v_id' ";
  4158. $sql .= "and dialplan_include_id = '$dialplan_include_id' ";
  4159. $row = $db->query($sql)->fetch();
  4160. $conference_name = $row['extension_name'];
  4161. $conference_name = str_replace("-", " ", $conference_name);
  4162. //$context = $row['context'];
  4163. $conference_order = $row['dialplan_order'];
  4164. $conference_enabled = $row['enabled'];
  4165. $conference_description = $row['descr'];
  4166. //get the dialplan details
  4167. $sql = "select * from v_dialplan_includes_details ";
  4168. $sql .= "where v_id = '$v_id' ";
  4169. $sql .= "and dialplan_include_id = '$dialplan_include_id' ";
  4170. $prepstatement = $db->prepare(check_sql($sql));
  4171. $prepstatement->execute();
  4172. $result_details = $prepstatement->fetchAll();
  4173. foreach ($result_details as &$row) {
  4174. if ($row['field_type'] == "destination_number") {
  4175. $conference_extension = $row['field_data'];
  4176. $conference_extension = trim($conference_extension, '^$');
  4177. }
  4178. $field_data_array = explode("=", $row['field_data']);
  4179. if ($field_data_array[0] == "conference_user_list") {
  4180. $user_list = $field_data_array[1];
  4181. }
  4182. if ($row['field_type'] == "conference") {
  4183. $field_data = $row['field_data'];
  4184. $tmp_pos = stripos($field_data, "@");
  4185. if ($tmp_pos !== false) {
  4186. $tmp_field_data = substr($field_data, $tmp_pos+1, strlen($field_data));
  4187. $tmp_field_data_array = explode("+",$tmp_field_data);
  4188. foreach ($tmp_field_data_array as &$tmp_row) {
  4189. if (is_numeric($tmp_row)) {
  4190. $conference_pin_number = $tmp_row;
  4191. }
  4192. if (substr($tmp_row, 0, 5) == "flags") {
  4193. $conference_flags = substr($tmp_row, 6, $tmp_row-1);
  4194. }
  4195. }
  4196. $conference_profile = $tmp_field_data_array[0];
  4197. }
  4198. }
  4199. }
  4200. //get the uuids
  4201. $dialplan_uuid = $dialplan_array[$dialplan_include_id]['dialplan_uuid'];
  4202. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4203. $conference_uuid = uuid();
  4204. //add the conference
  4205. $sql = "insert into v_conferences ";
  4206. $sql .= "(";
  4207. $sql .= "domain_uuid, ";
  4208. $sql .= "conference_uuid, ";
  4209. $sql .= "dialplan_uuid, ";
  4210. $sql .= "conference_name, ";
  4211. $sql .= "conference_extension, ";
  4212. $sql .= "conference_pin_number, ";
  4213. $sql .= "conference_profile, ";
  4214. $sql .= "conference_flags, ";
  4215. $sql .= "conference_order, ";
  4216. $sql .= "conference_description, ";
  4217. $sql .= "conference_enabled ";
  4218. $sql .= ")";
  4219. $sql .= "values ";
  4220. $sql .= "(";
  4221. $sql .= "'$domain_uuid', ";
  4222. $sql .= "'$conference_uuid', ";
  4223. $sql .= "'$dialplan_uuid', ";
  4224. $sql .= "'$conference_name', ";
  4225. $sql .= "'$conference_extension', ";
  4226. $sql .= "'$conference_pin_number', ";
  4227. $sql .= "'$conference_profile', ";
  4228. $sql .= "'$conference_flags', ";
  4229. $sql .= "'$conference_order', ";
  4230. $sql .= "'$conference_description', ";
  4231. $sql .= "'$conference_enabled' ";
  4232. $sql .= ")";
  4233. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4234. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4235. //add the assigned users to the conference
  4236. $user_list_array = explode("|", $user_list);
  4237. foreach($user_list_array as $username){
  4238. if (strlen($username) > 0) {
  4239. $user_uuid = $user_array[$v_id][$username]['user_uuid'];
  4240. if (strlen($user_uuid) > 0) {
  4241. $sql = "insert into v_conference_users ";
  4242. $sql .= "(";
  4243. $sql .= "conference_user_uuid, ";
  4244. $sql .= "domain_uuid, ";
  4245. $sql .= "conference_uuid, ";
  4246. $sql .= "user_uuid ";
  4247. $sql .= ")";
  4248. $sql .= "values ";
  4249. $sql .= "(";
  4250. $sql .= "'".uuid()."', ";
  4251. $sql .= "'".$domain_uuid."', ";
  4252. $sql .= "'".$conference_uuid."', ";
  4253. $sql .= "'".$user_uuid."' ";
  4254. $sql .= ")";
  4255. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4256. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4257. }
  4258. }
  4259. }
  4260. unset($user_list_array);
  4261. }
  4262. unset ($prepstatement, $result, $sql, $user_list);
  4263. //get the fax information
  4264. $sql = "select * from v_fax ";
  4265. $prep_statement = $db->prepare($sql);
  4266. $prep_statement->execute();
  4267. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4268. foreach ($result as &$row) {
  4269. $fax_uuid = uuid();
  4270. $v_id = check_str($row["v_id"]);
  4271. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4272. $fax_extension = check_str($row["fax_extension"]);
  4273. $fax_name = check_str($row["fax_name"]);
  4274. $fax_email = check_str($row["fax_email"]);
  4275. $fax_pin_number = check_str($row["fax_pin_number"]);
  4276. $fax_caller_id_name = check_str($row["fax_caller_id_name"]);
  4277. $fax_caller_id_number = check_str($row["fax_caller_id_number"]);
  4278. $fax_user_list = check_str($row["fax_user_list"]);
  4279. $fax_forward_number = check_str($row["fax_forward_number"]);
  4280. $fax_description = check_str($row["fax_description"]);
  4281. $sql = "insert into v_fax ";
  4282. $sql .= "(";
  4283. $sql .= "fax_uuid, ";
  4284. $sql .= "domain_uuid, ";
  4285. //dialplan_uuid
  4286. $sql .= "fax_extension, ";
  4287. $sql .= "fax_name, ";
  4288. $sql .= "fax_email, ";
  4289. $sql .= "fax_pin_number, ";
  4290. $sql .= "fax_caller_id_name, ";
  4291. $sql .= "fax_caller_id_number, ";
  4292. $sql .= "fax_forward_number, ";
  4293. $sql .= "fax_description ";
  4294. $sql .= ")";
  4295. $sql .= "values ";
  4296. $sql .= "(";
  4297. $sql .= "'".$fax_uuid."', ";
  4298. $sql .= "'".$domain_uuid."', ";
  4299. //dialplan_uuid
  4300. $sql .= "'".$fax_extension."', ";
  4301. $sql .= "'".$fax_name."', ";
  4302. $sql .= "'".$fax_email."', ";
  4303. $sql .= "'".$fax_pin_number."', ";
  4304. $sql .= "'".$fax_caller_id_name."', ";
  4305. $sql .= "'".$fax_caller_id_number."', ";
  4306. if (strlen($fax_forward_number) > 0) {
  4307. $sql .= "'".$fax_forward_number."', ";
  4308. }
  4309. else {
  4310. $sql .= "null, ";
  4311. }
  4312. $sql .= "'".$fax_description."' ";
  4313. $sql .= ")";
  4314. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4315. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4316. $user_list_array = explode("|", $fax_user_list);
  4317. foreach($user_list_array as $username){
  4318. if (strlen($username) > 0) {
  4319. $user_uuid = $user_array[$v_id][$username]['user_uuid'];
  4320. if (strlen($user_uuid) > 0) {
  4321. $sql = "insert into v_fax_users ";
  4322. $sql .= "(";
  4323. $sql .= "fax_user_uuid, ";
  4324. $sql .= "domain_uuid, ";
  4325. $sql .= "fax_uuid, ";
  4326. $sql .= "user_uuid ";
  4327. $sql .= ")";
  4328. $sql .= "values ";
  4329. $sql .= "(";
  4330. $sql .= "'".uuid()."', ";
  4331. $sql .= "'".$domain_uuid."', ";
  4332. $sql .= "'".$fax_uuid."', ";
  4333. $sql .= "'".$user_uuid."' ";
  4334. $sql .= ")";
  4335. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4336. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4337. }
  4338. }
  4339. }
  4340. unset($user_list_array);
  4341. unset($username);
  4342. }
  4343. unset ($prep_statement);
  4344. //export the gateways
  4345. $sql = "select * from v_gateways ";
  4346. $prep_statement = $db->prepare($sql);
  4347. $prep_statement->execute();
  4348. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4349. foreach ($result as &$row) {
  4350. $gateway_uuid = uuid();
  4351. $v_id = check_str($row["v_id"]);
  4352. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4353. $gateway = check_str($row["gateway"]);
  4354. $username = check_str($row["username"]);
  4355. $password = check_str($row["password"]);
  4356. $auth_username = check_str($row["auth_username"]);
  4357. $realm = check_str($row["realm"]);
  4358. $from_user = check_str($row["from_user"]);
  4359. $from_domain = check_str($row["from_domain"]);
  4360. $proxy = check_str($row["proxy"]);
  4361. $register_proxy = check_str($row["register_proxy"]);
  4362. $outbound_proxy = check_str($row["outbound_proxy"]);
  4363. $expire_seconds = check_str($row["expire_seconds"]);
  4364. $register = check_str($row["register"]);
  4365. $register_transport = check_str($row["register_transport"]);
  4366. $retry_seconds = check_str($row["retry_seconds"]);
  4367. $extension = check_str($row["extension"]);
  4368. $ping = check_str($row["ping"]);
  4369. $caller_id_in_from = check_str($row["caller_id_in_from"]);
  4370. $supress_cng = check_str($row["supress_cng"]);
  4371. $sip_cid_type = check_str($row["sip_cid_type"]);
  4372. $extension_in_contact = check_str($row["extension_in_contact"]);
  4373. $context = check_str($row["context"]);
  4374. $profile = check_str($row["profile"]);
  4375. $enabled = check_str($row["enabled"]);
  4376. $description = check_str($row["description"]);
  4377. $sql = "insert into v_gateways ";
  4378. $sql .= "(";
  4379. $sql .= "gateway_uuid, ";
  4380. $sql .= "domain_uuid, ";
  4381. $sql .= "gateway, ";
  4382. $sql .= "username, ";
  4383. $sql .= "password, ";
  4384. $sql .= "auth_username, ";
  4385. $sql .= "realm, ";
  4386. $sql .= "from_user, ";
  4387. $sql .= "from_domain, ";
  4388. $sql .= "proxy, ";
  4389. $sql .= "register_proxy, ";
  4390. $sql .= "outbound_proxy, ";
  4391. $sql .= "expire_seconds, ";
  4392. $sql .= "register, ";
  4393. $sql .= "register_transport, ";
  4394. $sql .= "retry_seconds, ";
  4395. $sql .= "extension, ";
  4396. $sql .= "ping, ";
  4397. $sql .= "caller_id_in_from, ";
  4398. $sql .= "supress_cng, ";
  4399. $sql .= "sip_cid_type, ";
  4400. $sql .= "extension_in_contact, ";
  4401. $sql .= "context, ";
  4402. $sql .= "profile, ";
  4403. $sql .= "enabled, ";
  4404. $sql .= "description ";
  4405. $sql .= ")";
  4406. $sql .= "values ";
  4407. $sql .= "(";
  4408. $sql .= "'".$gateway_uuid."', ";
  4409. $sql .= "'".$domain_uuid."', ";
  4410. $sql .= "'".$gateway."', ";
  4411. $sql .= "'".$username."', ";
  4412. $sql .= "'".$password."', ";
  4413. $sql .= "'".$auth_username."', ";
  4414. $sql .= "'".$realm."', ";
  4415. $sql .= "'".$from_user."', ";
  4416. $sql .= "'".$from_domain."', ";
  4417. $sql .= "'".$proxy."', ";
  4418. $sql .= "'".$register_proxy."', ";
  4419. $sql .= "'".$outbound_proxy."', ";
  4420. $sql .= "'".$expire_seconds."', ";
  4421. $sql .= "'".$register."', ";
  4422. $sql .= "'".$register_transport."', ";
  4423. $sql .= "'".$retry_seconds."', ";
  4424. $sql .= "'".$extension."', ";
  4425. $sql .= "'".$ping."', ";
  4426. $sql .= "'".$caller_id_in_from."', ";
  4427. $sql .= "'".$supress_cng."', ";
  4428. $sql .= "'".$sip_cid_type."', ";
  4429. $sql .= "'".$extension_in_contact."', ";
  4430. $sql .= "'".$context."', ";
  4431. $sql .= "'".$profile."', ";
  4432. $sql .= "'".$enabled."', ";
  4433. $sql .= "'".$description."' ";
  4434. $sql .= ")";
  4435. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4436. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4437. }
  4438. unset ($prep_statement);
  4439. //export the provisioning information
  4440. $sql = "select * from v_hardware_phones ";
  4441. $prep_statement = $db->prepare($sql);
  4442. $prep_statement->execute();
  4443. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4444. foreach ($result as &$row) {
  4445. $hardware_phone_uuid = uuid();
  4446. $v_id = check_str($row["v_id"]);
  4447. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4448. $phone_mac_address = check_str($row["phone_mac_address"]);
  4449. $phone_label = check_str($row["phone_label"]);
  4450. $phone_vendor = check_str($row["phone_vendor"]);
  4451. $phone_model = check_str($row["phone_model"]);
  4452. $phone_firmware_version = check_str($row["phone_firmware_version"]);
  4453. $phone_provision_enable = check_str($row["phone_provision_enable"]);
  4454. $phone_template = check_str($row["phone_template"]);
  4455. $phone_username = check_str($row["phone_username"]);
  4456. $phone_password = check_str($row["phone_password"]);
  4457. $phone_time_zone = check_str($row["phone_time_zone"]);
  4458. $phone_description = check_str($row["phone_description"]);
  4459. $sql = "insert into v_hardware_phones ";
  4460. $sql .= "(";
  4461. $sql .= "hardware_phone_uuid, ";
  4462. $sql .= "domain_uuid, ";
  4463. $sql .= "phone_mac_address, ";
  4464. $sql .= "phone_label, ";
  4465. $sql .= "phone_vendor, ";
  4466. $sql .= "phone_model, ";
  4467. $sql .= "phone_firmware_version, ";
  4468. $sql .= "phone_provision_enable, ";
  4469. $sql .= "phone_template, ";
  4470. $sql .= "phone_username, ";
  4471. $sql .= "phone_password, ";
  4472. $sql .= "phone_time_zone, ";
  4473. $sql .= "phone_description ";
  4474. $sql .= ")";
  4475. $sql .= "values ";
  4476. $sql .= "(";
  4477. $sql .= "'".$hardware_phone_uuid."', ";
  4478. $sql .= "'".$domain_uuid."', ";
  4479. $sql .= "'".$phone_mac_address."', ";
  4480. $sql .= "'".$phone_label."', ";
  4481. $sql .= "'".$phone_vendor."', ";
  4482. $sql .= "'".$phone_model."', ";
  4483. $sql .= "'".$phone_firmware_version."', ";
  4484. $sql .= "'".$phone_provision_enable."', ";
  4485. $sql .= "'".$phone_template."', ";
  4486. $sql .= "'".$phone_username."', ";
  4487. $sql .= "'".$phone_password."', ";
  4488. $sql .= "'".$phone_time_zone."', ";
  4489. $sql .= "'".$phone_description."' ";
  4490. $sql .= ")";
  4491. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4492. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4493. }
  4494. unset ($prep_statement);
  4495. //export the hunt groups
  4496. $sql = "select * from v_hunt_group ";
  4497. $prep_statement = $db->prepare($sql);
  4498. $prep_statement->execute();
  4499. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4500. foreach ($result as &$row) {
  4501. $hunt_group_uuid = uuid();
  4502. $v_id = check_str($row["v_id"]);
  4503. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4504. $hunt_group_extension = check_str($row["hunt_group_extension"]);
  4505. $hunt_group_id = check_str($row["hunt_group_id"]);
  4506. $hunt_group_name = check_str($row["hunt_group_name"]);
  4507. $hunt_group_type = check_str($row["hunt_group_type"]);
  4508. $hunt_group_context = check_str($row["hunt_group_context"]);
  4509. $hunt_group_timeout = check_str($row["hunt_group_timeout"]);
  4510. $hunt_group_timeout_destination = check_str($row["hunt_group_timeout_destination"]);
  4511. $hunt_group_timeout_type = check_str($row["hunt_group_time_out_type"]);
  4512. $hunt_group_ringback = check_str($row["hunt_group_ringback"]);
  4513. $hunt_group_cid_name_prefix = check_str($row["hunt_group_cid_name_prefix"]);
  4514. $hunt_group_pin = check_str($row["hunt_group_pin"]);
  4515. $hunt_group_caller_announce = check_str($row["hunt_group_caller_announce"]);
  4516. $hunt_group_call_prompt = check_str($row["hunt_group_call_prompt"]);
  4517. $hunt_group_user_list = check_str($row["hunt_group_user_list"]);
  4518. $hunt_group_enabled = check_str($row["hunt_group_enabled"]);
  4519. $hunt_group_description = check_str($row["hunt_group_descr"]);
  4520. //set the hunt_group_uuid
  4521. $hunt_group_array[$hunt_group_id]['hunt_group_uuid'] = $hunt_group_uuid;
  4522. $sql = "insert into v_hunt_groups ";
  4523. $sql .= "(";
  4524. $sql .= "hunt_group_uuid, ";
  4525. $sql .= "domain_uuid, ";
  4526. $sql .= "hunt_group_extension, ";
  4527. $sql .= "hunt_group_name, ";
  4528. $sql .= "hunt_group_type, ";
  4529. $sql .= "hunt_group_context, ";
  4530. $sql .= "hunt_group_timeout, ";
  4531. $sql .= "hunt_group_timeout_destination, ";
  4532. $sql .= "hunt_group_timeout_type, ";
  4533. $sql .= "hunt_group_ringback, ";
  4534. $sql .= "hunt_group_cid_name_prefix, ";
  4535. $sql .= "hunt_group_pin, ";
  4536. $sql .= "hunt_group_caller_announce, ";
  4537. $sql .= "hunt_group_call_prompt, ";
  4538. $sql .= "hunt_group_user_list, ";
  4539. $sql .= "hunt_group_enabled, ";
  4540. $sql .= "hunt_group_description ";
  4541. $sql .= ")";
  4542. $sql .= "values ";
  4543. $sql .= "(";
  4544. $sql .= "'".$hunt_group_uuid."', ";
  4545. $sql .= "'".$domain_uuid."', ";
  4546. $sql .= "'".$hunt_group_extension."', ";
  4547. $sql .= "'".$hunt_group_name."', ";
  4548. $sql .= "'".$hunt_group_type."', ";
  4549. $sql .= "'".$hunt_group_context."', ";
  4550. $sql .= "'".$hunt_group_timeout."', ";
  4551. $sql .= "'".$hunt_group_timeout_destination."', ";
  4552. $sql .= "'".$hunt_group_timeout_type."', ";
  4553. $sql .= "'".$hunt_group_ringback."', ";
  4554. $sql .= "'".$hunt_group_cid_name_prefix."', ";
  4555. $sql .= "'".$hunt_group_pin."', ";
  4556. $sql .= "'".$hunt_group_caller_announce."', ";
  4557. $sql .= "'".$hunt_group_call_prompt."', ";
  4558. $sql .= "'".$hunt_group_user_list."', ";
  4559. $sql .= "'".$hunt_group_enabled."', ";
  4560. $sql .= "'".$hunt_group_description."' ";
  4561. $sql .= ")";
  4562. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4563. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4564. }
  4565. unset ($prep_statement);
  4566. //export the hunt group destinations
  4567. $sql = "select * from v_hunt_group_destinations ";
  4568. $prep_statement = $db->prepare($sql);
  4569. $prep_statement->execute();
  4570. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4571. foreach ($result as &$row) {
  4572. $hunt_group_destination_uuid = uuid();
  4573. $v_id = check_str($row["v_id"]);
  4574. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4575. $hunt_group_id = check_str($row["hunt_group_id"]);
  4576. $destination_data = check_str($row["destination_data"]);
  4577. $destination_type = check_str($row["destination_type"]);
  4578. $destination_profile = check_str($row["destination_profile"]);
  4579. $destination_timeout = check_str($row["destination_timeout"]);
  4580. $destination_order = check_str($row["destination_order"]);
  4581. $destination_enabled = check_str($row["destination_enabled"]);
  4582. $destination_description = check_str($row["destination_descr"]);
  4583. //get the hunt_group_uuid
  4584. $hunt_group_uuid = $hunt_group_array[$hunt_group_id]['hunt_group_uuid'];
  4585. $sql = "insert into v_hunt_group_destinations ";
  4586. $sql .= "(";
  4587. $sql .= "hunt_group_destination_uuid, ";
  4588. $sql .= "domain_uuid, ";
  4589. $sql .= "hunt_group_uuid, ";
  4590. $sql .= "destination_data, ";
  4591. $sql .= "destination_type, ";
  4592. $sql .= "destination_profile, ";
  4593. $sql .= "destination_timeout, ";
  4594. $sql .= "destination_order, ";
  4595. $sql .= "destination_enabled, ";
  4596. $sql .= "destination_description ";
  4597. $sql .= ")";
  4598. $sql .= "values ";
  4599. $sql .= "(";
  4600. $sql .= "'".$hunt_group_destination_uuid."', ";
  4601. $sql .= "'".$domain_uuid."', ";
  4602. $sql .= "'".$hunt_group_uuid."', ";
  4603. $sql .= "'".$destination_data."', ";
  4604. $sql .= "'".$destination_type."', ";
  4605. $sql .= "'".$destination_profile."', ";
  4606. $sql .= "'".$destination_timeout."', ";
  4607. if (strlen($destination_order) > 0) {
  4608. $sql .= "'".$destination_order."', ";
  4609. }
  4610. else {
  4611. $sql .= "null, ";
  4612. }
  4613. $sql .= "'".$destination_enabled."', ";
  4614. $sql .= "'".$destination_description."' ";
  4615. $sql .= ")";
  4616. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4617. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4618. }
  4619. unset ($prep_statement);
  4620. //export the invoices
  4621. if ($invoices) {
  4622. //get the invoices and insert them
  4623. $sql = "select * from v_invoices ";
  4624. $prep_statement = $db->prepare($sql);
  4625. $prep_statement->execute();
  4626. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4627. foreach ($result as &$row) {
  4628. $invoice_id = check_str($row["invoice_id"]);
  4629. //set the invoice_uuid
  4630. $invoice_array[$invoice_id]['uuid'] = uuid();
  4631. }
  4632. foreach ($result as &$row) {
  4633. $invoice_id = check_str($row["invoice_id"]);
  4634. $invoice_uuid = uuid();
  4635. $v_id = check_str($row["v_id"]);
  4636. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4637. $contact_id_from = check_str($row["contact_id_from"]);
  4638. $contact_id_to = check_str($row["contact_id_to"]);
  4639. $invoice_number = check_str($row["invoice_number"]);
  4640. $invoice_date = check_str($row["invoice_date"]);
  4641. $invoice_notes = check_str($row["invoice_notes"]);
  4642. //get the uuids
  4643. $invoice_uuid = $invoice_array[$invoice_id]['uuid'];
  4644. $contact_uuid_from = $contact_array[$contact_id_from]['contact_uuid'];
  4645. $contact_uuid_to = $contact_array[$contact_id_to]['contact_uuid'];
  4646. $sql = "insert into v_invoices ";
  4647. $sql .= "(";
  4648. $sql .= "invoice_uuid, ";
  4649. $sql .= "domain_uuid, ";
  4650. $sql .= "contact_uuid_from, ";
  4651. $sql .= "contact_uuid_to, ";
  4652. $sql .= "invoice_number, ";
  4653. $sql .= "invoice_date, ";
  4654. $sql .= "invoice_notes ";
  4655. $sql .= ")";
  4656. $sql .= "values ";
  4657. $sql .= "(";
  4658. $sql .= "'".$invoice_uuid."', ";
  4659. $sql .= "'".$domain_uuid."', ";
  4660. if (strlen($contact_uuid_from) > 0) {
  4661. $sql .= "'".$contact_uuid_from."', ";
  4662. }
  4663. else {
  4664. $sql .= "null, ";
  4665. }
  4666. if (strlen($contact_uuid_to) > 0) {
  4667. $sql .= "'".$contact_uuid_to."', ";
  4668. }
  4669. else {
  4670. $sql .= "null, ";
  4671. }
  4672. if (strlen($invoice_number) > 0) {
  4673. $sql .= "'".$invoice_number."', ";
  4674. }
  4675. else {
  4676. $sql .= "null, ";
  4677. }
  4678. $sql .= "'".$invoice_date."', ";
  4679. $sql .= "'".$invoice_notes."' ";
  4680. $sql .= ")";
  4681. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4682. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4683. }
  4684. unset ($prep_statement);
  4685. //export invoice items
  4686. $sql = "select * from v_invoice_items ";
  4687. $prep_statement = $db->prepare($sql);
  4688. $prep_statement->execute();
  4689. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4690. foreach ($result as &$row) {
  4691. $invoice_item_uuid = uuid();
  4692. $v_id = check_str($row["v_id"]);
  4693. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4694. $invoice_id = check_str($row["invoice_id"]);
  4695. $item_qty = check_str($row["item_qty"]);
  4696. $item_description = check_str($row["item_desc"]);
  4697. $item_unit_price = check_str($row["item_unit_price"]);
  4698. //get the invoice_uuid
  4699. $invoice_uuid = $invoice_array[$invoice_id]['uuid'];
  4700. $sql = "insert into v_invoice_items ";
  4701. $sql .= "(";
  4702. $sql .= "invoice_item_uuid, ";
  4703. $sql .= "domain_uuid, ";
  4704. $sql .= "invoice_uuid, ";
  4705. $sql .= "item_qty, ";
  4706. $sql .= "item_desc, ";
  4707. $sql .= "item_unit_price ";
  4708. $sql .= ")";
  4709. $sql .= "values ";
  4710. $sql .= "(";
  4711. $sql .= "'".$invoice_item_uuid."', ";
  4712. $sql .= "'".$domain_uuid."', ";
  4713. $sql .= "'".$invoice_uuid."', ";
  4714. if (strlen($item_qty) > 0) {
  4715. $sql .= "'".$item_qty."', ";
  4716. }
  4717. else {
  4718. $sql .= "null, ";
  4719. }
  4720. $sql .= "'".$item_desc."', ";
  4721. if (strlen($item_unit_price) > 0) {
  4722. $sql .= "'".$item_unit_price."' ";
  4723. }
  4724. else {
  4725. $sql .= "null ";
  4726. }
  4727. $sql .= ")";
  4728. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4729. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4730. }
  4731. unset ($prep_statement);
  4732. }
  4733. //export the ivr menus
  4734. $sql = "select * from v_ivr_menu ";
  4735. $prep_statement = $db->prepare($sql);
  4736. $prep_statement->execute();
  4737. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4738. foreach ($result as &$row) {
  4739. $ivr_menu_id = check_str($row["ivr_menu_id"]);
  4740. $ivr_menu_uuid = uuid();
  4741. $v_id = check_str($row["v_id"]);
  4742. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4743. $ivr_menu_name = check_str($row["ivr_menu_name"]);
  4744. $ivr_menu_extension = check_str($row["ivr_menu_extension"]);
  4745. $ivr_menu_greet_long = check_str($row["ivr_menu_greet_long"]);
  4746. $ivr_menu_greet_short = check_str($row["ivr_menu_greet_short"]);
  4747. $ivr_menu_invalid_sound = check_str($row["ivr_menu_invalid_sound"]);
  4748. $ivr_menu_exit_sound = check_str($row["ivr_menu_exit_sound"]);
  4749. $ivr_menu_confirm_macro = check_str($row["ivr_menu_confirm_macro"]);
  4750. $ivr_menu_confirm_key = check_str($row["ivr_menu_confirm_key"]);
  4751. $ivr_menu_tts_engine = check_str($row["ivr_menu_tts_engine"]);
  4752. $ivr_menu_tts_voice = check_str($row["ivr_menu_tts_voice"]);
  4753. $ivr_menu_confirm_attempts = check_str($row["ivr_menu_confirm_attempts"]);
  4754. $ivr_menu_timeout = check_str($row["ivr_menu_timeout"]);
  4755. $ivr_menu_exit_app = check_str($row["ivr_menu_exit_app"]);
  4756. $ivr_menu_exit_data = check_str($row["ivr_menu_exit_data"]);
  4757. $ivr_menu_inter_digit_timeout = check_str($row["ivr_menu_inter_digit_timeout"]);
  4758. $ivr_menu_max_failures = check_str($row["ivr_menu_max_failures"]);
  4759. $ivr_menu_max_timeouts = check_str($row["ivr_menu_max_timeouts"]);
  4760. $ivr_menu_digit_len = check_str($row["ivr_menu_digit_len"]);
  4761. $ivr_menu_direct_dial = check_str($row["ivr_menu_direct_dial"]);
  4762. $ivr_menu_enabled = check_str($row["ivr_menu_enabled"]);
  4763. $ivr_menu_description = check_str($row["ivr_menu_desc"]);
  4764. //set the ivr_menu_uuid
  4765. $ivr_menu_array[$ivr_menu_id]['ivr_menu_uuid'] = $ivr_menu_uuid;
  4766. $sql = "insert into v_ivr_menus ";
  4767. $sql .= "(";
  4768. $sql .= "ivr_menu_uuid, ";
  4769. $sql .= "domain_uuid, ";
  4770. $sql .= "ivr_menu_name, ";
  4771. $sql .= "ivr_menu_extension, ";
  4772. $sql .= "ivr_menu_greet_long, ";
  4773. $sql .= "ivr_menu_greet_short, ";
  4774. $sql .= "ivr_menu_invalid_sound, ";
  4775. $sql .= "ivr_menu_exit_sound, ";
  4776. $sql .= "ivr_menu_confirm_macro, ";
  4777. $sql .= "ivr_menu_confirm_key, ";
  4778. $sql .= "ivr_menu_tts_engine, ";
  4779. $sql .= "ivr_menu_tts_voice, ";
  4780. $sql .= "ivr_menu_confirm_attempts, ";
  4781. $sql .= "ivr_menu_timeout, ";
  4782. $sql .= "ivr_menu_exit_app, ";
  4783. $sql .= "ivr_menu_exit_data, ";
  4784. $sql .= "ivr_menu_inter_digit_timeout, ";
  4785. $sql .= "ivr_menu_max_failures, ";
  4786. $sql .= "ivr_menu_max_timeouts, ";
  4787. $sql .= "ivr_menu_digit_len, ";
  4788. $sql .= "ivr_menu_direct_dial, ";
  4789. $sql .= "ivr_menu_enabled, ";
  4790. $sql .= "ivr_menu_description ";
  4791. $sql .= ")";
  4792. $sql .= "values ";
  4793. $sql .= "(";
  4794. $sql .= "'".$ivr_menu_uuid."', ";
  4795. $sql .= "'".$domain_uuid."', ";
  4796. $sql .= "'".$ivr_menu_name."', ";
  4797. $sql .= "'".$ivr_menu_extension."', ";
  4798. $sql .= "'".$ivr_menu_greet_long."', ";
  4799. $sql .= "'".$ivr_menu_greet_short."', ";
  4800. $sql .= "'".$ivr_menu_invalid_sound."', ";
  4801. $sql .= "'".$ivr_menu_exit_sound."', ";
  4802. $sql .= "'".$ivr_menu_confirm_macro."', ";
  4803. $sql .= "'".$ivr_menu_confirm_key."', ";
  4804. $sql .= "'".$ivr_menu_tts_engine."', ";
  4805. $sql .= "'".$ivr_menu_tts_voice."', ";
  4806. $sql .= "'".$ivr_menu_confirm_attempts."', ";
  4807. $sql .= "'".$ivr_menu_timeout."', ";
  4808. $sql .= "'".$ivr_menu_exit_app."', ";
  4809. $sql .= "'".$ivr_menu_exit_data."', ";
  4810. $sql .= "'".$ivr_menu_inter_digit_timeout."', ";
  4811. $sql .= "'".$ivr_menu_max_failures."', ";
  4812. $sql .= "'".$ivr_menu_max_timeouts."', ";
  4813. $sql .= "'".$ivr_menu_digit_len."', ";
  4814. $sql .= "'".$ivr_menu_direct_dial."', ";
  4815. $sql .= "'".$ivr_menu_enabled."', ";
  4816. $sql .= "'".$ivr_menu_description."' ";
  4817. $sql .= ")";
  4818. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4819. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4820. }
  4821. unset ($prep_statement);
  4822. //export the ivr menu options
  4823. $sql = "select * from v_ivr_menu_options ";
  4824. $prep_statement = $db->prepare($sql);
  4825. $prep_statement->execute();
  4826. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4827. foreach ($result as &$row) {
  4828. $ivr_menu_option_uuid = uuid();
  4829. $ivr_menu_id = check_str($row["ivr_menu_id"]);
  4830. $v_id = check_str($row["v_id"]);
  4831. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4832. $ivr_menu_option_digits = check_str($row["ivr_menu_options_digits"]);
  4833. $ivr_menu_option_action = check_str($row["ivr_menu_options_action"]);
  4834. $ivr_menu_option_param = check_str($row["ivr_menu_options_param"]);
  4835. $ivr_menu_option_order = check_str($row["ivr_menu_options_order"]);
  4836. $ivr_menu_option_description = check_str($row["ivr_menu_options_desc"]);
  4837. //$ivr_menu_options_action = str_replace("\\\\", "\\", $ivr_menu_options_action);
  4838. //get the ivr_menu_uuid
  4839. $ivr_menu_uuid = $ivr_menu_array[$ivr_menu_id]['ivr_menu_uuid'];
  4840. $sql = "insert into v_ivr_menu_options ";
  4841. $sql .= "(";
  4842. $sql .= "ivr_menu_option_uuid, ";
  4843. $sql .= "ivr_menu_uuid, ";
  4844. $sql .= "domain_uuid, ";
  4845. $sql .= "ivr_menu_option_digits, ";
  4846. $sql .= "ivr_menu_option_action, ";
  4847. $sql .= "ivr_menu_option_param, ";
  4848. $sql .= "ivr_menu_option_order, ";
  4849. $sql .= "ivr_menu_option_description ";
  4850. $sql .= ")";
  4851. $sql .= "values ";
  4852. $sql .= "(";
  4853. $sql .= "'".$ivr_menu_option_uuid."', ";
  4854. $sql .= "'".$ivr_menu_uuid."', ";
  4855. $sql .= "'".$domain_uuid."', ";
  4856. $sql .= "'".$ivr_menu_option_digits."', ";
  4857. $sql .= "'".$ivr_menu_option_action."', ";
  4858. $sql .= "'".$ivr_menu_option_param."', ";
  4859. $sql .= "'".$ivr_menu_option_order."', ";
  4860. $sql .= "'".$ivr_menu_option_description."' ";
  4861. $sql .= ")";
  4862. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4863. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4864. }
  4865. unset ($prep_statement);
  4866. //export the modules
  4867. $sql = "select * from v_modules ";
  4868. $prep_statement = $db->prepare($sql);
  4869. $prep_statement->execute();
  4870. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4871. foreach ($result as &$row) {
  4872. $module_uuid = uuid();
  4873. $v_id = check_str($row["v_id"]);
  4874. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4875. $module_label = check_str($row["module_label"]);
  4876. $module_name = check_str($row["module_name"]);
  4877. $module_description = check_str($row["module_desc"]);
  4878. $module_category = check_str($row["module_category"]);
  4879. $module_enabled = check_str($row["module_enabled"]);
  4880. $module_default_enabled = check_str($row["module_default_enabled"]);
  4881. $sql = "insert into v_modules ";
  4882. $sql .= "(";
  4883. $sql .= "module_uuid, ";
  4884. $sql .= "module_label, ";
  4885. $sql .= "module_name, ";
  4886. $sql .= "module_description, ";
  4887. $sql .= "module_category, ";
  4888. $sql .= "module_enabled, ";
  4889. $sql .= "module_default_enabled ";
  4890. $sql .= ")";
  4891. $sql .= "values ";
  4892. $sql .= "(";
  4893. $sql .= "'".$module_uuid."', ";
  4894. $sql .= "'".$module_label."', ";
  4895. $sql .= "'".$module_name."', ";
  4896. $sql .= "'".$module_description."', ";
  4897. $sql .= "'".$module_category."', ";
  4898. $sql .= "'".$module_enabled."', ";
  4899. $sql .= "'".$module_default_enabled."' ";
  4900. $sql .= ")";
  4901. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4902. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4903. }
  4904. unset ($prep_statement);
  4905. //export to php services
  4906. $sql = "select * from v_php_service ";
  4907. $prep_statement = $db->prepare($sql);
  4908. $prep_statement->execute();
  4909. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4910. foreach ($result as &$row) {
  4911. $php_service_uuid = uuid();
  4912. $service_name = check_str($row["service_name"]);
  4913. $v_id = check_str($row["v_id"]);
  4914. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4915. $service_script = check_str($row["service_script"]);
  4916. $service_enabled = check_str($row["service_enabled"]);
  4917. $service_description = check_str($row["service_description"]);
  4918. $sql = "insert into v_php_services ";
  4919. $sql .= "(";
  4920. $sql .= "php_service_uuid, ";
  4921. $sql .= "service_name, ";
  4922. $sql .= "domain_uuid, ";
  4923. $sql .= "service_script, ";
  4924. $sql .= "service_enabled, ";
  4925. $sql .= "service_description ";
  4926. $sql .= ")";
  4927. $sql .= "values ";
  4928. $sql .= "(";
  4929. $sql .= "'".$php_service_uuid."', ";
  4930. $sql .= "'".$service_name."', ";
  4931. $sql .= "'".$domain_uuid."', ";
  4932. $sql .= "'".$service_script."', ";
  4933. $sql .= "'".$service_enabled."', ";
  4934. $sql .= "'".$service_description."' ";
  4935. $sql .= ")";
  4936. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4937. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4938. }
  4939. unset ($prep_statement);
  4940. //export the recordings
  4941. $sql = "select * from v_recordings ";
  4942. $prep_statement = $db->prepare($sql);
  4943. $prep_statement->execute();
  4944. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4945. foreach ($result as &$row) {
  4946. $recording_uuid = uuid();
  4947. $v_id = check_str($row["v_id"]);
  4948. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4949. $recording_filename = check_str($row["recording_filename"]);
  4950. $recording_name = check_str($row["recording_name"]);
  4951. $recording_description = check_str($row["recording_desc"]);
  4952. $sql = "insert into v_recordings ";
  4953. $sql .= "(";
  4954. $sql .= "recording_uuid, ";
  4955. $sql .= "domain_uuid, ";
  4956. $sql .= "recording_filename, ";
  4957. $sql .= "recording_name, ";
  4958. $sql .= "recording_description ";
  4959. $sql .= ")";
  4960. $sql .= "values ";
  4961. $sql .= "(";
  4962. $sql .= "'".$recording_uuid."', ";
  4963. $sql .= "'".$domain_uuid."', ";
  4964. $sql .= "'".$recording_filename."', ";
  4965. $sql .= "'".$recording_name."', ";
  4966. $sql .= "'".$recording_description."' ";
  4967. $sql .= ")";
  4968. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  4969. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  4970. }
  4971. unset ($prep_statement);
  4972. //export the services
  4973. $sql = "select * from v_services ";
  4974. $prep_statement = $db->prepare($sql);
  4975. $prep_statement->execute();
  4976. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  4977. foreach ($result as &$row) {
  4978. $service_uuid = uuid();
  4979. $v_id = check_str($row["v_id"]);
  4980. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  4981. $service_name = check_str($row["v_service_name"]);
  4982. $service_type = check_str($row["v_service_type"]);
  4983. $service_data = check_str($row["v_service_data"]);
  4984. $service_cmd_start = check_str($row["v_service_cmd_start"]);
  4985. $service_cmd_stop = check_str($row["v_service_cmd_stop"]);
  4986. $service_cmd_restart = check_str($row["v_service_cmd_restart"]);
  4987. $service_description = check_str($row["v_service_desc"]);
  4988. $sql = "insert into v_services ";
  4989. $sql .= "(";
  4990. $sql .= "service_uuid, ";
  4991. $sql .= "domain_uuid, ";
  4992. $sql .= "service_name, ";
  4993. $sql .= "service_type, ";
  4994. $sql .= "service_data, ";
  4995. $sql .= "service_cmd_start, ";
  4996. $sql .= "service_cmd_stop, ";
  4997. $sql .= "service_cmd_restart, ";
  4998. $sql .= "service_description ";
  4999. $sql .= ")";
  5000. $sql .= "values ";
  5001. $sql .= "(";
  5002. $sql .= "'".$service_uuid."', ";
  5003. $sql .= "'".$domain_uuid."', ";
  5004. $sql .= "'".$service_name."', ";
  5005. $sql .= "'".$service_type."', ";
  5006. $sql .= "'".$service_data."', ";
  5007. $sql .= "'".$service_cmd_start."', ";
  5008. $sql .= "'".$service_cmd_stop."', ";
  5009. $sql .= "'".$service_cmd_restart."', ";
  5010. $sql .= "'".$service_description."' ";
  5011. $sql .= ")";
  5012. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5013. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5014. }
  5015. unset ($prep_statement);
  5016. //export the settings
  5017. $sql = "select * from v_settings ";
  5018. $prep_statement = $db->prepare($sql);
  5019. $prep_statement->execute();
  5020. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  5021. foreach ($result as &$row) {
  5022. $numbering_plan = check_str($row["numbering_plan"]);
  5023. $smtp_password = check_str($row["default_gateway"]);
  5024. $event_socket_ip_address = check_str($row["event_socket_ip_address"]);
  5025. $event_socket_port = check_str($row["event_socket_port"]);
  5026. $event_socket_password = check_str($row["event_socket_password"]);
  5027. $xml_rpc_http_port = check_str($row["xml_rpc_http_port"]);
  5028. $xml_rpc_auth_realm = check_str($row["xml_rpc_auth_realm"]);
  5029. $xml_rpc_auth_user = check_str($row["xml_rpc_auth_user"]);
  5030. $xml_rpc_auth_pass = check_str($row["xml_rpc_auth_pass"]);
  5031. $admin_pin = check_str($row["admin_pin"]);
  5032. $smtp_host = check_str($row["smtp_host"]);
  5033. $smtp_secure = check_str($row["smtp_secure"]);
  5034. $smtp_auth = check_str($row["smtp_auth"]);
  5035. $smtp_username = check_str($row["smtp_username"]);
  5036. $smtp_password = check_str($row["smtp_password"]);
  5037. $smtp_from = check_str($row["smtp_from"]);
  5038. $smtp_from_name = check_str($row["smtp_from_name"]);
  5039. $mod_shout_decoder = check_str($row["mod_shout_decoder"]);
  5040. $mod_shout_volume = check_str($row["mod_shout_volume"]);
  5041. $sql = "insert into v_settings ";
  5042. $sql .= "(";
  5043. $sql .= "numbering_plan, ";
  5044. $sql .= "event_socket_ip_address, ";
  5045. $sql .= "event_socket_port, ";
  5046. $sql .= "event_socket_password, ";
  5047. $sql .= "xml_rpc_http_port, ";
  5048. $sql .= "xml_rpc_auth_realm, ";
  5049. $sql .= "xml_rpc_auth_user, ";
  5050. $sql .= "xml_rpc_auth_pass, ";
  5051. $sql .= "admin_pin, ";
  5052. $sql .= "smtp_host, ";
  5053. $sql .= "smtp_secure, ";
  5054. $sql .= "smtp_auth, ";
  5055. $sql .= "smtp_username, ";
  5056. $sql .= "smtp_password, ";
  5057. $sql .= "smtp_from, ";
  5058. $sql .= "smtp_from_name, ";
  5059. $sql .= "mod_shout_decoder, ";
  5060. $sql .= "mod_shout_volume ";
  5061. $sql .= ")";
  5062. $sql .= "values ";
  5063. $sql .= "(";
  5064. $sql .= "'".$numbering_plan."', ";
  5065. $sql .= "'".$event_socket_ip_address."', ";
  5066. $sql .= "'".$event_socket_port."', ";
  5067. $sql .= "'".$event_socket_password."', ";
  5068. $sql .= "'".$xml_rpc_http_port."', ";
  5069. $sql .= "'".$xml_rpc_auth_realm."', ";
  5070. $sql .= "'".$xml_rpc_auth_user."', ";
  5071. $sql .= "'".$xml_rpc_auth_pass."', ";
  5072. $sql .= "'".$admin_pin."', ";
  5073. $sql .= "'".$smtp_host."', ";
  5074. $sql .= "'".$smtp_secure."', ";
  5075. $sql .= "'".$smtp_auth."', ";
  5076. $sql .= "'".$smtp_username."', ";
  5077. $sql .= "'".$smtp_password."', ";
  5078. $sql .= "'".$smtp_from."', ";
  5079. $sql .= "'".$smtp_from_name."', ";
  5080. $sql .= "'".$mod_shout_decoder."', ";
  5081. $sql .= "'".$mod_shout_volume."' ";
  5082. $sql .= ")";
  5083. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5084. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5085. }
  5086. unset ($prep_statement);
  5087. //get the time conditions and use diaplan_uuid to set the app_uuid
  5088. $sql = "select * from v_dialplan_includes_details ";
  5089. $prepstatement = $db->prepare(check_sql($sql));
  5090. $prepstatement->execute();
  5091. $x = 0;
  5092. $result = $prepstatement->fetchAll();
  5093. foreach ($result as &$row) {
  5094. $dialplan_include_id = $row["dialplan_include_id"];
  5095. $field_type = $row["field_type"];
  5096. //$field_data = $row["field_data"];
  5097. //get the dialplan_uuid
  5098. $dialplan_uuid = $dialplan_array[$dialplan_include_id]['dialplan_uuid'];
  5099. switch ($row['field_type']) {
  5100. case "hour":
  5101. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5102. $x++;
  5103. break;
  5104. case "minute":
  5105. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5106. $x++;
  5107. break;
  5108. case "minute-of-day":
  5109. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5110. $x++;
  5111. break;
  5112. case "mday":
  5113. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5114. $x++;
  5115. break;
  5116. case "mweek":
  5117. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5118. $x++;
  5119. break;
  5120. case "mon":
  5121. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5122. $x++;
  5123. break;
  5124. case "yday":
  5125. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5126. $x++;
  5127. break;
  5128. case "year":
  5129. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5130. $x++;
  5131. break;
  5132. case "wday":
  5133. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5134. $x++;
  5135. break;
  5136. case "week":
  5137. $time_array[$x]['dialplan_uuid'] = $dialplan_uuid;
  5138. $x++;
  5139. break;
  5140. }
  5141. }
  5142. unset ($prepstatement);
  5143. foreach ($time_array as &$row) {
  5144. $sql = "update v_dialplans set ";
  5145. $sql .= "app_uuid = '4b821450-926b-175a-af93-a03c441818b1' ";
  5146. $sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."' ";
  5147. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5148. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5149. unset($sql);
  5150. }
  5151. //get the variables
  5152. $sql = "select * from v_vars ";
  5153. $prep_statement = $db->prepare($sql);
  5154. $prep_statement->execute();
  5155. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  5156. foreach ($result as &$row) {
  5157. $v_id = check_str($row["v_id"]);
  5158. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5159. $var_uuid = uuid();
  5160. $var_name = check_str($row["var_name"]);
  5161. $var_value = check_str($row["var_value"]);
  5162. $var_cat = check_str($row["var_cat"]);
  5163. $var_enabled = check_str($row["var_enabled"]);
  5164. $var_order = check_str($row["var_order"]);
  5165. $var_description = check_str($row["var_desc"]);
  5166. $sql = "insert into v_vars ";
  5167. $sql .= "(";
  5168. $sql .= "var_uuid, ";
  5169. $sql .= "var_name, ";
  5170. $sql .= "var_value, ";
  5171. $sql .= "var_cat, ";
  5172. $sql .= "var_enabled, ";
  5173. $sql .= "var_order, ";
  5174. $sql .= "var_description ";
  5175. $sql .= ")";
  5176. $sql .= "values ";
  5177. $sql .= "(";
  5178. $sql .= "'".$var_uuid."', ";
  5179. $sql .= "'".$var_name."', ";
  5180. $sql .= "'".$var_value."', ";
  5181. $sql .= "'".$var_cat."', ";
  5182. $sql .= "'".$var_enabled."', ";
  5183. $sql .= "'".$var_order."', ";
  5184. $sql .= "'".$var_description."' ";
  5185. $sql .= ")";
  5186. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5187. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5188. }
  5189. unset ($prep_statement);
  5190. //export the virtual tables
  5191. $sql = "select * from v_virtual_tables ";
  5192. $prep_statement = $db->prepare($sql);
  5193. $prep_statement->execute();
  5194. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  5195. foreach ($result as &$row) {
  5196. $v_id = check_str($row["v_id"]);
  5197. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5198. $virtual_table_id = check_str($row["virtual_table_id"]);
  5199. $virtual_table_uuid = uuid();
  5200. //set the virtual_table_uuid
  5201. $virtual_table_array[$virtual_table_id]['virtual_table_uuid'] = $virtual_table_uuid;
  5202. }
  5203. foreach ($result as &$row) {
  5204. $v_id = check_str($row["v_id"]);
  5205. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5206. $virtual_table_id = check_str($row["virtual_table_id"]);
  5207. $virtual_table_category = check_str($row["virtual_table_category"]);
  5208. $virtual_table_label = check_str($row["virtual_table_label"]);
  5209. $virtual_table_name = check_str($row["virtual_table_name"]);
  5210. $virtual_table_auth = check_str($row["virtual_table_auth"]);
  5211. $virtual_table_captcha = check_str($row["virtual_table_captcha"]);
  5212. $virtual_table_parent_id = check_str($row["virtual_table_parent_id"]);
  5213. $virtual_table_description = check_str($row["virtual_table_desc"]);
  5214. //get the uuids
  5215. $virtual_table_uuid = $virtual_table_array[$virtual_table_id]['virtual_table_uuid'];
  5216. if (strlen($virtual_table_parent_id) > 0) {
  5217. $virtual_table_parent_uuid = $virtual_table_array[$virtual_table_parent_id]['virtual_table_uuid'];
  5218. }
  5219. $sql = "insert into v_virtual_tables ";
  5220. $sql .= "(";
  5221. $sql .= "virtual_table_uuid, ";
  5222. $sql .= "domain_uuid, ";
  5223. $sql .= "virtual_table_category, ";
  5224. $sql .= "virtual_table_label, ";
  5225. $sql .= "virtual_table_name, ";
  5226. $sql .= "virtual_table_auth, ";
  5227. $sql .= "virtual_table_captcha, ";
  5228. $sql .= "virtual_table_parent_uuid, ";
  5229. $sql .= "virtual_table_description ";
  5230. $sql .= ")";
  5231. $sql .= "values ";
  5232. $sql .= "(";
  5233. $sql .= "'".$virtual_table_uuid."', ";
  5234. $sql .= "'".$domain_uuid."', ";
  5235. $sql .= "'".$virtual_table_category."', ";
  5236. $sql .= "'".$virtual_table_label."', ";
  5237. $sql .= "'".$virtual_table_name."', ";
  5238. $sql .= "'".$virtual_table_auth."', ";
  5239. $sql .= "'".$virtual_table_captcha."', ";
  5240. if (strlen($virtual_table_parent_uuid) > 0) {
  5241. $sql .= "'".$virtual_table_parent_uuid."', ";
  5242. }
  5243. else {
  5244. $sql .= "null, ";
  5245. }
  5246. $sql .= "'".$virtual_table_description."' ";
  5247. $sql .= ")";
  5248. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5249. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5250. }
  5251. unset ($prep_statement);
  5252. //export the virtual table fields
  5253. $sql = "select * from v_virtual_table_fields ";
  5254. $prep_statement = $db->prepare($sql);
  5255. $prep_statement->execute();
  5256. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  5257. foreach ($result as &$row) {
  5258. $virtual_table_field_id = check_str($row["virtual_table_field_id"]);
  5259. $virtual_table_field_uuid = uuid();
  5260. $v_id = check_str($row["v_id"]);
  5261. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5262. $virtual_table_id = check_str($row["virtual_table_id"]);
  5263. $virtual_field_label = check_str($row["virtual_field_label"]);
  5264. $virtual_field_name = check_str($row["virtual_field_name"]);
  5265. $virtual_field_type = check_str($row["virtual_field_type"]);
  5266. $virtual_field_list_hidden = check_str($row["virtual_field_list_hidden"]);
  5267. $virtual_field_column = check_str($row["virtual_field_column"]);
  5268. $virtual_field_required = check_str($row["virtual_field_required"]);
  5269. $virtual_field_order = check_str($row["virtual_field_order"]);
  5270. $virtual_field_order_tab = check_str($row["virtual_field_order_tab"]);
  5271. $virtual_field_description = check_str($row["virtual_field_desc"]);
  5272. $virtual_field_value = check_str($row["virtual_field_value"]);
  5273. //get the virtual_table_uuid
  5274. $virtual_table_uuid = $virtual_table_array[$virtual_table_id]['virtual_table_uuid'];
  5275. //set virtual_table_field_uuid
  5276. $virtual_table_field_array[$virtual_table_field_id]['virtual_table_field_uuid'] = $virtual_table_field_uuid;
  5277. if (strlen($virtual_table_uuid) > 0) {
  5278. $sql = "insert into v_virtual_table_fields ";
  5279. $sql .= "(";
  5280. $sql .= "virtual_table_field_uuid, ";
  5281. $sql .= "domain_uuid, ";
  5282. $sql .= "virtual_table_uuid, ";
  5283. $sql .= "virtual_field_label, ";
  5284. $sql .= "virtual_field_name, ";
  5285. $sql .= "virtual_field_type, ";
  5286. $sql .= "virtual_field_list_hidden, ";
  5287. $sql .= "virtual_field_column, ";
  5288. $sql .= "virtual_field_required, ";
  5289. $sql .= "virtual_field_order, ";
  5290. $sql .= "virtual_field_order_tab, ";
  5291. $sql .= "virtual_field_description, ";
  5292. $sql .= "virtual_field_value ";
  5293. $sql .= ")";
  5294. $sql .= "values ";
  5295. $sql .= "(";
  5296. $sql .= "'".$virtual_table_field_uuid."', ";
  5297. $sql .= "'".$domain_uuid."', ";
  5298. $sql .= "'".$virtual_table_uuid."', ";
  5299. $sql .= "'".$virtual_field_label."', ";
  5300. $sql .= "'".$virtual_field_name."', ";
  5301. $sql .= "'".$virtual_field_type."', ";
  5302. $sql .= "'".$virtual_field_list_hidden."', ";
  5303. $sql .= "'".$virtual_field_column."', ";
  5304. $sql .= "'".$virtual_field_required."', ";
  5305. $sql .= "'".$virtual_field_order."', ";
  5306. $sql .= "'".$virtual_field_order_tab."', ";
  5307. $sql .= "'".$virtual_field_description."', ";
  5308. $sql .= "'".$virtual_field_value."' ";
  5309. $sql .= ")";
  5310. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5311. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5312. }
  5313. }
  5314. unset ($prep_statement);
  5315. //export the virtual table data
  5316. $sql = "select * from v_virtual_table_data ";
  5317. $prep_statement = $db->prepare($sql);
  5318. $prep_statement->execute();
  5319. while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
  5320. $virtual_table_data_id = check_str($row["virtual_table_data_id"]);
  5321. $virtual_table_data_uuid = uuid();
  5322. $v_id = check_str($row["v_id"]);
  5323. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5324. $virtual_table_id = check_str($row["virtual_table_id"]);
  5325. $virtual_data_row_id = check_str($row["virtual_data_row_id"]);
  5326. $virtual_field_name = check_str($row["virtual_field_name"]);
  5327. $virtual_data_field_value = check_str($row["virtual_data_field_value"]);
  5328. $virtual_data_add_user = check_str($row["virtual_data_add_user"]);
  5329. $virtual_data_add_date = check_str($row["virtual_data_add_date"]);
  5330. $virtual_data_del_user = check_str($row["virtual_data_del_user"]);
  5331. $virtual_data_del_date = check_str($row["virtual_data_del_date"]);
  5332. $virtual_table_parent_id = check_str($row["virtual_table_parent_id"]);
  5333. $virtual_data_parent_row_uuid = check_str($row["virtual_data_parent_row_id"]);
  5334. //get the virtual_table_uuid
  5335. $virtual_table_uuid = $virtual_table_array[$virtual_table_id]['virtual_table_uuid'];
  5336. if (strlen($virtual_table_parent_id) > 0) {
  5337. $virtual_table_parent_uuid = $virtual_table_array[$virtual_table_parent_id]['virtual_table_uuid'];
  5338. }
  5339. //get or set the virtual table data row uuid
  5340. if (strlen($virtual_table_array[$virtual_data_row_id]['virtual_data_row_uuid']) == 0) {
  5341. $virtual_data_row_uuid = uuid();
  5342. $virtual_table_array[$virtual_data_row_id]['virtual_data_row_uuid'] = $virtual_data_row_uuid;
  5343. }
  5344. else {
  5345. $virtual_data_row_uuid = $virtual_table_array[$virtual_data_row_id]['virtual_data_row_uuid'];
  5346. }
  5347. $sql = "insert into v_virtual_table_data ";
  5348. $sql .= "(";
  5349. $sql .= "virtual_table_data_uuid, ";
  5350. $sql .= "domain_uuid, ";
  5351. $sql .= "virtual_table_uuid, ";
  5352. $sql .= "virtual_data_row_uuid, ";
  5353. $sql .= "virtual_field_name, ";
  5354. $sql .= "virtual_data_field_value, ";
  5355. $sql .= "virtual_table_parent_uuid, ";
  5356. $sql .= "virtual_data_parent_row_uuid, ";
  5357. $sql .= "virtual_data_add_user, ";
  5358. $sql .= "virtual_data_add_date, ";
  5359. $sql .= "virtual_data_del_user, ";
  5360. $sql .= "virtual_data_del_date ";
  5361. $sql .= ")";
  5362. $sql .= "values ";
  5363. $sql .= "(";
  5364. $sql .= "'".$virtual_table_data_uuid."', ";
  5365. $sql .= "'".$domain_uuid."', ";
  5366. $sql .= "'".$virtual_table_uuid."', ";
  5367. $sql .= "'".$virtual_data_row_uuid."', ";
  5368. $sql .= "'".$virtual_field_name."', ";
  5369. $sql .= "'".$virtual_data_field_value."', ";
  5370. if (strlen($virtual_table_parent_uuid) > 0) {
  5371. $sql .= "'".$virtual_table_parent_uuid."', ";
  5372. }
  5373. else {
  5374. $sql .= "null, ";
  5375. }
  5376. if (strlen($virtual_data_parent_row_uuid) > 0) {
  5377. $sql .= "'".$virtual_data_parent_row_uuid."', ";
  5378. }
  5379. else {
  5380. $sql .= "null, ";
  5381. }
  5382. $sql .= "'".$virtual_data_add_user."', ";
  5383. $sql .= "'".$virtual_data_add_date."', ";
  5384. $sql .= "'".$virtual_data_del_user."', ";
  5385. $sql .= "'".$virtual_data_del_date."' ";
  5386. $sql .= ")";
  5387. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5388. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5389. }
  5390. unset ($prep_statement);
  5391. //get the virtual table data name value pairs
  5392. $sql = "select * from v_virtual_table_data_types_name_value ";
  5393. $prep_statement = $db->prepare($sql);
  5394. $prep_statement->execute();
  5395. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  5396. foreach ($result as &$row) {
  5397. $virtual_table_data_types_name_value_uuid = uuid();
  5398. $v_id = check_str($row["v_id"]);
  5399. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5400. $virtual_table_id = check_str($row["virtual_table_id"]);
  5401. $virtual_table_field_id = check_str($row["virtual_table_field_id"]);
  5402. $virtual_data_types_name = check_str($row["virtual_data_types_name"]);
  5403. $virtual_data_types_value = check_str($row["virtual_data_types_value"]);
  5404. //get the virtual_table_uuid
  5405. $virtual_table_uuid = $virtual_table_array[$virtual_table_id]['virtual_table_uuid'];
  5406. //get the virtual_table_field_uuid
  5407. $virtual_table_field_uuid = $virtual_table_field_array[$virtual_table_field_id]['virtual_table_field_uuid'];
  5408. if (strlen($virtual_table_uuid) > 0 && strlen($virtual_table_field_uuid) > 0) {
  5409. $sql = "insert into v_virtual_table_data_types_name_value ";
  5410. $sql .= "(";
  5411. $sql .= "virtual_table_data_types_name_value_uuid, ";
  5412. $sql .= "domain_uuid, ";
  5413. $sql .= "virtual_table_uuid, ";
  5414. $sql .= "virtual_table_field_uuid, ";
  5415. $sql .= "virtual_data_types_name, ";
  5416. $sql .= "virtual_data_types_value ";
  5417. $sql .= ")";
  5418. $sql .= "values ";
  5419. $sql .= "(";
  5420. $sql .= "'".$virtual_table_data_types_name_value_uuid."', ";
  5421. $sql .= "'".$domain_uuid."', ";
  5422. $sql .= "'".$virtual_table_uuid."', ";
  5423. $sql .= "'".$virtual_table_field_uuid."', ";
  5424. $sql .= "'".$virtual_data_types_name."', ";
  5425. $sql .= "'".$virtual_data_types_value."' ";
  5426. $sql .= ")";
  5427. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5428. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5429. }
  5430. }
  5431. unset ($prep_statement);
  5432. //export voicemail greetings
  5433. $sql = "select * from v_voicemail_greetings ";
  5434. $prep_statement = $db->prepare($sql);
  5435. $prep_statement->execute();
  5436. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  5437. foreach ($result as &$row) {
  5438. $greeting_uuid = uuid();
  5439. $v_id = check_str($row["v_id"]);
  5440. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5441. $user_id = check_str($row["user_id"]);
  5442. $greeting_name = check_str($row["greeting_name"]);
  5443. $greeting_description = check_str($row["greeting_description"]);
  5444. $sql = "insert into v_voicemail_greetings ";
  5445. $sql .= "(";
  5446. $sql .= "greeting_uuid, ";
  5447. $sql .= "user_id, ";
  5448. $sql .= "domain_uuid, ";
  5449. $sql .= "greeting_name, ";
  5450. $sql .= "greeting_description ";
  5451. $sql .= ")";
  5452. $sql .= "values ";
  5453. $sql .= "(";
  5454. $sql .= "'".$greeting_uuid."', ";
  5455. $sql .= "'".$user_id."', ";
  5456. $sql .= "'".$domain_uuid."', ";
  5457. $sql .= "'".$greeting_name."', ";
  5458. $sql .= "'".$greeting_description."' ";
  5459. $sql .= ")";
  5460. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5461. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5462. }
  5463. unset ($prep_statement);
  5464. //get the xmpp info
  5465. $sql = "select * from v_xmpp ";
  5466. $prep_statement = $db->prepare($sql);
  5467. $prep_statement->execute();
  5468. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  5469. foreach ($result as &$row) {
  5470. $xmpp_profile_uuid = uuid();
  5471. $v_id = check_str($row["v_id"]);
  5472. $domain_uuid = $domain_array[$v_id]['domain_uuid'];
  5473. $profile_name = check_str($row["profile_name"]);
  5474. $username = check_str($row["username"]);
  5475. $password = check_str($row["password"]);
  5476. $dialplan = check_str($row["dialplan"]);
  5477. $context = check_str($row["context"]);
  5478. $rtp_ip = check_str($row["rtp_ip"]);
  5479. $ext_rtp_ip = check_str($row["ext_rtp_ip"]);
  5480. $auto_login = check_str($row["auto_login"]);
  5481. $sasl_type = check_str($row["sasl_type"]);
  5482. $xmpp_server = check_str($row["xmpp_server"]);
  5483. $tls_enable = check_str($row["tls_enable"]);
  5484. $usr_rtp_timer = check_str($row["usr_rtp_timer"]);
  5485. $default_exten = check_str($row["default_exten"]);
  5486. $vad = check_str($row["vad"]);
  5487. $avatar = check_str($row["avatar"]);
  5488. $candidate_acl = check_str($row["candidate_acl"]);
  5489. $local_network_acl = check_str($row["local_network_acl"]);
  5490. $enabled = check_str($row["enabled"]);
  5491. $description = check_str($row["description"]);
  5492. $sql = "insert into v_xmpp ";
  5493. $sql .= "(";
  5494. $sql .= "xmpp_profile_uuid, ";
  5495. $sql .= "domain_uuid, ";
  5496. $sql .= "profile_name, ";
  5497. $sql .= "username, ";
  5498. $sql .= "password, ";
  5499. $sql .= "dialplan, ";
  5500. $sql .= "context, ";
  5501. $sql .= "rtp_ip, ";
  5502. $sql .= "ext_rtp_ip, ";
  5503. $sql .= "auto_login, ";
  5504. $sql .= "sasl_type, ";
  5505. $sql .= "xmpp_server, ";
  5506. $sql .= "tls_enable, ";
  5507. $sql .= "usr_rtp_timer, ";
  5508. $sql .= "default_exten, ";
  5509. $sql .= "vad, ";
  5510. $sql .= "avatar, ";
  5511. $sql .= "candidate_acl, ";
  5512. $sql .= "local_network_acl, ";
  5513. $sql .= "enabled, ";
  5514. $sql .= "description ";
  5515. $sql .= ")";
  5516. $sql .= "values ";
  5517. $sql .= "(";
  5518. $sql .= "'".$xmpp_profile_uuid."', ";
  5519. $sql .= "'".$domain_uuid."', ";
  5520. $sql .= "'".$profile_name."', ";
  5521. $sql .= "'".$username."', ";
  5522. $sql .= "'".$password."', ";
  5523. $sql .= "'".$dialplan."', ";
  5524. $sql .= "'".$context."', ";
  5525. $sql .= "'".$rtp_ip."', ";
  5526. $sql .= "'".$ext_rtp_ip."', ";
  5527. $sql .= "'".$auto_login."', ";
  5528. $sql .= "'".$sasl_type."', ";
  5529. $sql .= "'".$xmpp_server."', ";
  5530. $sql .= "'".$tls_enable."', ";
  5531. $sql .= "'".$usr_rtp_timer."', ";
  5532. $sql .= "'".$default_exten."', ";
  5533. $sql .= "'".$vad."', ";
  5534. $sql .= "'".$avatar."', ";
  5535. $sql .= "'".$candidate_acl."', ";
  5536. $sql .= "'".$local_network_acl."', ";
  5537. $sql .= "'".$enabled."', ";
  5538. $sql .= "'".$description."' ";
  5539. $sql .= ")";
  5540. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5541. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5542. }
  5543. unset ($prep_statement);
  5544. //get the xml cdr info
  5545. $sql = "select * from v_xml_cdr ";
  5546. if ($debug) {
  5547. $sql .= "limit 3 ";
  5548. }
  5549. $prep_statement = $db->prepare($sql);
  5550. $prep_statement->execute();
  5551. while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
  5552. $uuid = check_str($row["v_id"]);
  5553. $domain_name = check_str($row["domain_name"]);
  5554. $accountcode = check_str($row["accountcode"]);
  5555. $uuid = check_str($row["uuid"]);
  5556. $direction = check_str($row["direction"]);
  5557. $default_language = check_str($row["default_language"]);
  5558. $context = check_str($row["context"]);
  5559. $xml_cdr = check_str($row["xml_cdr"]);
  5560. $caller_id_name = check_str($row["caller_id_name"]);
  5561. $caller_id_number = check_str($row["caller_id_number"]);
  5562. $destination_number = check_str($row["destination_number"]);
  5563. $start_epoch = check_str($row["start_epoch"]);
  5564. $start_stamp = check_str($row["start_stamp"]);
  5565. $answer_stamp = check_str($row["answer_stamp"]);
  5566. $answer_epoch = check_str($row["answer_epoch"]);
  5567. $end_epoch = check_str($row["end_epoch"]);
  5568. $end_stamp = check_str($row["end_stamp"]);
  5569. $duration = check_str($row["duration"]);
  5570. $mduration = check_str($row["mduration"]);
  5571. $billsec = check_str($row["billsec"]);
  5572. $billmsec = check_str($row["billmsec"]);
  5573. $bridge_uuid = check_str($row["bridge_uuid"]);
  5574. $read_codec = check_str($row["read_codec"]);
  5575. $read_rate = check_str($row["read_rate"]);
  5576. $write_codec = check_str($row["write_codec"]);
  5577. $write_rate = check_str($row["write_rate"]);
  5578. $remote_media_ip = check_str($row["remote_media_ip"]);
  5579. $network_addr = check_str($row["network_addr"]);
  5580. $recording_file = check_str($row["recording_file"]);
  5581. $leg = check_str($row["leg"]);
  5582. $pdd_ms = check_str($row["pdd_ms"]);
  5583. $last_app = check_str($row["last_app"]);
  5584. $last_arg = check_str($row["last_arg"]);
  5585. $cc_side = check_str($row["cc_side"]);
  5586. $cc_member_uuid = check_str($row["cc_member_uuid"]);
  5587. $cc_queue_joined_epoch = check_str($row["cc_queue_joined_epoch"]);
  5588. $cc_queue = check_str($row["cc_queue"]);
  5589. $cc_member_session_uuid = check_str($row["cc_member_session_uuid"]);
  5590. $cc_agent = check_str($row["cc_agent"]);
  5591. $cc_agent_type = check_str($row["cc_agent_type"]);
  5592. $waitsec = check_str($row["waitsec"]);
  5593. $conference_name = check_str($row["conference_name"]);
  5594. $conference_uuid = check_str($row["conference_uuid"]);
  5595. $conference_member_id = check_str($row["conference_member_id"]);
  5596. $digits_dialed = check_str($row["digits_dialed"]);
  5597. $hangup_cause = check_str($row["hangup_cause"]);
  5598. $hangup_cause_q850 = check_str($row["hangup_cause_q850"]);
  5599. $sip_hangup_disposition = check_str($row["sip_hangup_disposition"]);
  5600. $sql = "insert into v_xml_cdr ";
  5601. $sql .= "(";
  5602. $sql .= "domain_uuid, ";
  5603. $sql .= "domain_name, ";
  5604. $sql .= "accountcode, ";
  5605. $sql .= "uuid, ";
  5606. $sql .= "direction, ";
  5607. $sql .= "default_language, ";
  5608. $sql .= "context, ";
  5609. $sql .= "xml_cdr, ";
  5610. $sql .= "caller_id_name, ";
  5611. $sql .= "caller_id_number, ";
  5612. $sql .= "destination_number, ";
  5613. $sql .= "start_epoch, ";
  5614. $sql .= "start_stamp, ";
  5615. $sql .= "answer_stamp, ";
  5616. $sql .= "answer_epoch, ";
  5617. $sql .= "end_epoch, ";
  5618. $sql .= "end_stamp, ";
  5619. $sql .= "duration, ";
  5620. $sql .= "mduration, ";
  5621. $sql .= "billsec, ";
  5622. $sql .= "billmsec, ";
  5623. $sql .= "bridge_uuid, ";
  5624. $sql .= "read_codec, ";
  5625. $sql .= "read_rate, ";
  5626. $sql .= "write_codec, ";
  5627. $sql .= "write_rate, ";
  5628. $sql .= "remote_media_ip, ";
  5629. $sql .= "network_addr, ";
  5630. $sql .= "recording_file, ";
  5631. $sql .= "leg, ";
  5632. $sql .= "pdd_ms, ";
  5633. $sql .= "last_app, ";
  5634. $sql .= "last_arg, ";
  5635. $sql .= "cc_side, ";
  5636. $sql .= "cc_member_uuid, ";
  5637. $sql .= "cc_queue_joined_epoch, ";
  5638. $sql .= "cc_queue, ";
  5639. $sql .= "cc_member_session_uuid, ";
  5640. $sql .= "cc_agent, ";
  5641. $sql .= "cc_agent_type, ";
  5642. $sql .= "waitsec, ";
  5643. $sql .= "conference_name, ";
  5644. $sql .= "conference_uuid, ";
  5645. $sql .= "conference_member_id, ";
  5646. $sql .= "digits_dialed, ";
  5647. $sql .= "hangup_cause, ";
  5648. $sql .= "hangup_cause_q850, ";
  5649. $sql .= "sip_hangup_disposition ";
  5650. $sql .= ")";
  5651. $sql .= "values ";
  5652. $sql .= "(";
  5653. $sql .= "'".$domain_uuid."', ";
  5654. $sql .= "'".$domain_name."', ";
  5655. $sql .= "'".$accountcode."', ";
  5656. $sql .= "'".$uuid."', ";
  5657. $sql .= "'".$direction."', ";
  5658. $sql .= "'".$default_language."', ";
  5659. $sql .= "'".$context."', ";
  5660. $sql .= "'".$xml_cdr."', ";
  5661. $sql .= "'".$caller_id_name."', ";
  5662. $sql .= "'".$caller_id_number."', ";
  5663. $sql .= "'".$destination_number."', ";
  5664. $sql .= "'".$start_epoch."', ";
  5665. if (strlen($start_stamp) > 0) {
  5666. $sql .= "'".$start_stamp."', ";
  5667. }
  5668. else {
  5669. $sql .= "null, ";
  5670. }
  5671. if (strlen($answer_stamp) > 0) {
  5672. $sql .= "'".$answer_stamp."', ";
  5673. }
  5674. else {
  5675. $sql .= "null, ";
  5676. }
  5677. if (strlen($answer_epoch) > 0) {
  5678. $sql .= "'".$answer_epoch."', ";
  5679. }
  5680. else {
  5681. $sql .= "null, ";
  5682. }
  5683. $sql .= "'".$end_epoch."', ";
  5684. $sql .= "'".$end_stamp."', ";
  5685. if (strlen($duration) > 0) {
  5686. $sql .= "'".$duration."', ";
  5687. }
  5688. else {
  5689. $sql .= "null, ";
  5690. }
  5691. if (strlen($mduration) > 0) {
  5692. $sql .= "'".$mduration."', ";
  5693. }
  5694. else {
  5695. $sql .= "null, ";
  5696. }
  5697. $sql .= "'".$billsec."', ";
  5698. $sql .= "'".$billmsec."', ";
  5699. $sql .= "'".$bridge_uuid."', ";
  5700. $sql .= "'".$read_codec."', ";
  5701. $sql .= "'".$read_rate."', ";
  5702. $sql .= "'".$write_codec."', ";
  5703. $sql .= "'".$write_rate."', ";
  5704. $sql .= "'".$remote_media_ip."', ";
  5705. $sql .= "'".$network_addr."', ";
  5706. $sql .= "'".$recording_file."', ";
  5707. $sql .= "'".$leg."', ";
  5708. if (strlen($cc_member_uuid) > 0) {
  5709. $sql .= "'".$pdd_ms."', ";
  5710. }
  5711. else {
  5712. $sql .= "null, ";
  5713. }
  5714. $sql .= "'".$last_app."', ";
  5715. $sql .= "'".$last_arg."', ";
  5716. $sql .= "'".$cc_side."', ";
  5717. if (strlen($cc_member_uuid) > 0) {
  5718. $sql .= "'".$cc_member_uuid."', ";
  5719. }
  5720. else {
  5721. $sql .= "null, ";
  5722. }
  5723. $sql .= "'".$cc_queue_joined_epoch."', ";
  5724. $sql .= "'".$cc_queue."', ";
  5725. if (strlen($cc_member_session_uuid) > 0) {
  5726. $sql .= "'".$cc_member_session_uuid."', ";
  5727. }
  5728. else {
  5729. $sql .= "null, ";
  5730. }
  5731. $sql .= "'".$cc_agent."', ";
  5732. $sql .= "'".$cc_agent_type."', ";
  5733. if (strlen($waitsec) > 0) {
  5734. $sql .= "'".$waitsec."', ";
  5735. }
  5736. else {
  5737. $sql .= "null, ";
  5738. }
  5739. $sql .= "'".$conference_name."', ";
  5740. if (strlen($conference_uuid) > 0) {
  5741. $sql .= "'".$conference_uuid."', ";
  5742. }
  5743. else {
  5744. $sql .= "null, ";
  5745. }
  5746. $sql .= "'".$conference_member_id."', ";
  5747. $sql .= "'".$digits_dialed."', ";
  5748. $sql .= "'".$hangup_cause."', ";
  5749. if (strlen($hangup_cause_q850) > 0) {
  5750. $sql .= "'".$hangup_cause_q850."', ";
  5751. }
  5752. else {
  5753. $sql .= "null, ";
  5754. }
  5755. $sql .= "'".$sip_hangup_disposition."' ";
  5756. $sql .= ")";
  5757. if ($export_type == "sql") { echo check_sql($sql).";\n"; }
  5758. if ($export_type == "db") { $dest_db->exec(check_sql($sql)); }
  5759. }
  5760. unset ($prep_statement);
  5761. //used for debugging
  5762. if ($debug) {
  5763. echo "</pre>\n";
  5764. }
  5765. ?>